I'm setting up AuthorizeNetAPI, and I have it working just fine for my card not present account - my ecom site. I have another account that is card present - for my retail store, and I'm trying to implement a feature where someone can order a product from my ecom site, and that order would go to the retail store account.
I tried to simply change my credientials, and I get this error:
Transaction Failed Error Code : 87 Error Message : Transactions of this market type cannot be processed on this system.
I did some research, and believe I need to change the market type on my request - but I cannot figure out how this is done.
Anyone has some advice they could spare?
Thanks!
Solved! Go to Solution.
โ07-29-2017 07:26 AM
All of the PHP applications in the SDK use cURL. Example code from the PHP SDK for cardPresent transactions is at: https://github.com/AuthorizeNet/sdk-php/blob/master/lib/AuthorizeNetCP.php
โ07-29-2017 02:08 PM - edited โ07-29-2017 02:20 PM
What API call are you making? If you are obtaining a Token with one account's credentials, then charging the card with another, that woud be good reason for the error.
If you are sure you are not doing the above, check the value of the marketType element that is being posted is appropriate for your account and transaction, "marketType" value should be "2" for Card Present transactions.
The retail element contains two elements: marketType and deviceType.
If you submit the retail element, the marketType and DeviceType elements are required.
marketType [0,1,2]
0 for ecommerce
1 for moto
2 for retail
deviceType [1, 2, 3, 4, 5, 7, 8, 9, 10]
1 = Unknown
2 = Unattended Terminal
3 = Self Service Terminal
4 = Electronic Cash Register
5 = Personal Computer- Based Terminal
7 = Wireless POS
8 = Website
9 = Dial Terminal
10 = Virtual Terminal
โ07-29-2017 09:15 AM - edited โ07-29-2017 09:18 AM
this is the sample code I am using:
http://developer.authorize.net/api/reference/index.html#payment-transactions-authorize-a-credit-card
Where is marketType set?
โ07-29-2017 10:09 AM - edited โ07-29-2017 10:10 AM
If you post your code, you may be able to be better helped. In the XML it would be like:
</shipTo> <customerIP>192.168.1.1</customerIP> <retail> <marketType>2</marketType> <deviceType>5</deviceType> </retail> <transactionSettings>
Are you sure you are using the right credentials for the Card Present account?
โ07-29-2017 10:48 AM - edited โ07-29-2017 10:55 AM
This is the code I am using, right from the sample code.
I do not see any marketType here, or any XML -
Is the marketType and deviceType set in the merchantAuthentication constructor?
$merchantAuthentication->
<?php require 'vendor/autoload.php'; use net\authorize\api\contract\v1 as AnetAPI; use net\authorize\api\controller as AnetController; define("AUTHORIZENET_LOG_FILE", "phplog"); function authorizeCreditCard($amount) { /* Create a merchantAuthenticationType object with authentication details retrieved from the constants file */ $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName(\SampleCode\Constants::MERCHANT_LOGIN_ID); $merchantAuthentication->setTransactionKey(\SampleCode\Constants::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("4111111111111111"); $creditCard->setExpirationDate("2038-12"); $creditCard->setCardCode("123"); // Add the payment data to a paymentType object $paymentOne = new AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); // Create order information $order = new AnetAPI\OrderType(); $order->setInvoiceNumber("10101"); $order->setDescription("Golf Shirts"); // Set the customer's Bill To address $customerAddress = new AnetAPI\CustomerAddressType(); $customerAddress->setFirstName("Ellen"); $customerAddress->setLastName("Johnson"); $customerAddress->setCompany("Souveniropolis"); $customerAddress->setAddress("14 Main Street"); $customerAddress->setCity("Pecan Springs"); $customerAddress->setState("TX"); $customerAddress->setZip("44628"); $customerAddress->setCountry("USA"); // Set the customer's identifying information $customerData = new AnetAPI\CustomerDataType(); $customerData->setType("individual"); $customerData->setId("99999456654"); $customerData->setEmail("EllenJohnson@example.com"); // 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("authOnlyTransaction"); $transactionRequestType->setAmount($amount); $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::SANDBOX); if ($response != null) { // Check to see if the API request was successfully received and acted upon if ($response->getMessages()->getResultCode() == \SampleCode\Constants::RESPONSE_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() . "\n"; echo " Transaction Response Code: " . $tresponse->getResponseCode() . "\n"; echo " Message Code: " . $tresponse->getMessages()[0]->getCode() . "\n"; echo " Auth Code: " . $tresponse->getAuthCode() . "\n"; echo " Description: " . $tresponse->getMessages()[0]->getDescription() . "\n"; } else { echo "Transaction Failed \n"; if ($tresponse->getErrors() != null) { echo " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "\n"; echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } } // 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() . "\n"; echo " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "\n"; } else { echo " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "\n"; echo " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "\n"; } } } else { echo "No response returned \n"; } return $response; } if (!defined('DONT_RUN_SAMPLES')) { authorizeCreditCard(\SampleCode\Constants::SAMPLE_AMOUNT); } ?>
โ07-29-2017 12:53 PM
Would a card present account require a different endpoint?
I could not find any information on this, but the endpoint that works fine is from the Sample Code:
const PRODUCTION = "https://api2.authorize.net";
Is it different for CP?
โ07-29-2017 01:04 PM
I've tried dumping the $controller data:
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION); print_r($controller);
There is quite a bit of data, but I cannot find anything regarding marketType or deviceType.
โ07-29-2017 01:24 PM
Are you posting card track data read from the customer's card?
If you are posting to a Card Present only account, you may need to be sending the track data instead of the creditCard element.
โ07-29-2017 01:39 PM - edited โ07-29-2017 01:40 PM
The retail stores are setup with a different type of Authorize.net api. It uses curl - the call is like this:
$ch = curl_init("https://cardpresent.authorize.net/gateway/transact.dll"); curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data ### curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ### $resp = curl_exec($ch); //execute post and get results curl_close ($ch);
This can accept the credit card number or the track data.
Is it possible to use the AnetAPI for a Card Present type account?
โ07-29-2017 01:47 PM
All of the PHP applications in the SDK use cURL. Example code from the PHP SDK for cardPresent transactions is at: https://github.com/AuthorizeNet/sdk-php/blob/master/lib/AuthorizeNetCP.php
โ07-29-2017 02:08 PM - edited โ07-29-2017 02:20 PM