1

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?

John Slegers
  • 45,213
  • 22
  • 199
  • 169
rob-gordon
  • 1,419
  • 3
  • 20
  • 38

1 Answers1

0

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.

  • @rob-gordon I was wondering, are the userFields available to your responseHandler? – Ken Brockert Mar 02 '17 at 21:26
  • 1
    userFields should be included when you submit the nonce from your server to Authorize.Net to process the transaction. Accept.js is used to avoid sensitive card data passing through your server. – rhldr Mar 02 '17 at 21:45
  • @rhldr you're correct. userFields is like invoiceNumber and is for the normal API. I'm trying find a way to send data to my accept.js handler. Do you know a way? – Ken Brockert Mar 02 '17 at 21:53