Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Add-ons >

I am facing bad request error while making put request for Payment in Api previewer

Started by Kapil Guleria -   in Add-ons

Hi
While making put request for Payments in API preview , I am facing bad request error. I want to have payments in my Php wrapper as its not in the Code sample of PHP. Please provide steps to resolve this.
Please reply soon.

Regards
Kapil Guleria
Hi Kapil,

To make a payment to an invoice, you need to provide an existing invoice id and the account code from which you want to make the payment. It is just like posting any other XML. Please refer : Payments Endpoint

 

Samitha N (Xero Staff)  

I am not sure about the account code where do I get this.
 

Kapil Guleria  

Hi Kapil,

To understand how payments work, do it via XeroUI by creating an invoice and add payments to it, in which case you have to select a bank account or any payments enabled account to make payments from.

To make a payment via API, please refer the link I sent before to find the required elements for a payment. Please follow the steps:

1. Create an invoice and store the invoiceID
2. Get the ID or Code of a bank account or any other payments enabled account using a GET on Accounts Endpoint

Use the above in the sample XML for PUT payments given in Payments

Hope this is clear enough to resolve your issue.
 

Samitha N (Xero Staff)  

Hi Sam
Thanks, I am able to create an Sale account in Xero Api Priviewer, and also set it as Paymentenabled, but while using this AccountID as I am facing error as listed below

Error: 10 ValidationException A validation exception occurred Payments can only be made against Authorised documents 2014-05-15T00:00:00 15.00 3833f51b-8d20-4731-8378-c52d5b8d8b9f 611110 TestPayements15 ACTIVE REVENUE OUTPUT REVENUE true false REV 28cd32cd-4268-46c4-bb9a-f34debaf5121 Kapil test 2014-04-17T00:00:00 2014-04-24T00:00:00 DRAFT Exclusive Monthly rental for property at 56a Wilkins Avenue 395.00 OUTPUT 0.00 1714.30 200 4.3400 1714.30 0.00 1714.30 2014-04-17T05:58:06.467 INR ACCREC 721baba5-32e2-49a6-8524-16f59c514e88 111 1714.30 0.00 false 1.000000

can you please let me know how to fix this.
 

Kapil Guleria  

Hi Kapil,

That error indicates your invoice status is not AUTHORISED. To make a payment against invoice, it must be of AUTHORISED status. I think your invoice is still a DRAFT.
 

Samitha N (Xero Staff)  

Hi Sam ,

When i create an invoice and try to add item code. It gives error - Invalid item code '65'.
But when i add an item code in inventory in my account(manually) and create an invoice again then it creates invoice successfully.
So how can i add item code dynamically ?

In the same way - To create a payment - there must be an account code and it must be enabled -
Steps :-
1. Go to Settings > Chart of Accounts.
2. Click the account you wish to enable payments to.
3. Check the box for Enable payments to this account.


How can i make an account dynamically enabled ?

Thanks
Anuj Dhiman
 

Anuj Dhiman  

how can i change invoice status from paid to anything else using xml.

i want to refund full amount of paid invoice but its give me error like " Invoice not of valid status for modification";
 

Drashti Patel