-
Notifications
You must be signed in to change notification settings - Fork 0
/
smsstartpay.php
79 lines (66 loc) · 2.01 KB
/
smsstartpay.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
<?php
session_start();
require_once('auth.php');
require_once('Store.inc.php');
// get
$CustomerID = $_SESSION['CustomerID'];
$itemCode = $_REQUEST['ItemID'];
if(!isset($CustomerID)) die('2');
if(!isset($itemCode)) die('3');
// price & description
list($itemPrice, $itemName) = store_GetItemPriceDescByCode($itemCode, 2);
if($itemPrice < 0)
die('itemprice');
// get customer email
require_once('dbinfo.inc.php');
$tsql = "SELECT * FROM AccountInfo WHERE CustomerID=?";
$params = array($CustomerID);
$member = db_exec($conn, $tsql, $params);
$CustomerEmail=trim($member['email']);
// get country geo-ip code
require_once('matomy.inc.php');
$geoIpCode = matomy_get_geoIpCode();
// assemble pass-thru param
$param = "$CustomerID:$itemCode:$itemPrice:$CustomerEmail:$geoIpCode";
//
// Exec BOKU prepare call
//
$url = "https://api2.boku.com/billing/request?action=prepare";
$url .= "&merchant-id=arktosgroup";
$url .= "&password=f1gz45hd5";
$url .= "&service-id=6dfb7ffc7a8c4f6724a3777d";
$url .= "&row-ref=$itemPrice";
$url .= "&desc=" . urlencode($itemName);
$url .= "¶m=$param";
// setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 0);
// Get response from the server.
$resp = curl_exec($ch);
if(!$resp) {
exit('SMS prepare failed: '.curl_error($ch).'('.curl_errno($ch).')');
}
// parse returned XML
$xml_obj = simplexml_load_string($resp);
$xml = object2array($xml_obj);
if($xml["result-code"] != 0)
{
echo "There was a error initiating SMS payment<br>";
echo $xml["result-code"] . "<br>";
echo $xml["result-msg"] . "<br>";
exit();
}
// redirect to buying URL
$buyUrl = $xml['buy-url'];
header("location: $buyUrl");
exit();
function object2array($object)
{
return @json_decode(@json_encode($object),1);
}
?>