cancel
Showing results for 
Search instead for 
Did you mean: 

E00114 Invalid OTS Token at create subscription request after Accept.js

Hello!

I'm trying to use Accept.js + my Server request to create subscription. 

 

Here a code i found at documentation:

 

// Set the transaction's refId
        $refId = 'ref' . time();
        // Subscription Type Info
        $subscription = new AnetAPI\ARBSubscriptionType();
        $subscription->setName("Socks Subscription ".mt_rand(0,9999));
        $interval = new AnetAPI\PaymentScheduleType\IntervalAType();
        $interval->setLength(23);
        $interval->setUnit("days");
        $paymentSchedule = new AnetAPI\PaymentScheduleType();
        $paymentSchedule->setInterval($interval);
        $paymentSchedule->setStartDate(new DateTime('2019-01-22'));
        $paymentSchedule->setTotalOccurrences("12");
        $paymentSchedule->setTrialOccurrences("1");
        $subscription->setPaymentSchedule($paymentSchedule);
        $subscription->setAmount(rand(1,99999)/12.0*12);
        $subscription->setTrialAmount("0.00");


        $payment = new AnetAPI\PaymentType();

        $creditCard = new AnetAPI\CreditCardType();
        $creditCard->setCardNumber("4111111111111111");
        $creditCard->setExpirationDate("2038-12");
        $payment->setCreditCard($creditCard);

        $subscription->setPayment($payment);


        $order = new AnetAPI\OrderType();
        $order->setInvoiceNumber("1234354");
        $order->setDescription("Description of the subscription");
        $subscription->setOrder($order);

        $billTo = new AnetAPI\NameAndAddressType();
        $billTo->setFirstName("John");
        $billTo->setLastName("Smith");
        $subscription->setBillTo($billTo);
        $request = new AnetAPI\ARBCreateSubscriptionRequest();
        $request->setmerchantAuthentication($this->merchantAuthentication);
        $request->setRefId($refId);
        $request->setSubscription($subscription);
        $controller = new AnetController\ARBCreateSubscriptionController($request);
        $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);

        if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") )
        {
            echo "SUCCESS: Subscription ID : " . $response->getSubscriptionId() . "\n";
        }
        else
        {
            echo "ERROR :  Invalid response\n";
            $errorMessages = $response->getMessages()->getMessage();
            echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "\n";
        }

It's working well, but it insert card data directly. I want to use Accept.js so i switched

$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$payment->setCreditCard($creditCard);

to

 

 

$opaqueData = new AnetAPI\OpaqueDataType();
        $opaqueData->setDataDescriptor("COMMON.ACCEPT.INAPP.PAYMENT");
        $opaqueData->setDataValue($opaquedataValue);
        $payment->setOpaqueData($opaqueData);

 

 $opaquedataValue contains a value i recieved from Accept.js 

So now it's not working and i have ERROR : Invalid response Response : E00114 Invalid OTS Token.

What is wrong?

Please help me :)

serg1992a
Member
3 REPLIES 3

I think i have the same issue like a guy from this topic:

https://community.developer.authorize.net/t5/Integration-and-Testing/error-E00114-testing-on-sandbox...

 

I took only one token from Accept.js every time i send there different card data

http://joxi.ru/DrlzpQVC48D6Z2

serg1992a
Member

Hi @serg1992a,

We generally get the above response code in the following case:

 

When payment token is not found on the server (most likely because it already got used).  Can you please try generating the new token and try with it ?

 

Also, sometimes incase of duplicate transactions, you encounter this issue. As it is a One time token, therefore, in the very first transaction it was consumed and for the second and forth coming transactions it is giving you this error.

AforANET
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert

 Hi @serg1992a

 

As mentioned by @AforANET you can get the E00114 error code if the token has been already used for a transaction.

 

But, you will also get the E00114 error if  the token you are generating in a different environment (eg Sandbox) and making create transaction request to different environment (e.g production)

 

Please make sure the accept.js and the create transaction request is being made to the same account on the same enviornment (either Sandbox or Production).

kikmak42
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert