-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathget-account-updater-job-details.php
More file actions
114 lines (107 loc) · 5.41 KB
/
get-account-updater-job-details.php
File metadata and controls
114 lines (107 loc) · 5.41 KB
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
109
110
111
112
113
114
<?php
require 'vendor/autoload.php';
require_once 'constants/SampleCodeConstants.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
function getAccountUpdaterJobDetails()
{
/* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
$merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
// Set the request's refId
$refId = '123456';
// Set a valid month (and other parameters) for the request
$month = "2018-08";
$modifedTypeFilter = "all";
$paging = new AnetAPI\PagingType;
$paging->setLimit("1000");
$paging->setOffset("2");
// Build tbe request object
$request = new AnetAPI\GetAUJobDetailsRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setMonth($month);
$request->setModifiedTypeFilter($modifedTypeFilter);
$request->setPaging($paging);
$controller = new AnetController\GetAUJobDetailsController($request);
// Retrieving details for the given month and parameters
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) {
echo "SUCCESS: Get Account Updater Details for Month : " . $month . "\n\n";
if ($response->getAuDetails() == null) {
echo "No Account Updater Details for this month"."\n";
} else {
$details = new AnetAPI\ListOfAUDetailsType;
$details = $response->getAuDetails();
if (($details->getAuUpdate() == null) && ($details->getAuDelete() == null)) {
echo "No Account Updater Details for this month"."\n";
}
}
// Displaying the details of each response in the list
echo "Total Num in Result Set : " . $response->getTotalNumInResultSet() . "\n\n";
$details = new AnetAPI\ListOfAUDetailsType;
$details = $response->getAuDetails();
echo "Updates:"."\n";
foreach ($details->getAuUpdate() as $update)
{
echo "Profile ID : " . $update->getCustomerProfileID() . "\n";
echo "Payment Profile ID : " . $update->getCustomerPaymentProfileID() . "\n";
echo "Update Time (UTC) : " . $update->getUpdateTimeUTC() . "\n";
echo "Reason Code : " . $update->getAuReasonCode() . "\n";
echo "Reason Description : " . $update->getReasonDescription() . "\n";
if ($update->getNewCreditCard()->getCardNumber() != null)
{
echo "Fetching New Card Details"."\n";
// Fetching New Card Details
echo "Card Number: ". $update->getNewCreditCard()->getCardNumber()."\n";
echo "New Expiration Date: ". $update->getNewCreditCard()->getExpirationDate()."\n";
echo "New Card Type: ". $update->getNewCreditCard()->getCardType()."\n";
}
if ($update->getOldCreditCard()->getCardNumber() != null)
{
echo "Fetching Old Card Details"."\n";
// Fetching Old Card Details
echo "Old Card Number: ". $update->getOldCreditCard()->getCardNumber()."\n";
echo "Old Expiration Date: ".$update->getOldCreditCard()->getExpirationDate()."\n";
echo "Old Card Type: ". $update->getOldCreditCard()->getCardType()."\n";
}
if(!empty($update->getSubscriptionIdList()))
{
echo "Subscription Id : ".implode("",$update->getSubscriptionIdList()). "\n";
}
}
echo "**** AU Update End ****"."\n";
echo "*** AU Deletes:****"."\n";
foreach ($details->getAuDelete() as $delete)
{
echo "Profile ID : " . $delete->getCustomerProfileID() . "\n";
echo "Payment Profile ID : " . $delete->getCustomerPaymentProfileID() . "\n";
echo "Update Time (UTC) : " . $delete->getUpdateTimeUTC() . "\n";
echo "Reason Code : " . $delete->getAuReasonCode() . "\n";
echo "Reason Description : " . $delete->getReasonDescription() . "\n";
if($delete->getCreditCard()->getCardNumber() != null)
{
echo "Fetching Card Details"."\n";
// Fetching New Card Details
echo "Card Number: ". $delete->getCreditCard()->getCardNumber()."\n";
echo "Expiration Date: ". $delete->getCreditCard()->getExpirationDate()."\n";
echo "Card Type: ". $delete->getCreditCard()->getCardType()."\n";
}
if(!empty($delete->getSubscriptionIdList()))
{
echo "Subscription Id :".implode("",$delete->getSubscriptionIdList())."\n";
}
}
}
else
{
echo "ERROR : Invalid response"."\n";
$errorMessages = $response->getMessages()->getMessage();
echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
}
return $response;
}
if (!defined('DONT_RUN_SAMPLES')) {
getAccountUpdaterJobDetails();
}