|
| 1 | +<?php |
| 2 | + require 'vendor/autoload.php'; |
| 3 | + use net\authorize\api\contract\v1 as AnetAPI; |
| 4 | + use net\authorize\api\controller as AnetController; |
| 5 | + define("AUTHORIZENET_LOG_FILE", "phplog"); |
| 6 | + // Common setup for API credentials |
| 7 | + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); |
| 8 | + $merchantAuthentication->setName("5KP3u95bQpv"); |
| 9 | + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); |
| 10 | + |
| 11 | + // An existing customer profile id and shipping address id for this merchant name and transaction key |
| 12 | + $customerProfileId = "36731856"; |
| 13 | + $customerAddressId = "35850995"; |
| 14 | + |
| 15 | + $request = new AnetAPI\GetCustomerShippingAddressRequest(); |
| 16 | + $request->setMerchantAuthentication($merchantAuthentication); |
| 17 | + $request->setCustomerProfileId($customerProfileId); |
| 18 | + $request->setCustomerAddressId($customerAddressId); |
| 19 | + |
| 20 | + $controller = new AnetController\GetCustomerShippingAddressController($request); |
| 21 | + |
| 22 | + //Retrieving existing customer shipping address |
| 23 | + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); |
| 24 | + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) |
| 25 | + { |
| 26 | + echo "Get Customer Shipping Address SUCCESS" . "\n"; |
| 27 | + echo " FirstName : " . $response->getAddress()->getFirstName() . "\n"; |
| 28 | + echo " LastName : " . $response->getAddress()->getLastName() . "\n"; |
| 29 | + echo " Company : " . $response->getAddress()->getCompany() . "\n"; |
| 30 | + echo " Address : " . $response->getAddress()->getAddress() . "\n"; |
| 31 | + echo " City : " . $response->getAddress()->getCity() . "\n"; |
| 32 | + echo " State : " . $response->getAddress()->getState() . "\n"; |
| 33 | + echo " Zip : " . $response->getAddress()->getZip() . "\n"; |
| 34 | + echo " Country : " . $response->getAddress()->getCountry() . "\n"; |
| 35 | + echo " Phone Number : " . $response->getAddress()->getPhoneNumber() . "\n"; |
| 36 | + echo " FAX Number : " . $response->getAddress()->getFaxNumber() . "\n"; |
| 37 | + echo "Customer AddressId : " . $response->getAddress()->getCustomerAddressId() . "\n"; |
| 38 | + } |
| 39 | + else |
| 40 | + { |
| 41 | + echo "Get Customer Shipping Address ERROR : Invalid response\n"; |
| 42 | + echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; |
| 43 | + } |
| 44 | +?> |
0 commit comments