|
| 1 | +<?php |
| 2 | + require 'vendor/autoload.php'; |
| 3 | + |
| 4 | + use net\authorize\api\contract\v1 as AnetAPI; |
| 5 | + use net\authorize\api\controller as AnetController; |
| 6 | + |
| 7 | + define("AUTHORIZENET_LOG_FILE", "phplog"); |
| 8 | + |
| 9 | + echo "PayPal Authorize Only Continue Transaction\n"; |
| 10 | + |
| 11 | + // Common setup for API credentials |
| 12 | + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); |
| 13 | + $merchantAuthentication->setName("5KP3u95bQpv"); |
| 14 | + $merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S"); |
| 15 | + $refId = 'ref' . time(); |
| 16 | + |
| 17 | + $paypal_type = new AnetAPI\PayPalType(); |
| 18 | + $paypal_type->setPayerID("JJLRRB29QC7RU"); |
| 19 | + $paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); |
| 20 | + $paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262"); |
| 21 | + |
| 22 | + $payment_type = new AnetAPI\PaymentType(); |
| 23 | + $payment_type->setPayPal($paypal_type); |
| 24 | + |
| 25 | + //create a transaction |
| 26 | + $transactionRequestType = new AnetAPI\TransactionRequestType(); |
| 27 | + $transactionRequestType->setTransactionType( "authOnlyContinueTransaction"); |
| 28 | + $transactionRequestType->setRefTransId("2241711631"); |
| 29 | + $transactionRequestType->setAmount(125.34); |
| 30 | + $transactionRequestType->setPayment($payment_type); |
| 31 | + |
| 32 | + $request = new AnetAPI\CreateTransactionRequest(); |
| 33 | + $request->setMerchantAuthentication($merchantAuthentication); |
| 34 | + $request->setRefId( $refId); |
| 35 | + $request->setTransactionRequest( $transactionRequestType); |
| 36 | + |
| 37 | + $controller = new AnetController\CreateTransactionController($request); |
| 38 | + |
| 39 | + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); |
| 40 | + |
| 41 | + if ($response != null) |
| 42 | + { |
| 43 | + $tresponse = $response->getTransactionResponse(); |
| 44 | + |
| 45 | + if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) |
| 46 | + { |
| 47 | + //echo " RESULT CODE : " . $response->getResultCode() . "\n"; |
| 48 | + echo " TRANS ID : " . $tresponse->getTransId() . "\n"; |
| 49 | + echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID(); |
| 50 | + } |
| 51 | + else |
| 52 | + { |
| 53 | + //print_r($tresponse); |
| 54 | + echo "ERROR : " . $tresponse->getResponseCode() . "\n"; |
| 55 | + } |
| 56 | + |
| 57 | + } |
| 58 | + else |
| 59 | + { |
| 60 | + echo "No response returned"; |
| 61 | + } |
| 62 | + |
| 63 | +?> |
0 commit comments