Skip to content

Commit f513ad2

Browse files
committed
Match the names as used in the API Reference
1 parent abf9466 commit f513ad2

File tree

4 files changed

+518
-506
lines changed

4 files changed

+518
-506
lines changed
Lines changed: 53 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2-
require 'vendor/autoload.php';
3-
use net\authorize\api\contract\v1 as AnetAPI;
4-
use net\authorize\api\controller as AnetController;
2+
require 'vendor/autoload.php';
3+
use net\authorize\api\contract\v1 as AnetAPI;
4+
use net\authorize\api\controller as AnetController;
55

66
define("AUTHORIZENET_LOG_FILE", "phplog");
77

@@ -20,71 +20,58 @@ function payPalAuthorizeCaptureContinued($refTransId, $payerID)
2020
$payPalType=new AnetAPI\PayPalType();
2121
$payPalType->setPayerID($payerID);
2222

23-
$paymentOne = new AnetAPI\PaymentType();
24-
$paymentOne->setPayPal($payPalType);
23+
$paymentOne = new AnetAPI\PaymentType();
24+
$paymentOne->setPayPal($payPalType);
2525

26-
// Create an authorize and capture continue transaction
27-
$transactionRequestType = new AnetAPI\TransactionRequestType();
28-
$transactionRequestType->setTransactionType( "authCaptureContinueTransaction");
29-
$transactionRequestType->setPayment($paymentOne);
30-
$transactionRequestType->setRefTransId($refTransId);
26+
// Create an authorize and capture continued transaction
27+
$transactionRequestType = new AnetAPI\TransactionRequestType();
28+
$transactionRequestType->setTransactionType("authCaptureContinueTransaction");
29+
$transactionRequestType->setPayment($paymentOne);
30+
$transactionRequestType->setRefTransId($refTransId);
3131

32-
$request = new AnetAPI\CreateTransactionRequest();
33-
$request->setMerchantAuthentication($merchantAuthentication);
34-
$request->setTransactionRequest( $transactionRequestType);
35-
$controller = new AnetController\CreateTransactionController($request);
36-
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
32+
$request = new AnetAPI\CreateTransactionRequest();
33+
$request->setMerchantAuthentication($merchantAuthentication);
34+
$request->setTransactionRequest($transactionRequestType);
35+
$controller = new AnetController\CreateTransactionController($request);
36+
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
3737

38-
if ($response != null)
39-
{
40-
if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK)
41-
{
42-
$tresponse = $response->getTransactionResponse();
43-
44-
if ($tresponse != null && $tresponse->getMessages() != null)
45-
{
46-
echo "Transaction Response...\n";
47-
echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
48-
//Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
49-
echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n";
50-
echo "Transaction ID: ".$tresponse->getTransId()."\n";
51-
echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n";
52-
echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
53-
}
54-
else
55-
{
56-
echo "Transaction Failed \n";
57-
if($tresponse->getErrors() != null)
58-
{
59-
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
60-
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
61-
}
62-
}
63-
}
64-
else
65-
{
66-
echo "Transaction Failed \n";
67-
$tresponse = $response->getTransactionResponse();
68-
if($tresponse != null && $tresponse->getErrors() != null)
69-
{
70-
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
71-
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
72-
}
73-
else
74-
{
75-
echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
76-
echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
77-
}
78-
}
79-
}
80-
else
81-
{
82-
echo "No response returned \n";
83-
}
38+
if ($response != null) {
39+
if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) {
40+
$tresponse = $response->getTransactionResponse();
41+
42+
if ($tresponse != null && $tresponse->getMessages() != null) {
43+
echo "Transaction Response...\n";
44+
echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
45+
//Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
46+
echo "Secure acceptance URL: ".$tresponse->getSecureAcceptance()->getSecureAcceptanceUrl()."\n";
47+
echo "Transaction ID: ".$tresponse->getTransId()."\n";
48+
echo " Code : " . $tresponse->getMessages()[0]->getCode() . "\n";
49+
echo " Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
50+
} else {
51+
echo "Transaction Failed \n";
52+
if ($tresponse->getErrors() != null) {
53+
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
54+
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
55+
}
56+
}
57+
} else {
58+
echo "Transaction Failed \n";
59+
$tresponse = $response->getTransactionResponse();
60+
if ($tresponse != null && $tresponse->getErrors() != null) {
61+
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
62+
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
63+
} else {
64+
echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
65+
echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
66+
}
67+
}
68+
} else {
69+
echo "No response returned \n";
70+
}
8471

85-
return $response;
86-
}
72+
return $response;
73+
}
8774

88-
if(!defined('DONT_RUN_SAMPLES'))
89-
payPalAuthorizeCaptureContinued("2241708986","6ZSCSYG33VP8Q");
90-
?>
75+
if (!defined('DONT_RUN_SAMPLES')) {
76+
payPalAuthorizeCaptureContinued("2241708986", "6ZSCSYG33VP8Q");
77+
}
Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
2-
require 'vendor/autoload.php';
2+
require 'vendor/autoload.php';
33

4-
use net\authorize\api\contract\v1 as AnetAPI;
5-
use net\authorize\api\controller as AnetController;
4+
use net\authorize\api\contract\v1 as AnetAPI;
5+
use net\authorize\api\controller as AnetController;
66

7-
define("AUTHORIZENET_LOG_FILE", "phplog");
7+
define("AUTHORIZENET_LOG_FILE", "phplog");
88

9-
function payPalAuthorizeOnlyContinue($transactionId, $payerId)
9+
function payPalAuthorizeOnlyContinued($transactionId, $payerId)
1010
{
1111

12-
echo "PayPal Authorize Only Continue Transaction\n";
12+
echo "PayPal Authorize Only Continued Transaction\n";
1313

1414
/* Create a merchantAuthenticationType object with authentication details
1515
retrieved from the constants file */
@@ -24,76 +24,62 @@ function payPalAuthorizeOnlyContinue($transactionId, $payerId)
2424
$payPalType=new AnetAPI\PayPalType();
2525
$payPalType->setPayerID($payerID);
2626

27-
$paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
27+
$paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
2828
$paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
2929

3030
$payment_type = new AnetAPI\PaymentType();
3131
$payment_type->setPayPal($paypal_type);
3232

3333
//create a transaction
3434
$transactionRequestType = new AnetAPI\TransactionRequestType();
35-
$transactionRequestType->setTransactionType( "authOnlyContinueTransaction");
35+
$transactionRequestType->setTransactionType("authOnlyContinueTransaction");
3636
$transactionRequestType->setRefTransId($transactionId);
3737
$transactionRequestType->setAmount(125.34);
3838
$transactionRequestType->setPayment($payment_type);
3939

4040
$request = new AnetAPI\CreateTransactionRequest();
4141
$request->setMerchantAuthentication($merchantAuthentication);
42-
$request->setRefId( $refId);
43-
$request->setTransactionRequest( $transactionRequestType);
42+
$request->setRefId($refId);
43+
$request->setTransactionRequest($transactionRequestType);
4444

4545
$controller = new AnetController\CreateTransactionController($request);
4646

47-
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
47+
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
4848

49-
if ($response != null)
50-
{
51-
if($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK)
52-
{
53-
$tresponse = $response->getTransactionResponse();
49+
if ($response != null) {
50+
if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_OK) {
51+
$tresponse = $response->getTransactionResponse();
5452

55-
if ($tresponse != null && $tresponse->getMessages() != null)
56-
{
57-
echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
58-
echo "TRANS ID : " . $tresponse->getTransId() . "\n";
59-
echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID();
60-
echo "Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
53+
if ($tresponse != null && $tresponse->getMessages() != null) {
54+
echo " Transaction Response code : " . $tresponse->getResponseCode() . "\n";
55+
echo "TRANS ID : " . $tresponse->getTransId() . "\n";
56+
echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID();
57+
echo "Description : " . $tresponse->getMessages()[0]->getDescription() . "\n";
58+
} else {
59+
echo "Transaction Failed \n";
60+
if ($tresponse->getErrors() != null) {
61+
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
62+
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
63+
}
64+
}
65+
} else {
66+
echo "Transaction Failed \n";
67+
$tresponse = $response->getTransactionResponse();
68+
if ($tresponse != null && $tresponse->getErrors() != null) {
69+
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
70+
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
71+
} else {
72+
echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
73+
echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
74+
}
6175
}
62-
else
63-
{
64-
echo "Transaction Failed \n";
65-
if($tresponse->getErrors() != null)
66-
{
67-
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
68-
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
69-
}
70-
}
71-
}
72-
else
73-
{
74-
echo "Transaction Failed \n";
75-
$tresponse = $response->getTransactionResponse();
76-
if($tresponse != null && $tresponse->getErrors() != null)
77-
{
78-
echo " Error code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n";
79-
echo " Error message : " . $tresponse->getErrors()[0]->getErrorText() . "\n";
80-
}
81-
else
82-
{
83-
echo " Error code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n";
84-
echo " Error message : " . $response->getMessages()->getMessage()[0]->getText() . "\n";
85-
}
86-
}
87-
}
88-
else
89-
{
90-
echo "No response returned \n";
76+
} else {
77+
echo "No response returned \n";
9178
}
9279

9380
return $response;
94-
}
81+
}
9582

96-
if(!defined('DONT_RUN_SAMPLES'))
97-
payPalAuthorizeOnlyContinue("2241711631", "JJLRRB29QC7RU");
98-
99-
?>
83+
if (!defined('DONT_RUN_SAMPLES')) {
84+
payPalAuthorizeOnlyContinued("2241711631", "JJLRRB29QC7RU");
85+
}

SampleCodeList.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ CreditBankAccount,1,0
4040
ChargeCustomerProfile,1,1
4141
PayPalVoid,1,0
4242
PayPalAuthorizeCapture,1,1
43-
PayPalAuthorizeCaptureContinue,1,1
44-
PayPalAuthorizeOnlyContinue,1,0
43+
PayPalAuthorizeCaptureContinued,1,1
44+
PayPalAuthorizeOnlyContinued,1,0
4545
PayPalCredit,1,0
4646
PayPalGetDetails,1,1
4747
PayPalPriorAuthorizationCapture,1,0

0 commit comments

Comments
 (0)