-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProcessTransaction.php
52 lines (47 loc) · 1.35 KB
/
ProcessTransaction.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
<?php
// STEP 1: Build the request array
$requestData = array
(
"MerchantID" => $_REQUEST["MerchantID"],
"LaneID" => $_REQUEST["02"],
"TranType" => $_REQUEST["TranType"],
"TranCode" => $_REQUEST["TranCode"],
"InvoiceNo" => $_REQUEST["InvoiceNo"],
"RefNo" => $_REQUEST["RefNo"],
"AcctNo" => $_REQUEST["AcctNo"],
"ExpDate" => $_REQUEST["ExpDate"],
"Memo" => $_REQUEST["Memo"],
"Purchase" => $_REQUEST["Purchase"]
);
// STEP 2: Use helper class to process the MercuryGift Web Services transaction
include_once("Mercury_Web_Services_SOAP_Helper.php");
$soapHelper = new Mercury_Web_Services_SOAP_Helper();
if ($requestData["TranType"] == "PrePaid")
{
$responseData = $soapHelper->gift_transaction($requestData, $_REQUEST["Password"]);
}
else
{
// Add Token request keys for Credit Transactions
$requestData["Frequency"] = "OneTime";
$responseData = $soapHelper->credit_transaction($requestData, $_REQUEST["Password"]);
}
echo "<h2>Request Data</h2>";
print_r($requestData);
// STEP 3: Read parsed response to check for approval
if ($responseData["CmdStatus"] <> ""
&& $responseData["CmdStatus"] == "Approved")
{
echo "<font color=\"green\">";
echo "<h2>Approved Response Data</h2>";
print_r($responseData);
echo "</font>";
}
else
{
echo "<font color=\"red\">";
echo "<h2>Declined/Error Response Data</h2>";
print_r($responseData);
echo "</font>";
}
?>