php 怎么使用api付款,使用PHP中的REST API进行Paypal付款

我不清楚如何将此代码示例放入

PHP的CURL结构中,特别是-d句柄.

curl -v https://api.sandbox.paypal.com/v1/payments/payment \

-H 'Content-Type:application/json' \

-H 'Authorization:Bearer EOjEJigcsRhdOgD7_76lPfrr45UfuI43zzNzTktUk1MK' \

-d '{

"intent":"sale",

"redirect_urls":{

"return_url":"http://",

"cancel_url":"http://"

},

"payer":{

"payment_method":"paypal"

},

"transactions":[

{

"amount":{

"total":"7.47",

"currency":"USD"

},

"description":"This is the payment transaction description."

}

]

}'

我已经使用了以下测试调用,但不知道如何将其扩展到上面的示例.

curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token");

curl_setopt($ch, CURLOPT_HEADER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_USERPWD, $clientId.":".$secret);

curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");

$result = curl_exec($ch);

if(empty($result))die("Error: No response.");

else

{

$json = json_decode($result);

print_r($json->access_token);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值