Tuesday, June 18, 2019

SuiteTalk (Web Services) C# Sample (2013.2) - Do Customer Payment from Invoice (Cash) - [Initialization and Add Operation]

public void initCustomerPayment_Cash_FromInvoice()

        {

            NetSuiteService service = new NetSuiteService();

            LoginClass passport = new LoginClass();

            service.passport = passport.login();

 

            InitializeRecord initRec = new InitializeRecord();

            initRec.type = InitializeType.customerPayment;

 

            InitializeRef initRef = new InitializeRef();

            initRef.typeSpecified = true;

            initRef.type = InitializeRefType.invoice;

            initRef.internalId = "973"; // this is the Invoice Internal ID

            initRec.reference = initRef;

 

            ReadResponse getInitResp = service.initialize(initRec);

            if (getInitResp.status.isSuccess)

            {

                Record rec = getInitResp.record;

                RecordRef payMethod = new RecordRef();

                payMethod.internalId = "1"; // Add Credit Card information

 

                CustomerPayment customerPayment = (CustomerPayment)rec;

                customerPayment.paymentMethod = payMethod;

               

                customerPayment.totalSpecified = false;

                customerPayment.appliedSpecified = false;

                customerPayment.unappliedSpecified = false;

                customerPayment.balanceSpecified = false;

                customerPayment.pendingSpecified = false;

 

 

                customerPayment.applyList.apply[0].totalSpecified = false;

                customerPayment.applyList.apply[0].dueSpecified = false;

                customerPayment.applyList.apply[0].discSpecified = false;

 

                customerPayment.applyList.apply[0].amount = 50;

                customerPayment.applyList.apply[0].amountSpecified = true;

 

 

                WriteResponse writeRes = service.add(customerPayment);

            }

        }

No comments:

Post a Comment