Complete a Reseller's Payment from the Account balance
The Complete the Payment from Balance method is used for completing a Payment of the current Reseller or any of its downstream Resellers from the Account balance. Only Payments in the Waiting for payment status can be completed using this method.
The Manager's API token specified in an API request determines the current Reseller and downstream Resellers accessible within a method.
Top-up Payments cannot be completed from the Account balance.
PATCH {base_url}/api/v3/resellers/{reseller_id}/payments/{payment_id}
{
"data":
{
"attributes":
{
"status": "paid_from_balance"
}
}
}
Arguments
Name | Parameter Type | Data type | Required/ Optional | Description |
---|---|---|---|---|
X-Api-Token | header | string | Required | API token of a Manager that performs the operation (see Viewing and updating manager's information) |
Content-Type | header | string | Required | Media type of the request. Specify the following: application/vnd.api+json |
Accept | header | string | Required | Supported media types of the answer. Specify the following: application/vnd.api+json |
base_url | path | string | Required | ActivePlatform URL |
reseller_id | path | number | Required | ID of the current Reseller or any of its downstream Resellers (see Viewing and updating reseller general information) |
payment_id | path | number | Required | Payment ID |
Response model
If a Payment is successfully completed, the method returns information about the Payment (see Get the Reseller's Payment information by ID without included additional information).
Request example
PATCH /api/v3/resellers/1/payments/6485
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+json
{
"data":
{
"attributes":
{
"status": "paid_from_balance"
}
}
}
Response example
If a Payment is successfully completed, the method returns information about the Payment.
{
"data": {
"id": "6485",
"type": "payments",
"attributes": {
"created_at": "2019-11-01T09:50:47.020146+0300",
"updated_at": "2019-11-01T09:51:06.281534+0300",
"account_id": 505,
"discount_amount": "0.0",
"total": "21.0",
"comment": "Payment for order 8149",
"status": "paid_from_balance",
"document_id": "2005268",
"expiration_date": null,
"payment_method_id": null,
"requester_ip": "10.0.0.203",
"manager_id": null,
"purpose": "",
"payment_method_name": null,
"closed_at": "2019-11-01T09:51:06.281534+0300"
},
"relationships": {
"orders": {
"data": [
{
"id": "8149",
"type": "sales_orders"
}
]
},
"invoices": {
"data": []
},
"reseller": {
"data": {
"id": "1",
"type": "resellers"
}
},
"account": {
"data": {
"id": "505",
"type": "accounts"
}
},
"payment_method": {
"data": null
}
}
}
}
In case of error, the method returns the error description. For example:
- If the Account balance has not enough funds for completing a Payment:
{
"errors": {
"title": "The payment cannot be completed due to absence of enough amount of money on balance.",
"status": "422"
}
}
- If a Payment is already completed:
{
"errors": {
"title": "This payment cannot be completed by balance.",
"status": "422"
}
}
- For Payments in any statuses but Waiting from payment:
{
"errors": {
"title": "Only payments with /"waiting for payment/" status can be completed",
"status": "422"
}
}
- For top-up Payments:
{
"errors": {
"title": "Topup payment cannot be completed by balance.",
"status": "422"
}
}