2
votes

Update:--- Code provided which fixes an issue on the graph which was preventing the API from allowing me to create.

public class CustomerPaymentMethodMaint_Extension:PXGraphExtension<CustomerPaymentMethodMaint>
{

    #region Event Handlers

    protected virtual void CustomerPaymentMethodDetail_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
    {
        if (del != null)
        {
            del(cache, e);
        }
        if (Base.IsContractBasedAPI)
        {
            CustomerPaymentMethodDetail row = (CustomerPaymentMethodDetail)e.Row;
            PXDefaultAttribute.SetPersistingCheck<CustomerPaymentMethodDetail.value>(cache, row, PXPersistingCheck.Nothing);
        }
    }

    #endregion

}

For the life of me, I cannot figure out what Acumatica is expecting me to send to it to either retrieve or create a customer payment method using the Rest API. It would be greatly appreciated if you could point me in the right direction. The examples we are given are very basic and don't seem to cover any scenarios such as this.

I would assume it would be retrieved using the standard "Retrieval of a Record by Key Fields" as described in the help section.

I have tried using all of the below url structures and it either gives me an "Operation is not valud due to the current state of the object" error, or "More than one entity satisfies the condition".

/entity/Default/6.00.001/CustomerPaymentMethod/{BAccountID}/{PMInstanceID}
/entity/Default/6.00.001/CustomerPaymentMethod/{AcctCD}/{PMInstanceID}
/entity/Default/6.00.001/CustomerPaymentMethod/{BAccountID}
/entity/Default/6.00.001/CustomerPaymentMethod/{PMInstanceID}
/entity/Default/6.00.001/CustomerPaymentMethod/{AcctCD}

While trying to create a payment method I tried using a "PUT" to the CustomerPaymentMethod endpoint with the following json Body (I also tried using the soap friendly names of these fields instead of the label thats in the UI "CCDNUM","CVV","EXPDATE","NAMEONCC"). The error I get returned to me is that "Value" cannot be empty.

{
    "CustomerID" : { value: "0000467" },
    "PaymentMethod" : { value: "CC" },
    "CustomerPaymentMethodDetail" : [
        {
            "Description" : { value : "Card Number" },
            "Value" : { value : "4111111111111111" },
        },
        {
            "Description" : { value : "Expiration Date" },
            "Value" : { value : "102020" },
        },
        {
            "Description" : { value : "Name on the Card" },
            "Value" : { value : "Test API" },
        }
    ]
}
2
Hello Chris, How do you fix this issue with the RestAPI? I am getting the same error "PX.Data.PXException: Error: 'Value' cannot be empty." Please guide me to solve this issue. Quick Help can be highly appreciated. Thank you in advance.Pribhav
Chris if you got an answer from Acumatica instead of putting in your question, you should answer your own question and accept the answer.samol518

2 Answers

1
votes

The following works for me on a project where I'm using APS (American Payment Solutions) as the Processing Center.

Use GET to retreive a collection of Customer Payment Methods for a specific customer:

/entity/Default/6.00.001/CustomerPaymentMethod/?$filter=CustomerID+eq+'000000'

Use GET to return a single Customer Payment Method by ID: (You can find the ID from a record returned by the call above.)

/entity/Default/6.00.001/CustomerPaymentMethod/guid-from-record?$expand=Details

I don't think it's possible to create a Customer Payment Method using a brand new card with the Acumatica API. I think you'll first have to create the payment record using your processing center's API. (APS in my case, but I assume Authorize.net works in a similar fashion.) Then, once the payment record exists at the processor, you can add the Customer Payment Record in Acumatica using a PUT to populate the Payment Profile ID, which is a reference to the tokenized card. From there, you can use the GET calls above to return what you need in order to auth/capture a Sales Order.

I'm working through this now and I'll update my comment once I've learned more.

0
votes

For me the following worked

/entity/Default/{version}/CustomerPaymentMethod/{customerID}/{customerPaymentMethodId}

Now to get the customerPaymentMethodId this can be done via the customer endpoint when expanding PaymentInstructions.

However unfortunately PaymentInstructions only returns the default payment method for the customer.