Authorize.net Accept.js集成

时间:2017-03-01 11:09:05

标签: javascript payment-gateway authorize.net accept.js

我使用Accept.js将简单的购买表单与Authorize.net集成,我希望记录发票#作业#与信用卡交易。表单提交处理程序如下所示:

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');

}

我试图从documentationcreateTransactionRequest的数据结构中进行推断。但是,该信息似乎并未显示给商家的收据。

有人有任何建议或经验吗?

1 个答案:

答案 0 :(得分:0)

您需要执行此服务器端。您的responseHandler应该将dataDescriptor和dataValue发送到您的服务器端实现。我建议随身携带发票#,或者将其与服务器一起收集,并使用特定于平台的API来设置invoiceNumber。对于PHP,它看起来像这样:

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

您提供的文档的链接适用于普通API,并不适用于accept.js。关于accept.js的最佳信息来源似乎是sample implementation on github。它也是Apple Pay的一个实现,可能会令人困惑。