脚本宝典收集整理的这篇文章主要介绍了使用PHP中的REST API进行Paypal付款,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
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://<return URL here>","cancel_url":"http://<cancel URL here>" },"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,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); }
$data = '{ "intent":"sale","description":"This is the payment transaction description." } ] }'; curl_setopt($ch,"https://api.sandBox.paypal.com/v1/payments/payment"); curl_setopt($ch,$data); curl_setopt($ch,CURLOPT_HTTPHEADER,array( "Content-Type: application/json","Authorization: Bearer EOjEJigcsRhdOgD7_76lPfrr45UfuI43zzNzTktUk1MK","Content-length: ".strlen($data)) );
看看这里的选项,http://php.net/manual/en/function.curl-setopt.php设置curl_setopt($ch,false);例如,如果您不需要返回标头.
以上是脚本宝典为你收集整理的使用PHP中的REST API进行Paypal付款全部内容,希望文章能够帮你解决使用PHP中的REST API进行Paypal付款所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。