What steps are required to be fulfilled when going from SANDBOX to PRODUCTION using the sdk-php-master folder?
STEPS COMPLETED
1. Keys have been generated for PRODUCTION
2. Sandbox and Merchant accounts have been switched from Test to LIVE
3. The charge_credit_card.php file has been modifed from
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
to
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
Solved! Go to Solution.
01-27-2019 09:44 AM
01-27-2019 01:34 PM
01-27-2019 10:23 AM
01-27-2019 10:27 AM
Credentials
I changed the $response from SANDBOX to PRODUCTION expecting everything to work. Is there some other setting in another sdk-php-master file to change from SANDBOX to PRODUCTION?
01-27-2019 11:22 AM
Currently the live keys are assigned and the sanbox keys are commented out
<?php class CodeConstants { //merchant credentials const MERCHANT_LOGIN_ID = "xxxxxx"; const MERCHANT_TRANSACTION_KEY = "xxxxxx"; const MERCHANT_SIGNATURE_KEY = "xxxxxxx"; //Sandbox // const MERCHANT_LOGIN_ID = "yyyyyyy"; // const MERCHANT_TRANSACTION_KEY = "yyyyyy"; // const MERCHANT_SIGNATURE_KEY = "Simon"; } ?>
01-27-2019 11:29 AM
01-27-2019 01:03 PM
<?php session_start(); require 'vendor/autoload.php'; require_once 'CodeConstants.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); function chargeCreditCard($amount) { //split $amount into local variables // $amount is an array of variables passed in $_REQUEST packed into an array for passign to functions // The 'array key name' is the name='' value in the form that is passed. Example: <input type=hidden value='invtotal'> // You CAN use the $amount['name'] fields directly, but this way you can also do any validation before // you pass them to the API. $CCNum=preg_replace('/\D/', '', $_REQUEST['creditcardnum']); $CCExp=preg_replace('/\D/', '', $_REQUEST['ccexpire']); $CCcvv=preg_replace('/\D/', '', $_REQUEST['cvv']); $INVamount=$_REQUEST['invtotal']; //invoice total $INVNum=$_REQUEST['invid']; //invoice id# $BILLNameF=$_REQUEST['BNFirst']; //Billing First Name $BILLNameL=$_REQUEST['BNLast']; //Billing Last Name if(isset($_REQUEST['BCompany'])) { $BILLCompany=$_REQUEST['BCompany']; } else { $BILLCompany=""; } $BILLAddr=$_REQUEST['BAddr']; //Billing Address $BILLCity=$_REQUEST['BCity']; //Billing City $BILLState=$_REQUEST['BState']; //Billing State $BILLZip=$_REQUEST['BZip']; //Billing Zip if(isset($_REQUEST['BCountry'])) { $BILLCountry=$_REQUEST['BCountry']; } else { $BILLCountry='USA'; } $CUSTId=$_REQUEST['CID']; //Customer ID if($BILLCompany!="") { $CUSTType="business"; } else { $CUSTType="individual"; } if(isset($_REQUEST['CUSTEmail'])) { $CUSTEmail=$_REQUEST['CUSTEmail']; } else { $CUSTEmail=""; } $OrderPKG = "Online Order - ".$_SESSION['PkgName']; /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\CodeConstants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\CodeConstants::MERCHANT_TRANSACTION_KEY); // Set the transaction's refId $refId = 'ref' . time(); // Create the payment data for a credit card $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber($CCNum); $creditCard->setExpirationDate($CCExp); $creditCard->setCardCode($CCcvv); // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); // Create order information $order = new AnetAPI\OrderType(); $order->setInvoiceNumber($INVNum); $order->setDescription($OrderPKG); // Set the customer's Bill To address $customerAddress = new AnetAPI\CustomerAddressType(); $customerAddress->setFirstName($BILLNameF); $customerAddress->setLastName($BILLNameL); $customerAddress->setCompany($BILLCompany); $customerAddress->setAddress($BILLAddr); $customerAddress->setCity($BILLCity); $customerAddress->setState($BILLState); $customerAddress->setZip($BILLZip); $customerAddress->setCountry($BILLCountry); // Set the customer's identifying information $customerData = new AnetAPI\CustomerDataType(); $customerData->setType("individual"); $customerData->setId($CUSTId); $customerData->setEmail($CUSTEmail); // Add values for transaction settings $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("60"); // Add some merchant defined fields. These fields won't be stored with the transaction, // but will be echoed back in the response. $merchantDefinedField1 = new AnetAPI\UserFieldType(); $merchantDefinedField1->setName("customerLoyaltyNum"); $merchantDefinedField1->setValue("1128836273"); $merchantDefinedField2 = new AnetAPI\UserFieldType(); $merchantDefinedField2->setName("favoriteColor"); $merchantDefinedField2->setValue("blue"); // Create a TransactionRequestType object and add the previous objects to it $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($INVamount); $transactionRequestType->setOrder($order); $transactionRequestType->setPayment($paymentOne); $transactionRequestType->setBillTo($customerAddress); $transactionRequestType->setCustomer($customerData); $transactionRequestType->addToTransactionSettings($duplicateWindowSetting); $transactionRequestType->addToUserFields($merchantDefinedField1); $transactionRequestType->addToUserFields($merchantDefinedField2); // Assemble the complete transaction request $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setTransactionRequest($transactionRequestType); // Create the controller and get the response $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); if ($response != null) { $_SESSION['TransID'] = ''; $_SESSION['AuthCode'] = ''; // Check to see if the API request was successfully received and acted upon if ($response->getMessages()->getResultCode() == "Ok") { // Since the API request was successful, look for a transaction response // and parse it to display the results of authorizing the card $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getMessages() != null) { // echo " Successfully created transaction with Transaction ID: " . $tresponse->getTransId() . "<br>"; // echo " Transaction Response Code: " . $tresponse->getResponseCode() . "<br>"; // echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "<br>"; // echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; // echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "<br>"; $_SESSION['TransID'] = $tresponse->getTransId(); $_SESSION['AuthCode'] = $tresponse->getAuthCode(); header("Location: ..\order_shiponline_confirm"); die; } else { echo "Transaction Failed \n"; if ($tresponse->getErrors() != null) { echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "<br>"; echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "<br>"; echo " <b>Click BACK on your browser to retype the card number.</b>"; } } // Or, print errors if the API request wasn't successful } else { echo "Transaction Failed \n"; $tresponse = $response->getTransactionResponse(); if ($tresponse != null && $tresponse->getErrors() != null) { echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "<br>"; echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "<br>"; } else { echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "<br>"; echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "<br>"; } } } else { echo "No response returned <br>"; } return $response; } if (!defined('DONT_RUN_SAMPLES')) { chargeCreditCard("2.23"); }
01-27-2019 01:14 PM
01-27-2019 01:34 PM