Complete payment by ID

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).

An API token of a manager is required for authorization. To get an API token via the Operator Control Panel, see Viewing and updating manager's information

The manager's API token specified in an API request determines:

  • The role and access level of the manager, which determine the availability of a method.
  • The current reseller and downstream resellers accessible within a method.

PATCH {base_url}/api/v3/resellers/{reseller_id}/payments/{payment_id}
{
    "data":
    {
        "attributes":
        {
            "payment_method_id": {payment_method_id}
        }
    }
}

Arguments

Name

Parameter Type

Data type

Required/ Optional

Description

X-Api-TokenheaderstringRequiredAPI token of a manager that performs the operation (see Viewing and updating manager's information)
Content-TypeheaderstringRequiredMedia type of the request. Specify the following: application/vnd.api+json
AcceptheaderstringRequired

Supported media types of the answer. Specify the following: application/vnd.api+json

base_urlpathstringRequiredActivePlatform URL
reseller_idpathnumberRequiredID of the current reseller or any of its downstream resellers (see Viewing and updating reseller general information)
payment_idpathnumberRequiredPayment ID

payment_method_id

form

number

Required

ID of the payment method to complete the payment (see Viewing the list of payment methods)

Response model

If no errors are encountered, the method returns information about the completed payment (see Get payment without the included parameter).

Request example

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
{
    "data":
    {
        "attributes":
        {
            "payment_method_id": 2
        }
    }
}

Response example

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

{
    "errors": {
        "title": "Only payments with \"waiting for payment/expired\" status can be completed.",
        "status": "422"
    }
}