Tuesday, June 18, 2019

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

public void initCustomerPayment()

        {

            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 = "5"; // Add Credit Card information

               

                CustomerPayment customerPayment = (CustomerPayment) rec;

                customerPayment.paymentMethod = payMethod;

                customerPayment.ccName = "Joe Jerry";

                customerPayment.ccNumber = "****************";

 

 

 

 

                customerPayment.ccExpireDate = DateTime.ParseExact("05/2014", "MM/yyyy", CultureInfo.CurrentCulture);

                customerPayment.ccExpireDateSpecified = true;

 

                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