Acumatica - Creating customer payment method with api

ε祈祈猫儿з 提交于 2019-12-06 04:53:50

Ok, so here is working code provided from Acumatica. I still have no idea why the old code broke when it has been working this entire year, but here's working code and it's a little cleaner since you do not have to deal with key/value.

        var context = new acumatica.Screen();
        context.CookieContainer = new System.Net.CookieContainer();
        context.AllowAutoRedirect = true;
        context.EnableDecompression = true;
        context.Timeout = 1000000;
        LoginResult result = context.Login("admin", "admin");

        context.AR303010Clear();
        AR303010Content AR303010 = context.AR303010GetSchema();

        try
        {
            var commands = new Command[]
                    {
                        new Value { Value = "ABARTENDE", 
                            LinkedCommand = AR303010.PaymentMethodSelection.Customer},
                        AR303010.Actions.Insert,
                        new Value { Value = "VISA", 
                            LinkedCommand = AR303010.PaymentMethodSelection.PaymentMethod},

                        new Value
                        {
                            Value = "='CCDNUM'",
                            LinkedCommand = AR303010.PaymentMethodDetails.Description
                        },

                        new Value { Value = "41111111111111118",
                                    LinkedCommand = AR303010.PaymentMethodDetails.Value,
                                    Commit = true
                        },

                        new Value
                        {
                            Value = "='CVV'",
                            LinkedCommand = AR303010.PaymentMethodDetails.Description
                        },

                        new Value { Value = "121",
                                    LinkedCommand = AR303010.PaymentMethodDetails.Value,
                                    Commit = true
                        },

                        new Value
                        {
                            Value = "='EXPDATE'",
                            LinkedCommand = AR303010.PaymentMethodDetails.Description
                        },

                        new Value {Value = "01/2019", 
                                   LinkedCommand = AR303010.PaymentMethodDetails.Value,
                                    Commit = true
                        },

                        new Value
                        {
                            Value = "='NAMEONCC'",
                            LinkedCommand = AR303010.PaymentMethodDetails.Description
                        },

                        new Value {Value = "Mr Jon Doe 8", 
                                   LinkedCommand = AR303010.PaymentMethodDetails.Value,
                                    Commit = true
                        },

                        AR303010.Actions.Save};
            AR303010Content[] AR303010Content = context.AR303010Submit(commands.ToArray());

        }
        catch (Exception ex)
        {
        }

here is the example which i used

public void CreateARPayment()
{
    string paymentType = GetParamValue("lblARPaymentType");
    string paymentNbr = GetParamValue("lblARPaymentNbr");
    string customerID = GetParamValue("txbCustomerID");
    string cardAccountNo = GetParamValue("lblCardAccountNo");

    string arInvoiceNbr = GetParamValue("txbARInvoiceNbr");
    string soInvoiceNbr = GetParamValue("txbSOInvoiceNbr");

    Screen context = new Screen();
    context.CookieContainer = new System.Net.CookieContainer();
    context.Url = Url;
    context.Login(Login, Password);

    AR302000Content paymentSchema = context.AR302000GetSchema();

    paymentSchema.PaymentSummary.CardAccountNo.FieldName += "!Descr";

    var commands = new Command[]
    {
        new Value 
        { 
            Value = customerID, 
            LinkedCommand = paymentSchema.PaymentSummary.Customer 
        },
        new Value 
        {
            Value = "TOKENCC", 
            LinkedCommand = paymentSchema.PaymentSummary.PaymentMethod 
        },
        new Value 
        {
            Value = cardAccountNo, 
            LinkedCommand = paymentSchema.PaymentSummary.CardAccountNo 
        },
        new Value 
        {
            Value = "101000", 
            LinkedCommand = paymentSchema.PaymentSummary.CashAccount 
        },
        new Value 
        {
            Value = "09/2014/AR-00001", 
            LinkedCommand = paymentSchema.PaymentSummary.PaymentRef 
        },

        paymentSchema.DocumentsToApply.ServiceCommands.NewRow,
        new Value 
        {
            Value = arInvoiceNbr, 
            LinkedCommand = paymentSchema.DocumentsToApply.ReferenceNbr, 
            Commit = true 
        },

        paymentSchema.DocumentsToApply.ServiceCommands.NewRow,
        new Value 
        {
            Value = soInvoiceNbr, 
            LinkedCommand = paymentSchema.DocumentsToApply.ReferenceNbr, 
            Commit = true 
        },

        paymentSchema.PaymentSummary.AppliedToDocuments,
    };
    var payment = context.AR302000Submit(commands)[0];

    commands = new Command[]
    {
        new Value 
        {
            Value = payment.PaymentSummary.AppliedToDocuments.Value, 
            LinkedCommand = paymentSchema.PaymentSummary.PaymentAmount 
        },

        paymentSchema.Actions.Save,

        paymentSchema.PaymentSummary.ReferenceNbr,
        paymentSchema.PaymentSummary.Status,
        paymentSchema.PaymentSummary.PaymentAmount
    };
    payment = context.AR302000Submit(commands)[0];

    UpdateSetting("lblARPaymentNbr", payment.PaymentSummary.ReferenceNbr.Value);
    UpdateSetting("lblARPaymentStatus", payment.PaymentSummary.Status.Value);
    UpdateSetting("lblARPaymentAmount", payment.PaymentSummary.PaymentAmount.Value);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!