I have been setting up payment integration using a login I created for development purposes(api login 83PsZ5z3). I was able to try different errors providing specific zipcodes, etc so the AVS would return an invalid address warning ,etc... But same transaction wont work w/customer's api.
Can anyone help?
This is the response I get using the real api login
C:\wamp64\www\healthsafetytrainingonline\index.php:1029: object(net\authorize\api\contract\v1\CreateTransactionResponse)[346] private 'transactionResponse' => null private 'profileResponse' => null private 'refId' (net\authorize\api\contract\v1\ANetApiResponseType) => null private 'messages' (net\authorize\api\contract\v1\ANetApiResponseType) => object(net\authorize\api\contract\v1\MessagesType)[368] private 'resultCode' => string 'Error' (length=5) private 'message' => array (size=1) 0 => object(net\authorize\api\contract\v1\MessagesType\MessageAType)[382] ... private 'sessionToken' (net\authorize\api\contract\v1\ANetApiResponseType) => null
If I use my developer's api login I get a proper response, eg
object(net\authorize\api\contract\v1\CreateTransactionResponse)[346]
private 'transactionResponse' =>
object(net\authorize\api\contract\v1\TransactionResponseType)[408]
private 'responseCode' => string '2' (length=1)
private 'rawResponseCode' => null
private 'authCode' => string 'TQPRED' (length=6)
private 'avsResultCode' => string 'N' (length=1)
private 'cvvResultCode' => string 'P' (length=1)
private 'cavvResultCode' => string '2' (length=1)
private 'transId' => string '40022326857' (length=11)
private 'refTransID' => string '40022326857' (length=11)
private 'transHash' => string '7B2F6946837AB60D055946037001A2ED' (length=32)
private 'testRequest' => string '0' (length=1)
private 'accountNumber' => string 'XXXX0002' (length=8)
private 'entryMode' => null
private 'accountType' => string 'AmericanExpress' (length=15)
private 'splitTenderId' => null
private 'prePaidCard' => null
private 'messages' =>
array (size=0)
empty
private 'errors' =>
array (size=1)
0 =>
object(net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType)[393]
...
private 'splitTenderPayments' =>
array (size=0)
empty
private 'userFields' =>
array (size=0)
empty
private 'shipTo' => null
private 'secureAcceptance' => null
private 'emvResponse' => null
private 'transHashSha2' => string '' (length=0)
private 'profile' => null
private 'profileResponse' => null
private 'refId' (net\authorize\api\contract\v1\ANetApiResponseType) => string 'ref1543524624' (length=13)
private 'messages' (net\authorize\api\contract\v1\ANetApiResponseType) =>
object(net\authorize\api\contract\v1\MessagesType)[368]
private 'resultCode' => string 'Ok' (length=2)
private 'message' =>
array (size=1)
0 =>
object(net\authorize\api\contract\v1\MessagesType\MessageAType)[382]
...
private 'sessionToken' (net\authorize\api\contract\v1\ANetApiResponseType) => null
This is the code leading to the transaction
define("AUTHORIZENET_API_LOGIN_ID", $api_login);
define("AUTHORIZENET_TRANSACTION_KEY", $transaction_key);
define("AUTHORIZENET_SANDBOX", ($sand?true:false));
define("TEST_REQUEST", "FALSE");
/*
require './vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
*/
define("AUTHORIZENET_LOG_FILE", "phplog");
$refId = 'ref' . time();
////*************************************************************/
////*************************************************************/
//validation
if($_REQUEST['firstName'] != ""
&& $_REQUEST['lastName'] != ""
&& $_REQUEST['email'] != ""
&& $_REQUEST['phone'] != ""
&& $_REQUEST['creditCardNumber'] != ""
&& $_REQUEST['cvv2Number'] != ""
&& $_REQUEST['address1'] != ""
&& $_REQUEST['city'] != ""
&& $_REQUEST['zip'] != "")
{
//exit("antes validacion");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName($api_login);
$merchantAuthentication->setTransactionKey($transaction_key);
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType( "authCaptureTransaction");
//$transactionRequestType->setTransactionType( "authorizationOnlyTransaction");
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber($_REQUEST['creditCardNumber']);
$creditCard->setExpirationDate( '20'.$_REQUEST['expDateYear'] . "-" . $_REQUEST['expDateMonth']);
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Bill To
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName($_REQUEST['firstName'] );
$billto->setLastName($_REQUEST['lastName']);
//$billto->setCompany("Souveniropolis");
$billto->setAddress($_REQUEST['address1']);
$billto->setCity($_REQUEST['city']);
$billto->setState($_REQUEST['state']);
$billto->setZip($_REQUEST['zip']);
$billto->setCountry($_REQUEST['country']);
$transactionRequestType->setAmount($amount);
$transactionRequestType->setBillTo($billto);
$transactionRequestType->setPayment($paymentOne);
$approved = false;
$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") ){
$approved = true;
if($debug){
echo "<br><br>Resposne Code (" . $tresponse->getResponseCode() . ":" . "" . ")<br><br>";
echo "<br><br>Charge Credit Card AUTH CODE : " . $tresponse->getAuthCode() . "<br><br>";
echo "<br><br>Charge Credit Card TRANS ID : " . $tresponse->getTransId() . "<br><br>";
}
$message = $tresponse->getMessages()[0]->getDescription();
if($debug)echo $message . "<br><br>";
}else{
if(method_exists($tresponse,"getErrors"))$message = $tresponse->getErrors()[0]->getErrorText();
if($debug){
if(method_exists($tresponse,"getResponseCode"))echo "<br><br>Charge Credit Card ERROR : Invalid response (" . $tresponse->getResponseCode() . ":" . "" . ")<br><br>";
echo $message . "<br><br>";
echo "print_r(tresponse)";print_r($tresponse);echo "<br>***<br>";
echo "dump(tresponse)";var_dump($tresponse);echo "<br>***<br>";
echo "print_r(response)";print_r($response);echo "<br>***<br>";
echo "dump(response)";var_dump($response);echo "<br>***<br>";
echo $tresponse;echo "<br>***<br>";
}
}
}else{
echo "Charge Credit card Null response returned";
}
}else{
$message = "Missing information on the Payment Form";
}
11-29-2018 01:46 PM
Hello @juaninacio2
When you are changing credentials, are you also ensuring you are specifying the correct endpoint?
define("AUTHORIZENET_SANDBOX", ($sand?true:false));
Our sandbox and production systems are completely separate. You cannot use credentials generated for the sandbox in production nor production in sandbox.
Richard
11-30-2018 11:26 AM