cancel
Showing results for 
Search instead for 
Did you mean: 

API hosted form can't post after initial validation error

I am able to get the hosted form to come up and can process payments as long as the form validation passed. 

 

I am getting the following error whenever the user inputs an incorrect field.  I get the error message for the problem, then when it is corrected and clicking pay invoice I get an error "fingerprint value is not valid".  This is happening in the sandbox and production.  This example is in production, I entered an invalid expiration date:

 

paymentTransaction1.jpg

 

paymentTransaction2.jpg

 

Now the user is stuck and has to cancel and come back in to process the payment.  Also, I have the cancel event being captured via the iframe communicator and this does not work after this error so the iframe redirects to the cancelUrl passed in with the token request.  I can't get the cancel event to trigger unless I provide a cancel url.   Here is my javascript to handle the events:

 

$(document).ready(function () {

 

           window.CommunicationHandler = {};

 

function parseQueryString(str) {

var vars = [];

var arr = str.split('&');

var pair;

for (var i = 0; i < arr.length; i++) {

                   pair = arr[i].split('=');

                   vars[pair[0]] = unescape(pair[1]);

               }

return vars;

           }

 

           window.CommunicationHandler.onReceiveCommunication = function (argument) {

var params = parseQueryString(argument.qstr);

               console.log(argument);

switch (params['action']) {

case "resizeWindow":

//alert('resizeWindow: width-' + params['width'] + ' height-' + params['height']);

var iFrame = document.getElementById('authNetIFrame');

                       iFrame.width = params['width'];

                       iFrame.height = params['height'];

break;

case "cancel":

if (_paymentDetail) {

                           _paymentDetail.hide();

                           location.reload(true);

                       }

 

break;

case "transactResponse":

var transResponse = JSON.parse(params['response']);

 

if (transResponse.responseCode == 1) {

var firstName = '';

var lastName = '';

var city = '';

var state = '';

var zip = '';

var address = '';

 

if (transResponse.billTo != 'undefined') {

                               firstName = transResponse.billTo.firstName;

                               lastName = transResponse.billTo.lastName;

                               city = transResponse.billTo.city;

                               state = transResponse.billTo.state;

                               zip = transResponse.billTo.zip;

                               address = transResponse.billTo.address;

                           }

                           ProcessPaymentReceipt(transResponse.transId, transResponse.accountType, transResponse.accountNumber, firstName, lastName, city, state, zip, address);

                       }

break;

               }

           }

 

       });

 

 

Here is the C# code to build the request:

 

public getHostedPaymentPageResponse GetHostedResponse(String ApiLoginID, String ApiTransactionKey, decimal paymentAmount, bool testMode)

              {

var borrGuid = "";

if (UserID == 0 && !string.IsNullOrEmpty(Borrower.AppraisalOrder.PaymentGuid))

                           borrGuid = Borrower.AppraisalOrder.PaymentGuid;

 

ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = testMode ? AuthorizeNet.Environment.SANDBOX : AuthorizeNet.Environment.PRODUCTION;

ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()

                     {

                           name = ApiLoginID,

                           ItemElementName = ItemChoiceType.transactionKey,

                           Item = ApiTransactionKey,

                     };

 

var transactionRequest = new transactionRequestType

                     {

                           transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize capture only

                           amount = paymentAmount,

                           poNumber = borrGuid

                     };

 

settingType[] settings = new settingType[9];

 

                     settings[0] = new settingType();

                     settings[0].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();

                     settings[0].settingValue = "{\"showReceipt\": false, \"cancelUrl\": \"" + AdminModel.BaseUrl + "\", \"cancelUrlText\": \"Cancel\"}";

 

                     settings[1] = new settingType();

                     settings[1].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();

                     settings[1].settingValue = "{\"text\": \"Pay Invoice\"}";

 

                     settings[2] = new settingType();

                     settings[2].settingName = settingNameEnum.hostedPaymentPaymentOptions.ToString();

                     settings[2].settingValue = "{\"cardCodeRequired\": false, \"showCreditCard\": true, \"showBankAccount\": false}";

 

                     settings[3] = new settingType();

                     settings[3].settingName = settingNameEnum.hostedPaymentSecurityOptions.ToString();

                     settings[3].settingValue = "{\"captcha\": false}";

 

                     settings[4] = new settingType();

                     settings[4].settingName = settingNameEnum.hostedPaymentShippingAddressOptions.ToString();

                     settings[4].settingValue = "{\"show\": false, \"required\": false}";

 

                     settings[5] = new settingType();

                     settings[5].settingName = settingNameEnum.hostedPaymentBillingAddressOptions.ToString();

                     settings[5].settingValue = "{\"show\": false, \"required\": false}";

 

                     settings[6] = new settingType();

                     settings[6].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();

                     settings[6].settingValue = "{\"showEmail\": false, \"requiredEmail\": false, \"addPaymentProfile\": false}";

 

                     settings[7] = new settingType();

                     settings[7].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();

                     settings[7].settingValue = "{\"show\": false, \"merchantName\": \"\"}";

 

                     settings[8] = new settingType();

                     settings[8].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString();

                     settings[8].settingValue = "{\"url\": \"" + AdminModel.BaseUrl + "InvoiceCommunicator.html\"}";

 

var request = new getHostedPaymentPageRequest();

                     request.transactionRequest = transactionRequest;

                     request.refId = UserID.ToString();

                     request.hostedPaymentSettings = settings;

 

// instantiate the contoller that will call the service

var controller = new getHostedPaymentPageController(request);

                     controller.Execute();

 

// get the response from the service (errors contained if any)

var response = controller.GetApiResponse();

 

return response;

              }

public string GetHostedFormToken()

              {

string token = "";

 

if (Test)

                     {

if (!string.IsNullOrEmpty(TestLogin))

                           {

                                  Login                = TestLogin;

                                  TransactionKey       = TestTransactionKey;

                           }

                     }

 

Decimal amt = 0;

Decimal.TryParse(PmtFormAmount, out amt);

 

var logger    = NLog.LogManager.GetLogger("AuthorizeNet");

var resp      = GetHostedResponse(Login,TransactionKey, amt, Test);

 

//validate

if (resp != null && resp.messages.resultCode == messageTypeEnum.Ok)

                     {

                           token = resp.token;

                     }

 

                     logger.Debug(() => String.Format("HostedFormToken: [{}{}{0}] : token  ", Borrower.BorrowerID.ToString()) + token);

 

return token;

              }

 

 

Thanks for your help.

mcarver8
Member
14 REPLIES 14

I have tried the following based on your request in sandbox in our test page. Dont see any issue. 

Can you let me know more about -- whenever user inputs incorrect field. we expose the fields you want based on the settings in the below request. so i believe that there wouldnt be any incorrect fields. 

 

-Bhavana

<getHostedPaymentPageRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name>8zw38TXp</name>
    <transactionKey>29L3e238quN7yqQT</transactionKey>
  </merchantAuthentication>
  <transactionRequest>
    <transactionType>authCaptureTransaction</transactionType>
    <amount>22.72</amount>
    <order>
      <invoiceNumber>INV_i7C7p7M</invoiceNumber>
      <description>Order description</description>
    </order>
    <lineItems>
      <lineItem>
        <itemId>123</itemId>
        <name>SKU1</name>
        <description>line item 1 description</description>
        <quantity>1</quantity>
        <unitPrice>4.01</unitPrice>
      </lineItem>
      <lineItem>
        <itemId>1234</itemId>
        <name>SKU2</name>
        <description>line item 2 description</description>
        <quantity>2</quantity>
        <unitPrice>5.01</unitPrice>
      </lineItem>
    </lineItems>
    <tax>
      <amount>1.01</amount>
      <name>tax name</name>
      <description>tax descryption</description>
    </tax>
    <duty>
      <amount>3.01</amount>
      <name>tax name</name>
      <description>duty description</description>
    </duty>
    <shipping>
      <amount>2.01</amount>
      <name>freight name</name>
      <description>freight description</description>
    </shipping>
    <poNumber>PO#12345678</poNumber>
    <customer>
      <id>CUST12345</id>
      <email>blackhole@authorize.net</email>
    </customer>
    <billTo>
      <firstName>Bob</firstName>
      <lastName>Smith</lastName>
      <company>Test Company</company>
      <address>1234 Test Ave N.E.</address>
      <city>Test Bellevue</city>
      <state>WA</state>
      <zip>98009</zip>
      <country>USA</country>
      <phoneNumber>425 111 2222</phoneNumber>
      <faxNumber>425 111 2222</faxNumber>
    </billTo>
    <shipTo>
      <firstName>Bob</firstName>
      <lastName>Smith</lastName>
      <company>Test &amp; Company</company>
      <address>Ship to 1234 Test Ave N.E.</address>
      <city>Test &amp; Bellevue</city>
      <state>WA</state>
      <zip>98009</zip>
      <country>USA</country>
    </shipTo>
    <customerIP>10.123.345.678</customerIP>
  </transactionRequest>
  <hostedPaymentSettings>
    <setting>
      <settingName>hostedPaymentPaymentOptions</settingName>
      <settingValue>{"cardCodeRequired": true, "showCreditCard":true, "showBankAccount":false}</settingValue>
    </setting>
	 <setting>
	 <settingName>hostedPaymentSecurityOptions</settingName>
      <settingValue>{"captcha": false}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentBillingAddressOptions</settingName>
      <settingValue>{"show": false, "required": false}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentShippingAddressOptions</settingName>
      <settingValue>{"show":false, "required": false}</settingValue>
    </setting>
	    <setting>
      <settingName>hostedPaymentOrderOptions</settingName>
      <settingValue>{"show": false}</settingValue>
    </setting>
    <setting>
      <settingName>hostedPaymentCustomerOptions</settingName>
      <settingValue>{"showEmail": false, "requiredEmail": false, "addPaymentProfile": false}</settingValue>
    </setting>
  </hostedPaymentSettings>
</getHostedPaymentPageRequest>

 

bhav
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert

by incorrect fields I mean they enter an invalid value, so in the sandbox while testing I entered the invalid zip code 46282 and receive a transaction declined message.  Then when I change to a valid zip code I get the invalid fingerprint error.  It doesn't matter what field value is invalid, I was displaying the address information as well. When I would enter an invalid zip code for the card being used, I get an address mismatch error then when corrected I get the fingerprint error and can't continue.  Is there a minimum version of jquery that is acceptable? 

mcarvar8, I am able to repro your issue in sandbox . But doing the same in our lower env. 

Will get back to you tomorrow.

 

-Bhavana

bhav
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert

 mcarvar8, able to reproduce this issue in our lower enviornment too and reported to the internal team. While we fix the issue, Workaround suggested by dev(@surya) was to regenerate token fresh in this scenario.

 

-Bhavana

bhav
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert

Is there any idea on a timeline of when to expect this to be fixed?  Because I lose communication back to the iframe communicator in my site I have no idea there is an issue, thus I can't trigger a new token. 

I'm reproducing the same issue.

 

A band-aid fix we implemented is to change the "Cancel" button into a "Reset Form and Try Again" button, which reloads the page. It's definetely not the best solution, but it gives users at least SOME option.

 

This is a really significant flaw that makes it hard for us to propose Authorize.net Accept Hosted as a replacement for Authorize.net SIM. Until this is fixed we'll probably need to suggest an alternative gateway to our users.

eventespresso
Member

We gave up on this solution and switched to Accept Js with our own custom form.  It was easy to implement and gave us full control, plus it kept our user experience the same as our original SIM solution.  We just had to build the new API calls for transaction processing in C#. 

Hi @eventespresso @mcarver8

 

This issue has been already reported to the dev team .

I will keep the thread posted once its released .

 

 

Thanks





Send feedback at developer_feedback@authorize.net

Anurag --

 

Is there any update on this?

 

/E