gpt4 book ai didi

php - 如何在服务器端执行 future 付款

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

我已经完成了关于此 link 的第一个和两个步骤并进行第 3 步“使用您的后端服务器调用支付 API。”

对于第 3 步,我有access_tokencorelation idamount

我在 curl 中找到了以下步骤 3 的代码。因此,我已将以下 curl 命令转换为 PHP 代码,对此我有两个问题:

1)是否转换正确?

2) 如果是,那么从 PayPal 获取空白页面响应可能是什么问题?

curl 代码:

curl 'https://api.paypal.com/v1/payments/authorization/4TD55050SV609544L/capture' \
-H "Content-Type: application/json" \
-H "Paypal-Application-Correlation-Id: c2edbd6e97b14ff2b19ddb8eec9d264c" \
-H "Authorization: Bearer WfXdnxmyJtdF4q59ofxuQuAAk6eEV-Njm6puht3Nk3w" \
-d '{
"amount":{
"currency":"USD",
"total":"1.50"
},
"is_final_capture":true
}'

这是我在上述代码的基础上根据我的理解尝试的:

static public function executePayment2( $refresh_token, $correlation_id, $fee_amount )
{
$data = array(
"amount" => array(
"currency" => "USD",
"total" => $fee_amount
),
"is_final_capture" => "true"
);

$data_string = json_encode($data);
$ch = curl_init( "https://api.paypal.com/v1/payments/authorization/4TD55050SV609544L/capture" );

curl_setopt_array( $ch, array(
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string),
'Authorization: Bearer ' . $refresh_token, //Need to set $refresh_token
'Paypal-Application-Correlation-Id: ' . $correlation_id //Need to set $correlation_id
),
CURLOPT_POSTFIELDS => $data_string,
CURLOPT_RETURNTRANSFER => true
)
);

$result = curl_exec( $ch ); //Make it all happen and store response
}

最佳答案

当您将您的移动应用程序与 PayPal Mobile SDK 2.0 集成时,您的客户可以允许在未来多次付款而无需登录他们的 PayPal 帐户。支持 PayPal 付款(非信用卡)。基本...

关于php - 如何在服务器端执行 future 付款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24380799/

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