Skip to content

Commit 44f06e6

Browse files
committed
Added composer autoload attribute to use SampleCode namespace
Added constants instead of value assignments in PaymentTransactions/ samples. capture-previously-authorized-amount failing
1 parent 67e0dd0 commit 44f06e6

12 files changed

+71
-42
lines changed

PaymentTransactions/authorize-credit-card.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
function authorizeCreditCard($amount){
88
// Common setup for API credentials
99
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
10-
$merchantAuthentication->setName("5KP3u95bQpv");
11-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
10+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
11+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1212
$refId = 'ref' . time();
1313

1414
// Create the payment data for a credit card
1515
$creditCard = new AnetAPI\CreditCardType();
16-
$creditCard->setCardNumber( "4111111111111111" );
17-
$creditCard->setExpirationDate( "2038-12");
16+
$creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER );
17+
$creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE);
1818
$paymentOne = new AnetAPI\PaymentType();
1919
$paymentOne->setCreditCard($creditCard);
2020

PaymentTransactions/capture-funds-authorized-through-another-channel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
function captureFundsAuthorizedThroughAnotherChannel($amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
$creditCard = new AnetAPI\CreditCardType();
14-
$creditCard->setCardNumber( "4111111111111111");
15-
$creditCard->setExpirationDate( "2038-12");
14+
$creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER);
15+
$creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE);
1616

1717
$paymentOne = new AnetAPI\PaymentType();
1818
$paymentOne->setCreditCard($creditCard);

PaymentTransactions/capture-previously-authorized-amount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
function capturePreviouslyAuthorizedAmount($transactionid){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
// Now capture the previously authorized amount

PaymentTransactions/charge-credit-card.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
function chargeCreditCard($amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
// Create the payment data for a credit card
1414
$creditCard = new AnetAPI\CreditCardType();
15-
$creditCard->setCardNumber( "4111111111111111" );
16-
$creditCard->setExpirationDate( "2038-12");
15+
$creditCard->setCardNumber(\SampleCode\Constants::CREDIT_CARD_NUMBER);
16+
$creditCard->setExpirationDate(\SampleCode\Constants::EXPIRY_DATE);
1717
$paymentOne = new AnetAPI\PaymentType();
1818
$paymentOne->setCreditCard($creditCard);
1919

PaymentTransactions/charge-customer-profile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
function chargeCustomerProfile($profileid, $paymentprofileid, $amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
$profileToCharge = new AnetAPI\CustomerProfilePaymentType();

PaymentTransactions/charge-tokenized-credit-card.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
function chargeTokenizedCreditCard($amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
// Create the payment data for a credit card
1414
$creditCard = new AnetAPI\CreditCardType();
15-
$creditCard->setCardNumber( "4111111111111111" );
16-
$creditCard->setExpirationDate( "2038-12");
15+
$creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER );
16+
$creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE);
1717
//Set the cryptogram
1818
$creditCard->setCryptogram("EjRWeJASNFZ4kBI0VniQEjRWeJA=");
1919

PaymentTransactions/credit-bank-account.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
function creditBankAccount($amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212
// Create the payment data for a Bank Account
1313
$bankAccount = new AnetAPI\BankAccountType();
14-
$bankAccount->setRoutingNumber('125000024');
15-
$bankAccount->setAccountNumber('12345678');
16-
$bankAccount->setNameOnAccount('John Doe');
14+
$bankAccount->setRoutingNumber(\SampleCode\Constants::ROUTING_NUMBER);
15+
$bankAccount->setAccountNumber(\SampleCode\Constants::ACCOUNT_NUMBER);
16+
$bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT);
1717

1818
$paymentBank= new AnetAPI\PaymentType();
1919
$paymentBank->setBankAccount($bankAccount);
2020

2121
// Order info
2222
$order = new AnetAPI\OrderType();
23-
$order->setInvoiceNumber("101");
24-
$order->setDescription("Golf Shirts");
23+
$order->setInvoiceNumber(\SampleCode\Constants::INVOICE_NUMBER);
24+
$order->setDescription(\SampleCode\Constants::ORDER_DESCRIPTION);
2525

2626
//create a debit card Bank transaction
2727

PaymentTransactions/debit-bank-account.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
function debitBankAccount($amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
// Create the payment data for a Bank Account
1414
$bankAccount = new AnetAPI\BankAccountType();
1515
//$bankAccount->setAccountType('CHECKING');
1616
$bankAccount->setEcheckType('WEB');
17-
$bankAccount->setRoutingNumber('121042882');
18-
$bankAccount->setAccountNumber('123456789123');
19-
$bankAccount->setNameOnAccount('Jane Doe');
20-
$bankAccount->setBankName('Bank of the Earth');
17+
$bankAccount->setRoutingNumber(\SampleCode\Constants::DEBIT_ROUTING_NUMBER);
18+
$bankAccount->setAccountNumber(\SampleCode\Constants::DEBIT_ACCOUNT_NUMBER);
19+
$bankAccount->setNameOnAccount(\SampleCode\Constants::NAME_ON_ACCOUNT);
20+
$bankAccount->setBankName(\SampleCode\Constants::BANK_NAME);
2121

2222
$paymentBank= new AnetAPI\PaymentType();
2323
$paymentBank->setBankAccount($bankAccount);

PaymentTransactions/refund-transaction.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
function refundTransaction($amount){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
// Create the payment data for a credit card
1414
$creditCard = new AnetAPI\CreditCardType();
15-
$creditCard->setCardNumber( "4111111111111111" );
16-
$creditCard->setExpirationDate( "2038-12");
15+
$creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER );
16+
$creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE);
1717
$paymentOne = new AnetAPI\PaymentType();
1818
$paymentOne->setCreditCard($creditCard);
1919
//create a transaction

PaymentTransactions/void-transaction.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
function voidTransaction($transactionid){
77
// Common setup for API credentials
88
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
9-
$merchantAuthentication->setName("5KP3u95bQpv");
10-
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
9+
$merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID);
10+
$merchantAuthentication->setTransactionKey(\SampleCode\Constants::MERCHANT_TRANSACTION_KEY);
1111
$refId = 'ref' . time();
1212

1313
// Create the payment data for a credit card
1414
$creditCard = new AnetAPI\CreditCardType();
15-
$creditCard->setCardNumber( "4111111111111111" );
16-
$creditCard->setExpirationDate( "2038-12");
15+
$creditCard->setCardNumber( \SampleCode\Constants::CREDIT_CARD_NUMBER );
16+
$creditCard->setExpirationDate( \SampleCode\Constants::EXPIRY_DATE);
1717
$paymentOne = new AnetAPI\PaymentType();
1818
$paymentOne->setCreditCard($creditCard);
1919
//create a transaction

0 commit comments

Comments
 (0)