发起新的支付交易。
{{base_url}}
/payment/create
范围 | 类型 | 细节 |
---|---|---|
amount | decimal | 您的金额必须四舍五入到2位精度。 |
currency | string | 货币代码,必须大写(Alpha-3 代码) |
return_url: | string | 输入您的返回或成功 URL |
cancel_url: | string (optional) | 输入您的取消或失败的 URL |
custom: | string (optional) | 交易 ID,可用于您的项目交易 |
Request Example (guzzle)
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', '{{base_url}}/payment/create', [
'json' => [
'amount' => '100.00',
'currency' => 'USD',
'return_url' => 'www.example.com/success',
'cancel_url' => 'www.example.com/cancel',
'custom' => '123456789ABCD',
],
'headers' => [
'Authorization' => 'Bearer {{access_token}}',
'accept' => 'application/json',
'content-type' => 'application/json',
],
]);
echo $response->getBody();
**Response: SUCCESS (200 OK)**
{
"message": {
"code": 200,
"success": [
"CREATED"
]
},
"data": {
"token": "2zMRmT3KeYT2BWMAyGhqEfuw4tOYOfGXKeyKqehZ8mF1E35hMwE69gPpyo3e",
"payment_url": "www.example.com/pay/sandbox/v1/user/authentication/form/2zMRmT3KeYT2BWMAyGhqEfuw4tOYOfGXKeyKqehZ8mF1E35hMwE69gPpyo3e",
},
"type": "success"
}
**Response: ERROR (403 FAILED)**
{
"message": {
"code": 403,
"error": [
"Requested with invalid token!"
]
},
"data": [],
"type": "error"
}