define("AUTHORIZENET_LOG_FILE", "phplog");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$payPalType = new AnetAPI\PayPalType();
$payPalType->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payPalType->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paymentType = new AnetAPI\PaymentType();
$paymentType->setPayPal($payPalType);
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType("priorAuthCaptureTransaction");
$transactionRequest->setPayment($paymentType);
$transactionRequest->setAmount(floatval(19.45));
$transactionRequest->setRefTransId(2241687191);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequest);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null && $response->getMessages()->getResultCode() == "Ok") {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null && $tresponse->getResponseCode() == "1") {
        echo "Prior Authorization capture AUTH CODE : " . $tresponse->getAuthCode() . "\n";
    } else {
        echo "Prior Authorization capture ERROR :  Invalid response\n";
    }
} else {
    echo "PriorAuthorizationCapture ERROR :  Invalid response\n";
// Put the values of the Payer ID and Ref. Transaction ID generated in Authorization and Capture
$payerID = "6ZSCSYG33VP8Q";
$refTransId = "2241708986";
// Common setup for API credentials (with PayPal compatible merchant credentials)
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$payPalType = new AnetAPI\PayPalType();
$payPalType->setPayerID($payerID);
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setPayPal($payPalType);
// Create an authorize and capture continue transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureContinueTransaction");
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setRefTransId($refTransId);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null) {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null) {
        echo "Transaction Response...\n";
        echo "Received response code: " . $tresponse->getResponseCode() . "\n";
        //Valid response codes: 1=Approved, 2=Declined, 3=Error, 5=Need Payer Consent
        echo "Secure acceptance URL: " . $tresponse->getSecureAcceptance()->getSecureAcceptanceUrl() . "\n";
        echo "Transaction ID: " . $tresponse->getTransId() . "\n";
    } else {
        echo "NULL transactionResponse Error\n";
Ejemplo n.º 3
0
 function makeRefund2($amount, $card_last_four, $exp_date, $trans_id)
 {
     $merchantAuthentication = $this->sandbox_authorize();
     $refId = 'ref' . time();
     $date = $this->prepareExpirationDate($exp_date);
     /*
     * 
      $transaction = new AuthorizeNetTransaction;
      $transaction->amount = $amount;
      $transaction->customerProfileId = $customerProfileId;
      $transaction->customerPaymentProfileId = $paymentProfileId;
      $transaction->transId = $transid; // original transaction ID
     
      $response = $request->createCustomerProfileTransaction("Refund", $transaction);
      $transactionResponse = $response->getTransactionResponse();
     
      $transactionId = $transactionResponse->transaction_id;
     * 
     */
     // Create the payment data for a credit card
     $creditCard = new AnetAPI\CreditCardType();
     //$creditCard->setCardNumber(base64_decode($card_last_four));
     $creditCard->setCardNumber($card_last_four);
     $creditCard->setExpirationDate($date);
     $paymentOne = new AnetAPI\PaymentType();
     $paymentOne->setCreditCard($creditCard);
     //create a transaction
     $transactionRequest = new AnetAPI\TransactionRequestType();
     $transactionRequest->setTransactionType("refundTransaction");
     $transactionRequest->setAmount($amount);
     $transactionRequest->setRefTransId($trans_id);
     $transactionRequest->setPayment($paymentOne);
     $request = new AnetAPI\CreateTransactionRequest();
     $request->setMerchantAuthentication($merchantAuthentication);
     $request->setRefId($refId);
     $request->setTransactionRequest($transactionRequest);
     $controller = new AnetController\CreateTransactionController($request);
     $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
     //$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
     if ($response != null) {
         $tresponse = $response->getTransactionResponse();
         echo "Response: <pre>";
         print_r($tresponse);
         echo "</pre>";
         if ($tresponse != null && $tresponse->getResponseCode() == "1") {
             //echo "it is ok ....";
             return TRUE;
         } else {
             $this->save_log($tresponse, $post_order);
             return FALSE;
         }
     } else {
         //echo "Null resposnse .. ...";
         return FALSE;
     }
     return $response;
 }
echo "PayPal Authorize Only Continue Transaction\n";
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$paypal_type = new AnetAPI\PayPalType();
$paypal_type->setPayerID("JJLRRB29QC7RU");
$paypal_type->setSuccessUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$paypal_type->setCancelUrl("http://www.merchanteCommerceSite.com/Success/TC25262");
$payment_type = new AnetAPI\PaymentType();
$payment_type->setPayPal($paypal_type);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authOnlyContinueTransaction");
$transactionRequestType->setRefTransId("2241711631");
$transactionRequestType->setAmount(125.34);
$transactionRequestType->setPayment($payment_type);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null) {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null && $tresponse->getResponseCode() == "1") {
        //echo " RESULT CODE : " . $response->getResultCode() . "\n";
        echo " TRANS ID  : " . $tresponse->getTransId() . "\n";
        echo "Payer ID : " . $tresponse->getSecureAcceptance()->getPayerID();
    } else {
Ejemplo n.º 5
0
require 'vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
echo "PayPal Get Details Transaction\n";
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
//create a transaction of type get details
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("getDetailsTransaction");
//replace following transaction ID with your transaction ID for which the details are required
$transactionRequestType->setRefTransId("2241687090");
//create a transaction request
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
//execute the api call to get transaction details
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null) {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null) {
        if ($tresponse->getResponseCode() == "1") {
            //parse the shipping information from response
            $shipping_response = $tresponse->getShipTo();
            echo "Shipping address : " . $shipping_response->getAddress() . ", " . $shipping_response->getCity() . ", " . $shipping_response->getState() . ", " . $shipping_response->getCountry() . "\n";
Ejemplo n.º 6
0
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE", "phplog");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("5KP3u95bQpv");
$merchantAuthentication->setTransactionKey("4Ktq966gC55GAX7S");
$refId = 'ref' . time();
$payPalType = new AnetAPI\PayPalType();
$payPalType->setSuccessUrl("");
$payPalType->setCancelUrl("");
$paymentType = new AnetAPI\PaymentType();
$paymentType->setPayPal($payPalType);
$transactionRequest = new AnetAPI\TransactionRequestType();
$transactionRequest->setTransactionType("voidTransaction");
$transactionRequest->setPayment($paymentType);
$transactionRequest->setRefTransId(2241706281);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequest);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
if ($response != null) {
    $tresponse = $response->getTransactionResponse();
    if ($tresponse != null && $tresponse->getResponseCode() == "1") {
        echo "Void transaction SUCCESS TRANS ID  : " . $tresponse->getTransId() . "\n";
    } else {
        echo "Void transaction ERROR : " . $tresponse->getResponseCode() . "\n";
    }
} else {
    echo "Void transaction Null esponse returned";