Reply
Highlighted
appfly Student

Student

Student
Posts: 2
Registered: Wednesday

How to apply a payment to an invoice

Using a hosted payment page, I retrieve the payment method ID. I have the customer's invoice ID which has the outstanding amount on it. I figure using the CRUD create payment method is the correct method, though I run into an error message that I'm not able to understand.

 

Request

 

to: (POST) /v1/object/payment

 

{
"AccountId": [customer account id], "InvoiceId": [customer invoice id], "amount": 123, "AppliedInvoiceAmount": 123, "EffectiveDate": "2017-12-06", "type": "Electronic", "PaymentMethodId": [The payment method id returned from the hosted payment page], "gateway": [the payment gateway id], "Status": "Processed", "Type": "Electronic"
}

 

This is the error response however:

 

{
    "Code": "INVALID_VALUE",
    "Message": "Electronic payment and electronic method should be in the same account."
}

What's the payment / method / account these refer to here - as i'm not sure where the mismatch is. e.g. is it referring to a customer account, or to a banking account of sorts?

 

Many thanks for your assistance.

 

x

yamasaki1ma Master

Master

Master
Posts: 41
Registered: ‎02-22-2017

Re: How to apply a payment to an invoice

[ Edited ]

Hi @appfly

 

This "account" seems to mean Customer Account of Zuora, not banking account.

 

Your customers each have a credit card (or debit card or Paypal or ACH ...)
That is, each Account on Zuora has a different Payment Method.
This error message appears when you specify a Payment Method that the Account you specified as "AccountId" does not have.
In other words, the Payment Method of an Account different from the Account you specified has been entered.

 

Your Request format will work correctly.
I posted the following Request to /v1/object/payment and it processed without error:

Request:

{
    "AccountId": "2c92c0f85e1d50d8015e1ebe3e731980",
    "InvoiceId": "2c92c094601fa1e701602ec3ee2717b1",
    "amount": 1000,
    "AppliedInvoiceAmount": 1000,
    "EffectiveDate": "2017-12-07",
    "type": "Electronic",
    "PaymentMethodId": "2c92c0f95fc912e3015fdc835316789a",
    "gateway": "135e52f9a710b6c0014a7895947e11cd",
    "Status": "Processed",
    "Type": "Electronic"
}

Response:

{
    "Success": true,
    "Id": "2c92c0f8601fab5701602f904d2b6110"
}

 

And I tried to set Id of another payment method that this account does not have
(Before trying, I deleted the Payment object created by the above Request):
I recieved the same result as the error you got.

Request:

{
    "AccountId": "2c92c0f85e1d50d8015e1ebe3e731980",
    "InvoiceId": "2c92c094601fa1e701602ec3ee2717b1",
    "amount": 1000,
    "AppliedInvoiceAmount": 1000,
    "EffectiveDate": "2017-12-07",
    "type": "Electronic",
    "PaymentMethodId": "2c92c0f95fc912e3015fdc835316789a",
    "gateway": "135e52f9a710b6c0014a7895947e11cd",
    "Status": "Processed",
    "Type": "Electronic"
}

Response:

{
    "Errors": [
        {
            "Code": "INVALID_VALUE",
            "Message": "Electronic payment and electronic method should be in the same account."
        }
    ],
    "Success": false
}

 

Incidentally, putting invalid values as PaymentMethodId resulted in this error.

Request:

{
    "AccountId": "2c92c0f85e1d50d8015e1ebe3e731980",
    "InvoiceId": "2c92c094601fa1e701602ec3ee2717b1",
    "amount": 1000,
    "AppliedInvoiceAmount": 1000,
    "EffectiveDate": "2017-12-07",
    "type": "Electronic",
    "PaymentMethodId": "dummy",
    "gateway": "135e52f9a710b6c0014a7895947e11cd",
    "Status": "Processed",
    "Type": "Electronic"
}

Response:

{
    "Errors": [
        {
            "Code": "INVALID_VALUE",
            "Message": "Invalid value for field PaymentMethodId: dummy"
        }
    ],
    "Success": false
}

 

Searching for the relationship between the Payment Method ID you received from the posted payment page and the AccountId you specified for the Request will be a clue to your problem resolution.

appfly Student

Student

Student
Posts: 2
Registered: Wednesday

Re: How to apply a payment to an invoice

I undestand now the Payment Method ID taken from the hosted payment page needs to be assigned to an account before it can be utilised. I've used the parameter 'field_accountId' for the hosted payment page javascript initialisation and this has helped too.

 

Many thanks for your assistance