Complete payment from balance

The Complete 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. Completing partially paid payments (amount_paid_from_balance > 0) and top-up payments using this method is not supported.

Top-up payments cannot be completed from the account balance.

XML
PATCH {base_url}/api/v3/resellers/{reseller_id}/payments/{payment_id}
JSON
{
    "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


)

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 


)

payment_id

path

number

Required

Payment ID

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/6485
Host: test.activeplatform.com
Content-Type: application/vnd.api+json
X-Api-Token: vY5fwetestK3gJXZH5uHCw
Accept: application/vnd.api+json
JSON
{
    "data":
    {
        "attributes":
        {
            "status": "paid_from_balance"
        }
    }
}

Response example

JSON
{
    "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",
            "amount_paid_from_balance": null,
            "initial_total": "21.0",
            "currency_code": "USD",
            "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": "",
            "external_total": null,
            "external_currency": null,
            "due_date": null, 
            "payment_method_name": null,
            "closed_at": "2019-11-01T09:51:06.281534+0300"
        },
        "relationships": {
            "orders": {
                "data": [
                    {
                        "id": "8149",
                        "type": "sales_orders"
                    }
                ]
            },
            "invoices": {
                "data": []
            },
            "corrections": {
                "data": []
            },
            "reseller": {
                "data": {
                    "id": "1",
                    "type": "resellers"
                }
            },
            "account": {
                "data": {
                    "id": "505",
                    "type": "accounts"
                }
            },
            "payment_method": {
                "data": null
            }
        }
    }
}

Errors

In case of error, the method returns the error description. For example:

  • If the account balance has not enough funds for completing a payment:

JSON
{
    "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:

JSON
{
    "errors": {
        "title": "This payment cannot be completed by balance.",
        "status": "422"
    }
}
  • For payments in any statuses except Waiting for payment:

JSON
{
    "errors": {
        "title": "Only payments with /"waiting for payment/" status can be completed",
        "status": "422"
    }
}
  • For top-up payments:

JSON
{
    "errors": {
        "title": "Topup payment cannot be completed by balance.",
        "status": "422"
    }
}