forked from AuthorizeNet/sample-code-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-details.php
More file actions
66 lines (52 loc) · 2.04 KB
/
get-details.php
File metadata and controls
66 lines (52 loc) · 2.04 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
<?php
require 'vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
echo "PayPal Get Details Transaction\n";
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
//create a transaction of type get details
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "getDetailsTransaction");
//replace following transaction ID with your transaction ID for which the details are required
$transactionRequestType->setRefTransId("2241687090");
//create a transaction request
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId( $refId);
$request->setTransactionRequest( $transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
//execute the api call to get transaction details
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null)
{
$tresponse = $response->getTransactionResponse();
if($tresponse != null)
{
if ($tresponse->getResponseCode()=="1")
{
//parse the shipping information from response
$shipping_response = $tresponse->getShipTo();
echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity()
. ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n";
echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID();
}
else
{
echo "ERROR : " . $tresponse->getResponseCode() . "\n";
}
}
else
{
echo "No response returned";
}
}
else
{
echo "No response returned";
}
?>