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. 

Access to the current Reseller and downstream Resellers is determined by the Manager's token in the API request.

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-TokenheaderstringRequiredAPI token of the Manager that performs the operation (see Viewing and updating manager's information)
Content-TypeheaderstringRequiredIndicates the media type (text/html or text/JSON) of the request that is sent to the server by the client (browser)
AcceptheaderstringRequiredInformation about data types that the client (browser) supports
reseller_idpathnumberRequiredID of the current Reseller or any of its downstream Resellers (see Viewing and updating reseller general information)
payment_idpathnumberRequiredPayment 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"
    }
}