Kelvin Lacy Posted January 4, 2022 Share Posted January 4, 2022 I can't find any examples of how specifically to code the call. My first refund attempt seems to be raising an odd error. The allocated artefact is an on account payment id. Can you point me at a good example or suggest what might be wrong? Thank you 2022-01-04 09:41:13: Array ( [contact_payment] => Array ( [transaction_type_id] => CUSTOMER_REFUND [payment_method_id] => ELECTRONIC [contact_id] => ffaa7373274f05114c419a72bab3dba6 [bank_account_id] => ffaab5139b12f1be428d8effc53a3104 [date] => 2022-01-03 [reference] => ZZZ0281 [total_amount] => 130.00 [allocated_artefacts] => Array ( [0] => Array ( [artefact_id] => 6088be58e9a34db286cbb1429acbcfff [amount] => 130.00 ) ) ) ) 2022-01-04 09:41:14: Refund creation failed: error code 422 2022-01-04 09:41:14: result array Array ( [0] => stdClass Object ( [$severity] => error [$dataCode] => RecordInvalid [$message] => You can only pay unpaid or part-paid invoices. [$source] => base ) ) Link to comment Share on other sites More sharing options...
Steel, Mark Posted January 4, 2022 Share Posted January 4, 2022 Hi Kelvin, thank you for your question. CUSTOMER_REFUND can be allocated only to sales_credit_notes and payments on account with an outstanding amount. The message returned for your request seems to suggest the payment on account has already been allocated. When allocating against a payment on account you need to ensure you set the allocated_artefacts artefact_id with the payment_on_account_id and not the artefact_id or transaction_id.Payment On Account Example - Note the payment_on_account_id and outstanding_amount { "id": "37ba1d6d75754ddeadce2bb91228f6e5", "displayed_as": "Test PA", "$path": "/contact_payments/37ba1d6d75754ddeadce2bb91228f6e5", "created_at": "2022-01-04T15:15:43Z", "updated_at": "2022-01-04T15:15:43Z", "links": [ { "href": "https://accounts-extra.sageone.com/advanced_uk/customer_income_payments/360381886", "rel": "alternate", "type": "text/html" } ], "transaction": { "id": "c3b64ecb82bc46f489236b1475bf658f", "displayed_as": "Test PA", "$path": "/transactions/c3b64ecb82bc46f489236b1475bf658f" }, "transaction_type": { "id": "CUSTOMER_RECEIPT", "displayed_as": "Customer Receipt", "$path": "/transaction_types/CUSTOMER_RECEIPT" }, "payment_method": { "id": "CREDIT_DEBIT", "displayed_as": "Credit/Debit Card", "$path": "/payment_methods/CREDIT_DEBIT" }, "contact": { "id": "7c2ae4b1747c481cb8d217011556d19e", "displayed_as": "ABS Garages Ltd (ABS001)", "$path": "/contacts/7c2ae4b1747c481cb8d217011556d19e" }, "bank_account": { "id": "e1284829c0624845bb68efce77dbf2ca", "displayed_as": "Bank Account (1200)", "$path": "/bank_accounts/e1284829c0624845bb68efce77dbf2ca" }, "date": "2022-01-04", "net_amount": "0.0", "tax_amount": "0.0", "total_amount": "10.0", "currency": { "id": "GBP", "displayed_as": "Pound Sterling (GBP)", "$path": "/currencies/GBP" }, "exchange_rate": "1.0", "base_currency_net_amount": "0.0", "base_currency_tax_amount": "0.0", "base_currency_total_amount": "10.0", "base_currency_currency_charge": "0.0", "reference": "Test PA", "allocated_artefacts": [], "tax_rate": null, "payment_on_account": { "id": "95c194e7f6084d2eb38f167100b25c70", "displayed_as": "Test PA", "$path": "/contact_payments/37ba1d6d75754ddeadce2bb91228f6e5", "created_at": "2022-01-04T15:15:43Z", "updated_at": "2022-01-04T15:15:43Z", "contact_name": "ABS Garages Ltd", "contact_reference": "ABS001", "contact": { "id": "7c2ae4b1747c481cb8d217011556d19e", "displayed_as": "ABS Garages Ltd (ABS001)", "$path": "/contacts/7c2ae4b1747c481cb8d217011556d19e" }, "date": "2022-01-04", "reference": "Test PA", "net_amount": "10.0", "tax_amount": "0.0", "total_amount": "10.0", "outstanding_amount": "10.0", "currency": { "id": "GBP", "displayed_as": "Pound Sterling (GBP)", "$path": "/currencies/GBP" }, "exchange_rate": "1.0", "base_currency_net_amount": "10.0", "base_currency_tax_amount": "0.0", "base_currency_total_amount": "10.0", "base_currency_outstanding_amount": "10.0", "status": { "id": "UNPAID", "displayed_as": "Unpaid", "$path": "/artefact_statuses/UNPAID" } }, "editable": true Working JSON POST request { "contact_payment": { "transaction_type_id": "CUSTOMER_REFUND", "payment_method_id": "CREDIT_DEBIT", "contact_id": "7c2ae4b1747c481cb8d217011556d19e", "bank_account_id": "e1284829c0624845bb68efce77dbf2ca", "date": "2022-12-04", "total_amount": "10.00", "allocated_artefacts": [ { "artefact_id": "95c194e7f6084d2eb38f167100b25c70", "amount": "10.00" } ] } } Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now