简体   繁体   中英

Authorize.net Accept.js Integration

I'm integrating a simple purchase form with Authorize.net using Accept.js and I would like to have an Invoice # or Job # recorded with the credit card transaction. The form submission handler looks like:

function getSecureData() {

  /* Compile Data from Form */
  var secureData = {},
  authData = {},
  cardData = {};

  cardData.cardNumber = document.getElementById('CARDNUMBER_ID').value;
  cardData.month = document.getElementById('EXPIRY_MONTH_ID').value;
  cardData.year = document.getElementById('EXPIRY_YEAR_ID').value;
  cardData.zip  = document.getElementById('ZIP_CODE').value;
  cardData.cardCode  = document.getElementById('CARD_CODE').value;

  authData.clientKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
  authData.apiLoginID = 'XXXXXXXXX';

  /* My attempt to attach a job number to the secureData being submitted */
  secureData.userFields = {
    job_number: document.getElementById('JOB_NUMBER').value
  };

  secureData.cardData = cardData;
  secureData.authData = authData;

  /* Dispatch Data to Accept.js */
  Accept.dispatchData(secureData, 'responseHandler');

}

I was trying to extrapolate from the data structure from createTransactionRequest in the documentation . However, the info doesn't seem to make it to the merchant's receipt.

Does anyone have any suggestions or experience doing this?

You will need to do this server side. Your responseHandler should be sending the dataDescriptor and dataValue to your server side implementation. I suggest sending the invoice # with them, or gathering it with the server, and use the platform specific API to set the invoiceNumber. For PHP it looks like this:

$order = new AnetAPI\OrderType();
$order->setInvoiceNumber($invoice_number);

The link to the documentation you provided is for the normal API and doesn't really apply to accept.js. The best source for information on accept.js seems to be the sample implementation on github . It's also an implementation for Apple Pay and can be confusing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM