关于交易,有两个步骤很重要。第一步是授权。
使用您在此处添加的代码在前端完成授权。用户可以篡改金额,但这只是预订,不会从付款人信用卡中取款。
第二步称为捕获。您只能从 Paylike 仪表板或通过您的服务器获取资金。当您这样做时,您通常会发送与您最初希望用户支付的金额相同的金额,如果授权较少,您会收到错误消息。例如,如果您想拒绝订单,您还可以获取交易以检查授权金额。您还可以发送一个自定义参数,用于在服务器上进行验证,如果您愿意,类似于校验和。
您有一个私钥,用户无法获得该私钥,这样可以保证安全。两步法本身就是一种验证,但正如我所提到的,您也可以检查交易。
您可以在此处查看 API 文档:https://github.com/paylike/api-docs,您还可以在其中找到指向客户端 SDK 的链接。
如果你使用 PHP,使用 PHP 库(我维护)你可以这样做来检查交易:
$paylike = new \Paylike\Paylike($private_api_key);
$transactions = $paylike->transactions();
$transaction = $transactions->fetch($transaction_id);
事务变量将如下所示:
{
"id":"5da8272132aad2256xxxxxxx",
"test":true,
"merchantId":"594d3c455be12d547xxxxxx",
"created":"2019-10-17T08:32:34.362Z",
"amount":35,
"refundedAmount":0,
"capturedAmount":0,
"voidedAmount":0,
"pendingAmount":35,
"disputedAmount":0,
"card":{
"id":"5da82743735e61604xxxxxxx",
"bin":"410000",
"last4":"0000",
"expiry":"2023-11-30T22:59:59.999Z",
"code":{
"present":true
},
"scheme":"visa"
},
"tds":"none",
"currency":"JPY",
"custom":{
"email":"customer@example.com",
"orderId":"Could not be determined at this point",
"products":[
[
{
"ID":"48",
"name":"Hoodie with Pocket",
"quantity":"1"
}
]
],
"customer":{
"name":"John Doe",
"email":"customer@example.com",
"phoneNo":"020 91X XXXX",
"address":"123 Main Street, New York, NY 10030",
"IP":"10.0.2.2"
},
"platform":{
"name":"WordPress",
"version":"5.2.4"
},
"ecommerce":{
"name":"WooCommerce",
"version":"3.7.1"
},
"paylikePluginVersion":"1.7.2"
},
"recurring":false,
"successful":true,
"error":false,
"descriptor":"PHP API WRAPPER TEST",
"trail":[
]
}