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.

Re: How to apply a payment to an invoice

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:

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.

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.