forked from MercuryPay/WebServices.PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CloseBatch.php
79 lines (69 loc) · 2.61 KB
/
CloseBatch.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
// STEP 1: Build Batch Summary request array
$batchSummaryRequest = array
(
"MerchantID" => $_REQUEST["MerchantID"],
"TranCode" => "BatchSummary",
"Memo" => "Testing WebServices PHP"
);
// STEP 2: Use helper class to process the Web Services transaction
include_once("Mercury_Web_Services_SOAP_Helper.php");
$soapHelper = new Mercury_Web_Services_SOAP_Helper();
$batchSummaryResponse = $soapHelper->credit_transaction($batchSummaryRequest, $_REQUEST["Password"]);
echo "<h2>Batch Summary Request Data</h2>";
print_r($batchSummaryRequest);
// STEP 3: Read parsed response to check for Ssuccess
if ($batchSummaryResponse["CmdStatus"] <> ""
&& $batchSummaryResponse["CmdStatus"] == "Success")
{
echo "<font color=\"green\">";
echo "<h2>Batch Summary Response Data</h2>";
print_r($batchSummaryResponse);
echo "</font>";
// STEP 1.b: On successful Batch Summary use the results to build a Batch Close
$batchCloseRequest = array
(
"MerchantID" => $_REQUEST["MerchantID"],
"TranCode" => "BatchClose",
"Memo" => "Testing WebServices PHP",
"BatchNo" => $batchSummaryResponse["BatchNo"],
"BatchItemCount" => $batchSummaryResponse["BatchItemCount"],
"NetBatchTotal" => $batchSummaryResponse["NetBatchTotal"],
"CreditPurchaseCount" => $batchSummaryResponse["CreditPurchaseCount"],
"CreditPurchaseAmount" => $batchSummaryResponse["CreditPurchaseAmount"],
"CreditReturnCount" => $batchSummaryResponse["CreditReturnCount"],
"CreditReturnAmount" => $batchSummaryResponse["CreditReturnAmount"],
"DebitPurchaseCount" => $batchSummaryResponse["DebitPurchaseCount"],
"DebitPurchaseAmount" => $batchSummaryResponse["DebitPurchaseAmount"],
"DebitReturnCount" => $batchSummaryResponse["DebitReturnCount"],
"DebitReturnAmount" => $batchSummaryResponse["DebitReturnAmount"]
);
// STEP 2.b: Use helper class to process the Web Services transaction
$batchCloseResponse = $soapHelper->credit_transaction($batchCloseRequest, $_REQUEST["Password"]);
echo "<h2>Batch Close Request Data</h2>";
print_r($batchCloseRequest);
// STEP 3.b: Read parsed response to check for Success
if ($batchCloseResponse["CmdStatus"] <> ""
&& $batchCloseResponse["CmdStatus"] == "Success")
{
echo "<font color=\"green\">";
echo "<h2>Batch Close Response Data</h2>";
print_r($batchCloseResponse);
echo "</font>";
}
else
{
echo "<font color=\"red\">";
echo "<h2>Declined/Error Batch Close sResponse Data</h2>";
print_r($batchCloseResponse);
echo "</font>";
}
}
else
{
echo "<font color=\"red\">";
echo "<h2>Declined/Error Batch Summary sResponse Data</h2>";
print_r($batchSummaryResponse);
echo "</font>";
}
?>