【发布时间】:2021-04-23 05:47:58
【问题描述】:
当 Braintree 交易因 SOAP API 失败时,我正在尝试在 Netsuite 中创建未经批准的付款记录。我通过 API 传递了帐户内部 ID(未经批准的客户付款)。但是 API 返回的内部 ID 是无效的,即使它显示在科目表列表下。
帮助通过 SOAP API 在 Netsuite 中创建此非过帐类型的付款记录。我在这里附上了一些截图供参考。
public async Task<WriteResponse> updateInvoiceTranscation(Invoice invoiceRecord, Braintree.Transaction transaction)
{
bool isTransactionSuccess = BraintreeService.IsTransactionSuccess(transaction.Status);
WriteResponse customerPaymentResult = null;
InitializeRecord initRec = new InitializeRecord();
initRec.type = InitializeType.customerPayment;
InitializeRef initRef = new InitializeRef();
initRef.typeSpecified = true;
initRef.type = InitializeRefType.invoice;
initRef.internalId = invoiceRecord.internalId;
initRec.reference = initRef;
this.SecureAuthService();
initializeResponse response = await SuiteTalkClient.initializeAsync(null, CreateTokenPassport(), null, null, null, initRec);
ReadResponse result = response.readResponse;
if (result.status.isSuccess)
{
Record rec = result.record;
CustomerPayment customerPayment = (CustomerPayment)rec;
CustomerPaymentApply scustomerPayment = customerPayment.applyList.apply.Single(r => r.doc == long.Parse(invoiceRecord.internalId));
customerPayment.totalSpecified = false;
customerPayment.appliedSpecified = false;
customerPayment.unappliedSpecified = false;
customerPayment.balanceSpecified = false;
customerPayment.pendingSpecified = false;
if (!isTransactionSuccess)
{
RecordRef acccountRef = new RecordRef();
acccountRef.type = RecordType.account;
acccountRef.internalId = ((int)NetSuiteInternalIdEnum.UnApprovedPayment).ToString();
acccountRef.typeSpecified = true;
customerPayment.account = acccountRef;
customerPayment.undepFunds = false;
} else
{
//acccountRef.internalId = ((int)NetSuiteInternalIdEnum.UndepositAccount).ToString();
customerPayment.undepFunds = true;
}
customerPayment.undepFundsSpecified = true;
scustomerPayment.totalSpecified = false;
scustomerPayment.dueSpecified = false;
scustomerPayment.discSpecified = false;
scustomerPayment.amount = invoiceRecord.total;
scustomerPayment.amountSpecified = true;
List<CustomFieldRef> paymentCustomFields = new List<CustomFieldRef>();
StringCustomFieldRef custbodyBraintreeId = new StringCustomFieldRef();
custbodyBraintreeId.scriptId = Enum.GetName(typeof(CustomScriptIdEnum), CustomScriptIdEnum.custbody_braintree_id);
custbodyBraintreeId.value = transaction.Id;
paymentCustomFields.Add(custbodyBraintreeId);
BooleanCustomFieldRef custbodyBraintreeCharged = new BooleanCustomFieldRef();
custbodyBraintreeCharged.scriptId = Enum.GetName(typeof(CustomScriptIdEnum), CustomScriptIdEnum.custbody_braintree_charged);
custbodyBraintreeCharged.value = true;
paymentCustomFields.Add(custbodyBraintreeCharged);
customerPayment.customFieldList = paymentCustomFields.ToArray();
if (!isTransactionSuccess)
{
BooleanCustomFieldRef custbodyOrderOnHold = new BooleanCustomFieldRef();
custbodyOrderOnHold.scriptId = Enum.GetName(typeof(CustomScriptIdEnum), CustomScriptIdEnum.custbody_order_on_hold);
custbodyOrderOnHold.value = true;
paymentCustomFields.Add(custbodyOrderOnHold);
}
this.SecureAuthService();
addResponse customerPaymentResponse = await SuiteTalkClient.addAsync(null, CreateTokenPassport(), null, null, null, customerPayment);
customerPaymentResult = customerPaymentResponse.writeResponse;
}
return customerPaymentResult;
}
【问题讨论】: