gpt4 book ai didi

php - 使用交易 ID 获取交易详情 - Paypal

转载 作者:太空宇宙 更新时间:2023-11-03 15:52:58 25 4
gpt4 key购买 nike

我想做的是验证 Paypal 付款的交易 ID。但是 Paypal 给我回了一个:

{"name":"INVALID_RESOURCE_ID","message":"Requested resource ID was not found.","information_link":"https:\/\/developer.paypal.com\/docs\/api\/payments\/#errors"}

我现在的代码是这样的:

$curl = curl_init("https://api.sandbox.paypal.com/v1/payments/payment/<transaction_id>");
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . '<changed this to my access token>',
'Accept: application/json',
'Content-Type: application/json'
));
$response = curl_exec($curl);
$result = json_decode($response);

最佳答案

您使用了错误的 Paypal API 端点。根据您对要执行的操作的描述,您应该根据文档使用/v1/checkout/orders/因为它为您提供了特定交易的所有详细信息。

这样做:

$curl = curl_init("https://api.sandbox.paypal.com/v1/checkout/orders/<transaction_id>");
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer ' . '<access_token>',
'Accept: application/json',
'Content-Type: application/json'
));
$response = curl_exec($curl);
$result = json_decode($response);

来源:https://developer.paypal.com/docs/api/orders/v1/

关于php - 使用交易 ID 获取交易详情 - Paypal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51303695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com