Reply
Highlighted
Member
Posts: 4
Registered: ‎06-13-2017

Missing or Invalid token

Hello Everyone,

 

I'm currently seeing the "Missing or Invalid Token" when trying to display host form in my iFrame.  I've read other posts in this forum regarding the same issue and I've applied the suggestions however, I'm not having any luck.  Here are the endpoints and code I'm using:

 

.NET C# implementation

 

GetToken URL: Snippet

https://test.authorize.net/payment/payment

 GetHostForm URL: Snippet

https://test.authorize.net

 

I can successfully retrieve a token using the provided C# code.

 

Here's the HTML I have implemented:

<div>
    <input type="hidden" id="Token" name="Token" value="@Model.AcceptPaymentToken" />
    <input type="hidden" name="PaymentProfileId" value="" />
    <input type="hidden" name="ShippingAddressId" value="" />

    <div id="divAuthorizeNetPopup" style="display:none;" class="AuthorizeNetPopupSimpleTheme">
        <div class="AuthorizeNetPopupOuter">
            <iframe src="/CheckOut/AuthorizePage" name="iframeAuthorizeNet" id="iframeAuthorizeNet" frameborder="0" scrolling="no"></iframe>
        </div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowT"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowR"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowB"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowL"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowTR"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowBR"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowBL"></div>
        <div class="AuthorizeNetShadow AuthorizeNetShadowTL"></div>
    </div>

    <button onclick="AuthorizeNetPopup.openAddPaymentPopup()">Add a New Payment</button>

    <!--
    INSTRUCTIONS:
    Put this divAuthorizeNetPopupScreen section right before the closing </body> tag.
    -->
    <div id="divAuthorizeNetPopupScreen" style="display:none;"></div>
</div>

I have tried generating a token through the Authorize.NET GUI and paste into the examplePage.html provided in the examples section but I get the same error message.

 

I would greatly appreciate your help.  This has been bugging me for several days now.

 

Highlighted
Member
Posts: 4
Registered: ‎06-13-2017

Re: Missing or Invalid token

Sorry, I left out another important piece code.  In my JS file which is supplied with the example, I have modified the form submit to use AJAX instead of the standard HTML form since I already have another form implemented on the page and I can't nest:

 

        $.ajax({
            type: 'POST',
            cache: false,
            dataType: 'html',
            async: false,
            url: "/CheckOut/DisplayCreditCardForm",
            data: {
                "url": action,
                "token": token,
                "paymentProfileId": paymentProfileId.value,
                "shippingAddressId": shippingAddressId.value
            },
            success: function (html) {
                $('iframeAuthorizeNet').html(html);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                console.error(thrownError);
            }
        });
Highlighted
Member
Posts: 4
Registered: ‎06-13-2017

Re: Missing or Invalid token

Ok, so disregard the AJAX I posted above.  I have reverted beack to regular HTML FORM and I am able to display the hosted page in my iFrame.  However, I'm still seeing the Missing or Invalid Token message.

 

I'm retrieving the token correctly using the OUT OF THE BOX C# code provided by Authorize.NET.  I'm sending the token to https://test.authorize.net/profile/manage but still no luck.

 

<form method="post" action="https://test.authorize.net/profile/manage" id="formAuthorizeNetPopup" name="formAuthorizeNetPopup" target="iframeAuthorizeNet" style="display:none;">
        <input type="hidden" id="Token" name="Token" value="">
        <input type="hidden" id="PaymentProfileId" name="PaymentProfileId" value="">
        <input type="hidden" id="ShippingAddressId" name="ShippingAddressId" value="">
    </form>
Highlighted
Member
Posts: 6
Registered: ‎02-19-2020

Re: Missing or Invalid token

I'm just not implementing something similar and getting this Token error as well.  Did you resolve it?

I know I have the token but something is failing.

I could use some help!