NetSuite:转换销售订单,在项目履行之前添加信用卡authCode和pnRefNum

时间:2016-12-04 17:15:30

标签: netsuite restlet suitescript

我正在为位于Webstore之外的NS构建一个前端。我们的支付网关有一个能够创建参考号和授权码的网络应用程序,这些需要附加到销售订单,以便支付提供商可以在分派订单时处理付款。这是可能的还是我在错误的树上吠叫?

我对NS很陌生,如果答案很明显,我会道歉!

我收到的错误消息是:

Code: INVALID_RCRD_TRANSFRM Details: That type of record transformation is not allowed. Please see the documentation for a list of supported transformation types.

这是我试图在我的RESTlet中使用的代码:

function authorizeCreditCard(dataIn) {
  nlapiLogExecution('DEBUG', 'Pre Transform', JSON.stringify(dataIn));
  var customerpayment, paymentrecord
  try {
    customerpayment = nlapiTransformRecord('salesorder', dataIn.id, 'customerpayment', {
      "memo": dataIn.memo,
      "authCode": dataIn.authCode,
      "pnRefNum": dataIn.pnRefNum,
      "ccApproved": dataIn.ccApproved,
      "ccAvsStreetMatch": dataIn.ccAvsStreetMatch,
      "ccAvsZipMatch": dataIn.ccAvsZipMatch,
      "ccSecurityCodeMatch": dataIn.ccSecurityCodeMatch
    });
    paymentrecord = nlapiSubmitRecord(customerpayment);
  } catch (e) {
    nlapiLogExecution('ERROR', 'Transform failed', e);
  }
  nlapiLogExecution('DEBUG', 'Post Transform: CP', JSON.stringify(customerpayment));
  nlapiLogExecution('DEBUG', 'Post Transform: PR', JSON.stringify(paymentrecord));

  if (paymentrecord) {
    return {
      status: 'success',
      data: paymentrecord
    }
  }
  return {
    status: 'error',
    message: 'something went wrong'
  }
}

3 个答案:

答案 0 :(得分:1)

无法将salerorder转换为customerpayment。 salerorder只能转换为cashsale,invoice,itemfulfillment,returnauthorization和revenuecommitment。我认为您应该首先将您的salerorder转换为发票,然后通过customerpayment付款给客户。

问候

答案 1 :(得分:0)

为了在外部系统中进行授权并在Netsuite中自动结算/捕获,第一步是为外部系统的授权使用相同的支付处理器(或显然只是相同的商业银行,但YMMMV)。

以下代码段用于创建具有授权的销售订单。稍后当您履行订单时,由此产生的现金销售将触发结算和捕获。如果您无法在NS中配置与授权相同的处理器,那么大多数商家银行都会使用非常简单的设置API。

function dummyExpDate() {
    var d = new Date();
    return ('0' + (d.getMonth() + 1)).slice(-2) + '/' + (d.getFullYear() + 1); // some future date
}
var soRec = nlapiTransformRecord('customer', custId, 'salesorder, {recordmode: 'dynamic'});
soRec.setFieldValue('paymentmethod', 'somepaymentmethodid_Visa_works'); // some payment method id for NS happiness
soRec.setFieldValue('ccnumber', '4111111111111111'); // dummy valid visa for NS happiness
soRec.setFieldValue('ccexpiredate', dummyExpDate());
soRec.setFieldValue('pnrefnum', pnref);
soRec.setFieldValue('ccapproved', 'T');

答案 2 :(得分:0)

@bknights @ pedro-bustos感谢您的帮助。

我已经弄明白了!很大程度上是由于你的回答bknights。

首次创建销售订单时,您只能添加authcode等。这意味着我必须稍微重构一下,但我现在可以添加auth代码和pn refs。

相关问题