Acumatica-使用api创建客户付款方式 [英] Acumatica - Creating customer payment method with api

查看:76
本文介绍了Acumatica-使用api创建客户付款方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用API​​创建客户付款方式的正确方法是什么?这还将回答如何使用具有键值对的网格而不是将值仅存储到特定字段中。

What is the correct way to create a customer payment method using the API? This will also answer how to work with a grid that has a key value pair vs just storing values into a particular field.

此代码已在使用中并且可以正确运行现在已经快一年了,然后从本周初开始,它将不再起作用。

This code has been in use and functioning correctly for almost a year now and then starting earlier this week it no longer works.

    // Connect to Acumatica
    context = new acumatica.Screen();
    context.CookieContainer = new System.Net.CookieContainer();
    context.AllowAutoRedirect = true;
    context.EnableDecompression = true;
    context.Timeout = 1000000;
    context.Url = Properties.Settings.Default.WebServiceURL;
    LoginResult result = api.context.Login(Properties.Settings.Default.AcumaticaUserName, Properties.Settings.Default.AcumaticaPassword);

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

    try
    {
    Debug.WriteLine("--- Payment Method Start ---");
        // Create Invoice
        AR303010.Actions.Save.Commit = true;
        AR303010Content[] AR303010Content = context.AR303010Submit
        (
            new Command[]
            {

                new Value { Value = "ABARTENDE", LinkedCommand = AR303010.PaymentMethodSelection.Customer, Commit = true },

                AR303010.Actions.Insert,

                new Value { Value = "VISA", LinkedCommand = AR303010.PaymentMethodSelection.PaymentMethod, Commit = true },

                new Key
                {
                    ObjectName = AR303010.PaymentMethodDetails.Description.ObjectName,
                    FieldName = AR303010.PaymentMethodDetails.Description.FieldName,
                    Value = "=[" + AR303010.PaymentMethodDetails.Description.ObjectName + "." + AR303010.PaymentMethodDetails.Description.FieldName + "]"
                },

                new Value {Value = "Card Number", LinkedCommand = AR303010.PaymentMethodDetails.Description},
                new Value {Value = "4000000000003636", LinkedCommand = AR303010.PaymentMethodDetails.Value, Commit = true},

                new Key
                {
                    ObjectName = AR303010.PaymentMethodDetails.Description.ObjectName,
                    FieldName = AR303010.PaymentMethodDetails.Description.FieldName,
                    Value = "=[" + AR303010.PaymentMethodDetails.Description.ObjectName + "." + AR303010.PaymentMethodDetails.Description.FieldName + "]"
                },

                new Value {Value = "Card Verification Code", LinkedCommand = AR303010.PaymentMethodDetails.Description},
                new Value {Value = "321", LinkedCommand = AR303010.PaymentMethodDetails.Value, Commit = true},

                new Key
                {
                    ObjectName = AR303010.PaymentMethodDetails.Description.ObjectName,
                    FieldName = AR303010.PaymentMethodDetails.Description.FieldName,
                    Value = "=[" + AR303010.PaymentMethodDetails.Description.ObjectName + "." + AR303010.PaymentMethodDetails.Description.FieldName + "]"
                },

                new Value {Value = "Expiration Date", LinkedCommand = AR303010.PaymentMethodDetails.Description},
                new Value {Value = "012015", LinkedCommand = AR303010.PaymentMethodDetails.Value, Commit = true},

                AR303010.Actions.Save
            }
        );

        Debug.WriteLine("--- Payment Method Created ---");
    }
    catch (Exception ex)
    {
        Debug.WriteLine(" --- Failed to create Payment Method ---");
        Debug.WriteLine(ex.Message);
    }

该代码最初是从Acumatica论坛上提取的:

The code was originally pulled from the Acumatica forums at:

http://forum.acumatica.com/forum/acumatica-reseller-and-isv-community/development-and-customization/5873-setting-credit卡-fields-though-web-services

http:// forum。 acumatica.com/zh-cn/forum/acumatica-reseller-and-isv-community/发展和定制/ 885-帮助将新的付款方式添加到给定的客户通过webservice-ar303010

•我们尝试在以前的版本上使用该代码,我们知道该代码以前可以100%正常工作。
•我们尝试取消发布自定义项。
•我们尝试将数据发送到tryacumatica.com上的acumatica演示

• We have tried using the code on a previous version that we know 100% that it used to work on. • We have tried unpublishing our customizations. • We have tried sending the data over to the acumatica demo located at tryacumatica.com

我们测试过的每个站点/版本/计算机都将其返回相同的错误。

Every single site/version/computer we have tested it on returns the same error.

 Error #12: Inserting  'Customer Payment Method Detail' record raised one or more errors. Please review. Error: 'Value' may not be empty. ---> PX.Data.PXOuterException: Error #12: Inserting  'Customer Payment Method Detail' record raised one or more errors. Please review.

有人可以指出我正确的方向吗?

Can somebody please point me in the right direction?

推荐答案

好,所以这里是Acumatica提供的工作代码。我仍然不知道为什么旧代码在整个一年中都工作时会中断,但是这里是有效的代码,由于您不必处理键/值,因此它更简洁。

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)
        {
        }

这篇关于Acumatica-使用api创建客户付款方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆