Payment Collection
Generate a hosted checkout link for your customer.
POST
/api/webRequest Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| api_key | String | Required | Your merchant API Key |
| chid | String | Required | Authorized Channel ID |
| amount | Number | Required | Transaction amount |
| order_id | String | Required | Unique merchant order reference ID |
| callback | String | Required | Webhook notification URL |
| page_url | String | Required | User return / success redirect URL |
Note: page_url is the URL the customer is redirected to after successful payment confirmation.
Success Response
| Field | Type | Description |
|---|---|---|
| status | Boolean | true for success |
| message | String | Success message |
| payment_link | String | Hosted checkout payment URL |
| orderNo | String | MxPay internal platform order reference |
Callback Webhook Payload
| Field | Type | Description |
|---|---|---|
| status | Boolean | true when transaction is successful |
| amount | Number | Processed payment amount |
| platform_id | String | MxPay platform transaction ID |
| order_id | String | Your 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);
?>