Skip to content

Commit 7e75d63

Browse files
committed
Readded define("AUTHORIZENET_LOG_FILE") to allow logging of request/responses in samples. Some indentation of the function definitions.
1 parent c1fcfbd commit 7e75d63

50 files changed

Lines changed: 269 additions & 166 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ApplePayTransactions/create-an-apple-pay-transaction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use net\authorize\api\contract\v1 as AnetAPI;
55
use net\authorize\api\controller as AnetController;
66

7+
define("AUTHORIZENET_LOG_FILE", "phplog");
8+
79
function createAnApplePayTransaction(){
810
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
911
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);

CustomerProfiles/create-customer-payment-profile.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
require 'vendor/autoload.php';
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
5+
6+
define("AUTHORIZENET_LOG_FILE", "phplog");
57

68
function createCustomerPaymentProfile($existingcustomerprofileid, $phoneNumber){
79
// Common setup for API credentials

CustomerProfiles/create-customer-profile-from-transaction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
55

6+
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
68
function createCustomerProfileFromTransaction($transId= \SampleCode\Constants::TRANS_ID_TO_CREATE_CUSTOMER_PROFILE)
79
{
810
// Common setup for API credentials

CustomerProfiles/create-customer-profile.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
require 'vendor/autoload.php';
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
5-
5+
6+
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
68
function createCustomerProfile($email){
79

810
// Common setup for API credentials

CustomerProfiles/create-customer-shipping-address.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
require 'vendor/autoload.php';
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
5+
6+
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
58
function createCustomerShippingAddress($existingcustomerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID,
69
$phoneNumber= \SampleCode\Constants::PHONE_NUMBER)
710
{

CustomerProfiles/delete-customer-payment-profile.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
55

6-
function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID,
6+
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
8+
function deleteCustomerPaymentProfile($customerProfileId= \SampleCode\Constants::CUSTOMER_PROFILE_ID,
79
$customerpaymentprofileid = \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID)
810
{
911
// Common setup for API credentials

CustomerProfiles/delete-customer-profile.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
55

6+
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
68
function deleteCustomerProfile($customerProfileId)
79
{
810
// Common setup for API credentials

CustomerProfiles/delete-customer-shipping-address.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use net\authorize\api\contract\v1 as AnetAPI;
44
use net\authorize\api\controller as AnetController;
55

6+
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
68
function deleteCustomerShippingAddress($customerprofileid = \SampleCode\Constants::CUSTOMER_PROFILE_ID_2,
79
$customeraddressid = "36976434")
810
{

CustomerProfiles/get-customer-payment-profile-list.php

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
1-
21
<?php
32
require 'vendor/autoload.php';
43

54
use net\authorize\api\contract\v1 as AnetAPI;
65
use net\authorize\api\controller as AnetController;
76

7+
define("AUTHORIZENET_LOG_FILE", "phplog");
8+
89
function getCustomerPaymentProfileList()
910
{
10-
// Common setup for API credentials (merchant)
11-
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
12-
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
13-
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
14-
$refId = 'ref' . time();
15-
16-
//Setting the paging
17-
$paging = new AnetAPI\PagingType();
18-
$paging->setLimit("1000");
19-
$paging->setOffset("1");
20-
21-
//Setting the sorting
22-
$sorting = new AnetAPI\CustomerPaymentProfileSortingType();
23-
$sorting->setOrderBy("id");
24-
$sorting->setOrderDescending("false");
11+
// Common setup for API credentials (merchant)
12+
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
13+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
14+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
15+
$refId = 'ref' . time();
16+
17+
//Setting the paging
18+
$paging = new AnetAPI\PagingType();
19+
$paging->setLimit("1000");
20+
$paging->setOffset("1");
21+
22+
//Setting the sorting
23+
$sorting = new AnetAPI\CustomerPaymentProfileSortingType();
24+
$sorting->setOrderBy("id");
25+
$sorting->setOrderDescending("false");
26+
27+
//Creating the request with the required parameters
28+
$request = new AnetAPI\GetCustomerPaymentProfileListRequest();
29+
$request->setMerchantAuthentication($merchantAuthentication);
30+
$request->setRefId($refId);
31+
$request->setPaging($paging);
32+
$request->setSorting($sorting);
33+
$request->setSearchType("cardsExpiringInMonth");
34+
$request->setMonth("2020-12");
2535

26-
//Creating the request with the required parameters
27-
$request = new AnetAPI\GetCustomerPaymentProfileListRequest();
28-
$request->setMerchantAuthentication($merchantAuthentication);
29-
$request->setRefId($refId);
30-
$request->setPaging($paging);
31-
$request->setSorting($sorting);
32-
$request->setSearchType("cardsExpiringInMonth");
33-
$request->setMonth("2020-12");
34-
35-
// Controller
36-
$controller = new AnetController\GetCustomerPaymentProfileListController($request);
37-
// Getting the response
38-
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
39-
40-
if(($response != null))
41-
{
42-
if ($response->getMessages()->getResultCode() == "Ok")
36+
// Controller
37+
$controller = new AnetController\GetCustomerPaymentProfileListController($request);
38+
// Getting the response
39+
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
40+
41+
if(($response != null))
4342
{
44-
// Success
45-
echo "GetCustomerPaymentProfileList SUCCESS: " . "\n";
46-
echo "Message Code: " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
47-
echo "Message Text: " . $response->getMessages()->getMessage()[0]->getText() . "\n";
48-
echo "Total number of Results in the result set" . $response->getTotalNumInResultSet() . "\n";
49-
// Displaying the customer payment profile list
50-
foreach($response->getPaymentProfiles() as $paymentProfile )
43+
if ($response->getMessages()->getResultCode() == "Ok")
5144
{
52-
echo "\nCustomer Profile id: " . $paymentProfile->getCustomerProfileId() . "\n";
53-
echo "Payment profile id: " . $paymentProfile->getCustomerPaymentProfileId() . "\n";
54-
echo "Credit Card Number: " . $paymentProfile->getPayment()->getCreditCard()->getCardNumber() . "\n";
55-
if($paymentProfile->getBillTo() != null)
56-
echo "First Name in Billing Address: " . $paymentProfile->getBillTo()->getFirstName() . "\n";
45+
// Success
46+
echo "GetCustomerPaymentProfileList SUCCESS: " . "\n";
47+
echo "Message Code: " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
48+
echo "Message Text: " . $response->getMessages()->getMessage()[0]->getText() . "\n";
49+
echo "Total number of Results in the result set" . $response->getTotalNumInResultSet() . "\n";
50+
// Displaying the customer payment profile list
51+
foreach($response->getPaymentProfiles() as $paymentProfile )
52+
{
53+
echo "\nCustomer Profile id: " . $paymentProfile->getCustomerProfileId() . "\n";
54+
echo "Payment profile id: " . $paymentProfile->getCustomerPaymentProfileId() . "\n";
55+
echo "Credit Card Number: " . $paymentProfile->getPayment()->getCreditCard()->getCardNumber() . "\n";
56+
if($paymentProfile->getBillTo() != null)
57+
echo "First Name in Billing Address: " . $paymentProfile->getBillTo()->getFirstName() . "\n";
58+
}
59+
}
60+
else
61+
{
62+
// Error
63+
echo "GetCustomerPaymentProfileList ERROR : Invalid response\n";
64+
echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n";
5765
}
5866
}
5967
else
6068
{
61-
// Error
62-
echo "GetCustomerPaymentProfileList ERROR : Invalid response\n";
63-
echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n";
69+
// Failed to get the response
70+
echo "NULL Response Error";
6471
}
65-
}
66-
else
67-
{
68-
// Failed to get the response
69-
echo "NULL Response Error";
70-
}
71-
return $response;
72+
return $response;
7273
}
7374
if(!defined('DONT_RUN_SAMPLES'))
7475
getCustomerPaymentProfileList();

CustomerProfiles/get-customer-payment-profile.php

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
21
<?php
32

43
require 'vendor/autoload.php';
54

65
use net\authorize\api\contract\v1 as AnetAPI;
76
use net\authorize\api\controller as AnetController;
87

8+
define("AUTHORIZENET_LOG_FILE", "phplog");
9+
910
function getCustomerPaymentProfile($customerProfileId=\SampleCode\Constants::CUSTOMER_PROFILE_ID_2,
1011
$customerPaymentProfileId= \SampleCode\Constants::CUSTOMER_PAYMENT_PROFILE_ID_GET)
1112
{
12-
// Common setup for API credentials (merchant)
13-
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
14-
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
15-
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
16-
$refId = 'ref' . time();
13+
// Common setup for API credentials (merchant)
14+
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
15+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
16+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
17+
$refId = 'ref' . time();
1718

18-
//request requires customerProfileId and customerPaymentProfileId
19-
$request = new AnetAPI\GetCustomerPaymentProfileRequest();
20-
$request->setMerchantAuthentication($merchantAuthentication);
21-
$request->setRefId( $refId);
22-
$request->setCustomerProfileId($customerProfileId);
23-
$request->setCustomerPaymentProfileId($customerPaymentProfileId);
19+
//request requires customerProfileId and customerPaymentProfileId
20+
$request = new AnetAPI\GetCustomerPaymentProfileRequest();
21+
$request->setMerchantAuthentication($merchantAuthentication);
22+
$request->setRefId( $refId);
23+
$request->setCustomerProfileId($customerProfileId);
24+
$request->setCustomerPaymentProfileId($customerPaymentProfileId);
2425

25-
$controller = new AnetController\GetCustomerPaymentProfileController($request);
26-
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
27-
if(($response != null)){
28-
if ($response->getMessages()->getResultCode() == "Ok")
29-
{
30-
echo "GetCustomerPaymentProfile SUCCESS: " . "\n";
31-
echo "Customer Payment Profile Id: " . $response->getPaymentProfile()->getCustomerPaymentProfileId() . "\n";
32-
echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress(). "\n";
33-
echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber(). "\n";
26+
$controller = new AnetController\GetCustomerPaymentProfileController($request);
27+
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
28+
if(($response != null)){
29+
if ($response->getMessages()->getResultCode() == "Ok")
30+
{
31+
echo "GetCustomerPaymentProfile SUCCESS: " . "\n";
32+
echo "Customer Payment Profile Id: " . $response->getPaymentProfile()->getCustomerPaymentProfileId() . "\n";
33+
echo "Customer Payment Profile Billing Address: " . $response->getPaymentProfile()->getbillTo()->getAddress(). "\n";
34+
echo "Customer Payment Profile Card Last 4 " . $response->getPaymentProfile()->getPayment()->getCreditCard()->getCardNumber(). "\n";
3435

35-
}
36-
else
37-
{
38-
echo "GetCustomerPaymentProfile ERROR : Invalid response\n";
39-
echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n";
40-
}
41-
}
42-
else{
43-
echo "NULL Response Error";
44-
}
45-
return $response;
36+
}
37+
else
38+
{
39+
echo "GetCustomerPaymentProfile ERROR : Invalid response\n";
40+
echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n";
41+
}
42+
}
43+
else{
44+
echo "NULL Response Error";
45+
}
46+
return $response;
4647
}
4748
if(!defined('DONT_RUN_SAMPLES'))
4849
getCustomerPaymentProfile();

0 commit comments

Comments
 (0)