我正在使用在这里找到的PayPal PHP:https://github.com/paypal/Checkout-PHP-SDK
我对如何完成这一进程感到有些困惑。
从一开始,这似乎相当简单:
设置您的credentials
即http://example.com/pay/complete/paypal?token=8UK32254ES097084V&PayerID=SEQNPLB2JR9LY
这就是事情变得有点混乱的地方。
方便地,返回一个令牌和一个PayerID。
根据文档,您现在需要“捕获订单”,并提供了以下代码:
use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
// Here, OrdersCaptureRequest() creates a POST request to /v2/checkout/orders
// $response->result->id gives the orderId of the order created above
$request = new OrdersCaptureRequest("APPROVED-ORDER-ID");
$request->prefer('return=representation');
try {
// Call API with your client and get a response for your call
$response = $client->execute($request);
// If call returns body in response, you can get the deserialized version from the result attribute of the response
print_r($response);
}catch (HttpException $ex) {
echo $ex->statusCode;
print_r($ex->getMessage());
}令人困惑的是,OrdersCaptureRequest需要一个“已批准的订单ID”。
但是返回的只是一个“令牌”和一个"PayerID“。
所以我的问题是,这是什么批准的订单ID,我在哪里得到它?
谢谢!
发布于 2020-07-08 22:20:21
这是什么被批准的订单ID,我从哪里得到的?
在那一刻,来源于token=。它应该对应于在对步骤2的响应(“创建订单”)中收到的订单Id。
对于步骤3,最好不使用任何重定向。相反,实现这个前端用户界面,它提供了一种非常好的上下文体验,使您的站点在后台加载:https://developer.paypal.com/demo/checkout/#/pattern/server。
一个现代化的网站没有理由不必要地重定向。
https://stackoverflow.com/questions/62804424
复制相似问题