This endpoint is useful for generating unique payment URLs. You can use this to accept payments from anyone registered with ZexPay.io.
POSThttps://zexpay.io/api/v1/merchant/| Name | Required | Type | Info |
|---|---|---|---|
| item_desc | Yes | String | Description of the item being sold. |
| amount | Yes | float | Amount with float number based on main crypto, maximal 8 decimal. (e.g, 0.00150000). |
| crypto_1 | Yes | String | The main crypto in your payment form. (e.g, BTC, ETH, USDT). |
| crypto_2 | No | String | The crypto to enforce the buyer to pay with. If blank, the user chooses themselves by supported crypto on merchant dashboard. |
| custom_id | No | String | An identifier passed to the webhook URL. Can be used to identify unique IDs such as IDs (User, transaction, or order). |
| webhook_url | No | String | If paid successfully, this url will be called immediately by passing all the data. |
| paid_url | No | String | If paid successfully, buyer will redirected immediately to this url. |
| cancel_url | No | String | A URL where you want to redirect the buyer if they cancel. |
Example<?php $api_key = 'YOUR_MERCHANT_API_KEY'; $url = 'https://zexpay.io/api/v1/merchant/'; $data = [ "item_desc" => 'Bill #15', "amount" => 815, "crypto_1" => 'USDT', "crypto_2" => 'BTC', "custom_id" => 15, "webhook_url" => 'https://mycrypto.store/pay/webhook/', "paid_url" => 'https://mycrypto.store/pay/paid/', "cancel_url" => 'https://mycrypto.store/pay/cancel/' ]; $e_data = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $e_data); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'api-key: '.$api_key ]); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $response = curl_exec($ch); $result = json_decode($response, true); var_dump($result); ?>
These example code snippets demonstrate how to request the "Receive Payment" endpoint using PHP cURL. You can customize the data parameters according to your specific requirements. And below is the response you will receive:
Success Response{ "status" : 200, "error" : false, "message" : "ok", "data" : { "pay_url" : "https://zexpay.io/merchant/?pay=UNIQUE_PAYMENT_CODE" } }
Below is a list of status from this endpoint. This can be a validation material for your website:
| Status | Error | Data | Message |
|---|---|---|---|
| 200 | false | Object | The request was processed without errors. |
| 400 | true | null | Required fields is missing or Unacceptable parameter values. |
| 401 | true | null | Invalid / missing API Key. |
| 405 | true | null | Method not allowed, or Merchant not recognized. |
| 500 | true | null | Internal server error. |
Error Response{ "status" : 405, "error" : true, "message" : "Merchant not recognized.", "data" : null }
