MxPay API Docs

Payment Collection

Generate a hosted checkout link for your customer.

POST/api/web

Request Parameters

FieldTypeRequiredDescription
api_keyStringRequiredYour merchant API Key
chidStringRequiredAuthorized Channel ID
amountNumberRequiredTransaction amount
order_idStringRequiredUnique merchant order reference ID
callbackStringRequiredWebhook notification URL
page_urlStringRequiredUser return / success redirect URL
Note: page_url is the URL the customer is redirected to after successful payment confirmation.

Success Response

FieldTypeDescription
statusBooleantrue for success
messageStringSuccess message
payment_linkStringHosted checkout payment URL
orderNoStringMxPay internal platform order reference

Callback Webhook Payload

FieldTypeDescription
statusBooleantrue when transaction is successful
amountNumberProcessed payment amount
platform_idStringMxPay platform transaction ID
order_idStringYour original order ID

Code Example

<?php
$params = [
    'api_key'  => 'YOUR_API_KEY',
    'chid'     => 'CHANNEL_ID',
    'amount'   => 100,
    'order_id' => 'ORDER_12345',
    'callback' => 'https://yourwebsite.com/callback',
    'page_url' => 'https://yourwebsite.com/success',
];

$ch = curl_init("https://mxpay.one/api/web");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    $result = json_decode($response, true);
    if (isset($result['status']) && $result['status'] === true) {
        echo "Payment Link: " . $result['payment_link'];
    } else {
        echo "Error: " . ($result['message'] ?? 'Unknown error');
    }
}
curl_close($ch);
?>