Can you add an existing customer payment method to an existing sales order through Acumatica API?

I have created a Customer Payment Method through the API using the AR301000 screen. However, I have run into an error when trying to add the payment method to a sales order. Here is my current code.

    SO301000Content SO301000 = context.SO301000GetSchema();
    context.SO301000Clear();
    SO301000Content[] SO30100content = context.SO301000Submit
    (
        new Command[]
            {
                //add header info
                new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
                new Value { Value = "000129", LinkedCommand = SO301000.OrderSummary.OrderNbr },
                //add payment
                new Value { Value = "VISA", LinkedCommand = SO301000.PaymentSettings.PaymentMethod },
                new Value { Value = "VISA:****-****-****-7261", LinkedCommand = SO301000.PaymentSettings.CardAccountNo },

                SO301000.Actions.Save
            }
    );

When trying to run, it gives the following error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> PX.Data.PXException: Error #12: Updating 'Sales Order' record raised one or more errors. Please review. Error: 'Card/Account No' may not be empty.

Is there another Card/Account number field that must be updated?

1 Answer

  1. Alex- Reply

    2019-11-16

        You have to use different approach
    
        SO301000Content orderSchema = context.SO301000GetSchema();
        var commands = new Command[]
        {
            new Value 
            {
                Value = orderType, 
                LinkedCommand = orderSchema.OrderSummary.OrderType 
            },
            new Value 
            {
                Value = orderNbr, 
                LinkedCommand = orderSchema.OrderSummary.OrderNbr 
            },
            new Value 
            {
                Value = "TOKENCC", 
                LinkedCommand = orderSchema.PaymentSettings.PaymentMethod 
            },
            new Value 
            {
                Value = "True", 
                LinkedCommand = orderSchema.PaymentSettings.NewCard 
            },
    new Value { Value = "VISA", LinkedCommand = orderSchema.PaymentSettings.PaymentMethod },
    
    //below you have to fill attributes (pairs key-value)
            new Key
            {
                ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
                FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
                Value = "='CCDNUM'"
            },
            new Value 
            {
                Value = "4321111111111234", 
                LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value 
            },
    
            new Key
            {
                ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
                FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
                Value = "='CVV'"
            },
            new Value 
            {
                Value = "321", 
                LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value 
            },
    
    
            new Key
            {
                ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
                FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
                Value = "='EXPDATE'"
            },
            new Value 
            {
                Value = "01/2019", 
                LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value 
            },
    
            new Key
            {
                ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
                FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
                Value = "='NAMEONCC'"
            },
            new Value 
            {
                Value = "01/2019", 
                LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value 
            },
    
            orderSchema.Actions.Save
        };
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>