The Complete payment by ID method is used for completing a payment by its ID for the current reseller or any of its downstream resellers, for example, when it was paid in a third-party system. Only payments in the Waiting for payment and Expired statuses can be completed.
You can also complete a payment by its number document_id (see Complete payment by document ID).
XML
PATCH {base_url}/api/v3/resellers/{reseller_id}/payments/{payment_id}
JSON
{
"data":
{
"attributes":
{
"payment_method_id": {payment_method_id}
}
}
}
Arguments
Response model
If no errors are encountered, the method returns information about the completed payment (see Get payment without the included parameter).
Request example
XML
PATCH /api/v3/resellers/1/payments/6475
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+json
JSON
{
"data":
{
"attributes":
{
"payment_method_id": 2
}
}
}
Response example
JSON
{
"data": {
"id": "6475",
"type": "payments",
"attributes": {
"created_at": "2019-11-01T04:30:47.797788+0300",
"updated_at": "2019-11-01T04:34:42.986099+0300",
"account_id": 505,
"discount_amount": "0.0",
"total": "99.0",
"amount_paid_from_balance": null,
"initial_total": "99.0",
"currency_code": "USD",
"comment": "cash",
"status": "completed",
"document_id": "2005258",
"expiration_date": null,
"payment_method_id": 2,
"requester_ip": "10.0.0.203",
"manager_id": 234,
"purpose": "",
"external_total": null,
"external_currency": null,
"due_date": null,
"payment_method_name": "Cash",
"closed_at": "2019-11-01T04:34:42.986099+0300"
},
"relationships": {
"orders": {
"data": []
},
"invoices": {
"data": []
},
"corrections": {
"data": []
},
"reseller": {
"data": {
"id": "1",
"type": "resellers"
}
},
"account": {
"data": {
"id": "505",
"type": "accounts"
}
},
"payment_method": {
"data": {
"id": "2",
"type": "payment_methods"
}
}
}
}
}
Errors
In case of error, the method returns the error description. For example, for error 422:
JSON
{
"errors": {
"title": "Only payments with \"waiting for payment/expired\" status can be completed.",
"status": "422"
}
}