Skip to content

Instantly share code, notes, and snippets.

@SerKnight
Created August 5, 2020 17:57
Show Gist options
  • Save SerKnight/6d54ec61011509ae4a38915645c6e23f to your computer and use it in GitHub Desktop.
Save SerKnight/6d54ec61011509ae4a38915645c6e23f to your computer and use it in GitHub Desktop.
XeroAPI Batch payments & summarizeErrors
POST https://api.xero.com/api.xro/2.0/Payments?summarizeErrors=false
{
"Payments": [
{
"Invoice": { "InvoiceID": "e081f93b-bdde-417b-b785-2b453c9b3ed3" },
"Account": { "AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2" },
"Date": "2020-08-05",
"Amount": 234303.00
},
{
"Invoice": { "InvoiceID": "7f25c350-953d-4b8e-bd45-1c71addc0579" },
"Account": { "AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2" },
"Date": "2020-08-05",
"Amount": 10803.50
}
]
}
200 OK
{
"Id": "0af97400-3a6f-4b45-abb9-f0bda8907540",
"Status": "OK",
"ProviderName": "Insomnia Client",
"DateTimeUTC": "\/Date(1596649422857)\/",
"Payments": [
{
"Date": "\/Date(1596585600000+0000)\/",
"Amount": 234303.00,
"HasAccount": true,
"Account": {
"AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2",
"Code": "091",
"Name": "Savings Account",
"Status": "ACTIVE",
"Type": "BANK",
"TaxType": "NONE",
"Class": "ASSET",
"EnablePaymentsToAccount": false,
"ShowInExpenseClaims": false,
"BankAccountNumber": "987654321",
"BankAccountType": "BANK",
"CurrencyCode": "USD",
"ReportingCode": "ASS",
"UpdatedDateUTC": "\/Date(1594075144627+0000)\/",
"AddToWatchlist": false
},
"Invoice": {
"Type": "ACCPAY",
"InvoiceID": "e081f93b-bdde-417b-b785-2b453c9b3ed3",
"InvoiceNumber": "GB1-White",
"Reference": "",
"Prepayments": [],
"Overpayments": [],
"AmountDue": 606.00,
"AmountPaid": 234.00,
"SentToContact": false,
"CurrencyRate": 1.000000,
"IsDiscounted": false,
"HasErrors": false,
"Contact": {
"ContactID": "6aca7bad-c92b-4d33-8a1e-acb225dd4d5e",
"Name": "Bayside Wholesale",
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2020-07-01T00:00:00",
"Date": "\/Date(1593561600000+0000)\/",
"DueDateString": "2020-07-12T00:00:00",
"DueDate": "\/Date(1594512000000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "GB1-White",
"Description": "Golf balls - white single",
"UnitAmount": 4.20,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 840.00,
"AccountCode": "500",
"Tracking": [],
"Quantity": 200.0000,
"LineItemID": "cc69f8e6-5a64-4131-a425-acd8f29f12be",
"DiscountEnteredAsPercent": true,
"ValidationErrors": []
}
],
"SubTotal": 840.00,
"TotalTax": 0.00,
"Total": 840.00,
"UpdatedDateUTC": "\/Date(1596649334130+0000)\/",
"CurrencyCode": "USD"
},
"HasValidationErrors": true,
"StatusAttributeString": "ERROR",
"ValidationErrors": [
{
"Message": "Payment amount exceeds the amount outstanding on this document"
}
]
},
{
"Date": "\/Date(1596585600000+0000)\/",
"Amount": 10803.50,
"HasAccount": true,
"Account": {
"AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2",
"Code": "091",
"Name": "Savings Account",
"Status": "ACTIVE",
"Type": "BANK",
"TaxType": "NONE",
"Class": "ASSET",
"EnablePaymentsToAccount": false,
"ShowInExpenseClaims": false,
"BankAccountNumber": "987654321",
"BankAccountType": "BANK",
"CurrencyCode": "USD",
"ReportingCode": "ASS",
"UpdatedDateUTC": "\/Date(1594075144627+0000)\/",
"AddToWatchlist": false
},
"Invoice": {
"Type": "ACCPAY",
"InvoiceID": "7f25c350-953d-4b8e-bd45-1c71addc0579",
"InvoiceNumber": "RPT644-1",
"Reference": "",
"Prepayments": [],
"Overpayments": [],
"AmountDue": 0.10,
"AmountPaid": 108.50,
"SentToContact": false,
"CurrencyRate": 1.000000,
"IsDiscounted": false,
"HasErrors": false,
"RepeatingInvoiceID": "cc34c95b-2e26-4522-9b04-81d102cd929c",
"Contact": {
"ContactID": "ac565f9c-9829-4f51-8a5b-0400de972b3c",
"Name": "PowerDirect",
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2020-06-27T00:00:00",
"Date": "\/Date(1593216000000+0000)\/",
"DueDateString": "2020-07-07T00:00:00",
"DueDate": "\/Date(1594080000000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "NoTax",
"LineItems": [
{
"Description": "Monthly electricity",
"UnitAmount": 108.60,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 108.60,
"AccountCode": "644",
"Tracking": [],
"Quantity": 1.0000,
"LineItemID": "c59dc825-d1b3-41a8-aa16-0d6f70576ac7",
"DiscountEnteredAsPercent": true,
"ValidationErrors": []
}
],
"SubTotal": 108.60,
"TotalTax": 0.00,
"Total": 108.60,
"UpdatedDateUTC": "\/Date(1596649334223+0000)\/",
"CurrencyCode": "USD"
},
"HasValidationErrors": true,
"StatusAttributeString": "ERROR",
"ValidationErrors": [
{
"Message": "Payment amount exceeds the amount outstanding on this document"
}
]
}
]
}
POST https://api.xero.com/api.xro/2.0/Payments?summarizeErrors=true
{
"Payments": [
{
"Invoice": { "InvoiceID": "e081f93b-bdde-417b-b785-2b453c9b3ed3" },
"Account": { "AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2" },
"Date": "2020-08-05",
"Amount": 234303.00
},
{
"Invoice": { "InvoiceID": "7f25c350-953d-4b8e-bd45-1c71addc0579" },
"Account": { "AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2" },
"Date": "2020-08-05",
"Amount": 10803.50
}
]
}
400 Bad Request
{
"ErrorNumber": 10,
"Type": "ValidationException",
"Message": "A validation exception occurred",
"Elements": [
{
"Date": "\/Date(1596585600000+0000)\/",
"Amount": 234303.00,
"HasAccount": true,
"Account": {
"AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2",
"Code": "091",
"Name": "Savings Account",
"Status": "ACTIVE",
"Type": "BANK",
"TaxType": "NONE",
"Class": "ASSET",
"EnablePaymentsToAccount": false,
"ShowInExpenseClaims": false,
"BankAccountNumber": "987654321",
"BankAccountType": "BANK",
"CurrencyCode": "USD",
"ReportingCode": "ASS",
"UpdatedDateUTC": "\/Date(1594075144627+0000)\/",
"AddToWatchlist": false
},
"Invoice": {
"Type": "ACCPAY",
"InvoiceID": "e081f93b-bdde-417b-b785-2b453c9b3ed3",
"InvoiceNumber": "GB1-White",
"Reference": "",
"Prepayments": [],
"Overpayments": [],
"AmountDue": 606.00,
"AmountPaid": 234.00,
"SentToContact": false,
"CurrencyRate": 1.000000,
"IsDiscounted": false,
"HasErrors": false,
"Contact": {
"ContactID": "6aca7bad-c92b-4d33-8a1e-acb225dd4d5e",
"Name": "Bayside Wholesale",
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2020-07-01T00:00:00",
"Date": "\/Date(1593561600000+0000)\/",
"DueDateString": "2020-07-12T00:00:00",
"DueDate": "\/Date(1594512000000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "GB1-White",
"Description": "Golf balls - white single",
"UnitAmount": 4.20,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 840.00,
"AccountCode": "500",
"Tracking": [],
"Quantity": 200.0000,
"LineItemID": "cc69f8e6-5a64-4131-a425-acd8f29f12be",
"DiscountEnteredAsPercent": true,
"ValidationErrors": []
}
],
"SubTotal": 840.00,
"TotalTax": 0.00,
"Total": 840.00,
"UpdatedDateUTC": "\/Date(1596649334130+0000)\/",
"CurrencyCode": "USD"
},
"HasValidationErrors": true,
"ValidationErrors": [
{
"Message": "Payment amount exceeds the amount outstanding on this document"
}
]
},
{
"Date": "\/Date(1596585600000+0000)\/",
"Amount": 10803.50,
"HasAccount": true,
"Account": {
"AccountID": "3d09fd49-434d-4c18-a57b-831663ab70d2",
"Code": "091",
"Name": "Savings Account",
"Status": "ACTIVE",
"Type": "BANK",
"TaxType": "NONE",
"Class": "ASSET",
"EnablePaymentsToAccount": false,
"ShowInExpenseClaims": false,
"BankAccountNumber": "987654321",
"BankAccountType": "BANK",
"CurrencyCode": "USD",
"ReportingCode": "ASS",
"UpdatedDateUTC": "\/Date(1594075144627+0000)\/",
"AddToWatchlist": false
},
"Invoice": {
"Type": "ACCPAY",
"InvoiceID": "7f25c350-953d-4b8e-bd45-1c71addc0579",
"InvoiceNumber": "RPT644-1",
"Reference": "",
"Prepayments": [],
"Overpayments": [],
"AmountDue": 0.10,
"AmountPaid": 108.50,
"SentToContact": false,
"CurrencyRate": 1.000000,
"IsDiscounted": false,
"HasErrors": false,
"RepeatingInvoiceID": "cc34c95b-2e26-4522-9b04-81d102cd929c",
"Contact": {
"ContactID": "ac565f9c-9829-4f51-8a5b-0400de972b3c",
"Name": "PowerDirect",
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2020-06-27T00:00:00",
"Date": "\/Date(1593216000000+0000)\/",
"DueDateString": "2020-07-07T00:00:00",
"DueDate": "\/Date(1594080000000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "NoTax",
"LineItems": [
{
"Description": "Monthly electricity",
"UnitAmount": 108.60,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 108.60,
"AccountCode": "644",
"Tracking": [],
"Quantity": 1.0000,
"LineItemID": "c59dc825-d1b3-41a8-aa16-0d6f70576ac7",
"DiscountEnteredAsPercent": true,
"ValidationErrors": []
}
],
"SubTotal": 108.60,
"TotalTax": 0.00,
"Total": 108.60,
"UpdatedDateUTC": "\/Date(1596649334223+0000)\/",
"CurrencyCode": "USD"
},
"HasValidationErrors": true,
"ValidationErrors": [
{
"Message": "Payment amount exceeds the amount outstanding on this document"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment