Create Non-posting (Unapproved payment) record by SOAP API in NetSuite
I am trying to create the Unapproved payment record in Netsuite when the Braintree transaction fails by SOAP API. I passed the Account Internal ID (unapproved customer payment) by API. But the API return the internal ID is invalid even if it’s presented under the Chart of accounts list.
Help to create this non-posting type payment record in Netsuite by SOAP API. I have attached some screenshots and code here FYI.
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;
}