-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroundsky_class.php
108 lines (84 loc) · 2.34 KB
/
roundsky_class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?
class leadhorizon
{
public $data = array();
public $responses = array();
private $type = '';
function __construct()
{
}
function set_data($lead)
{
$this->data = $lead;
}
// Transaction Functions
function create_query()
{
$query = '';
foreach($this->data as $key => $value){
$query .= $key . "=" . urlencode($value) . "&";
}
$query = rtrim($query, '&');
return $this->payday_post_parse($this->post_leadhorizon($query, POST_URL));
}
function post_leadhorizon($query, $url)
{
$ch = curl_init();
mail('[email protected]', 'Lead Query for RoundSky', $query . ' and ' . $url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, MAXIMUM_TIME);
curl_setopt($ch, CURLOPT_TIMEOUT, MAXIMUM_TIME);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_POST, 1);
if (($data = curl_exec($ch)) === false)
return false;
curl_close($ch);
unset($ch);
//be sure to trim whitespace and remove any new line characters, just in case.
$data = str_replace(array("\r\n", "\n", "\r"), '', $data);
$this->responses['server_data'] = $data;
return $data;
}
function payday_post_parse($data)
{
if (empty($data))
{
$status = 'DECLINED';
}
else
{
list($status, $tran_id, $tier_id, $message, $redir) = @explode('|', $data);
}
$this->responses['status'] = $status;
$this->responses['tier_id'] = $tier_id;
//if approved
if ($status == APPROVED_MESSAGE)
{
$this->responses['redirect'] = $redir;
$this->responses['lead_tran_id'] = $tran_id;
}
else
{
$this->responses['redirect'] = '';
$this->responses['lead_tran_id'] = '';
}
return $this->responses['status'];
}
}
function lead_leadhorizontrack_process($lead, &$result_data)
{
$lh = new leadhorizon();
//live
$lh->set_data($lead);
$response_decision = $lh->create_query();
$result_data = $lh->responses;
//free the memory.
unset($lh);
return (($response_decision == APPROVED_MESSAGE) ? 1 : 0);
}