简体   繁体   English

贝宝支付REST API执行过程

[英]Paypal payment REST API execute process using guzzle

I want to ask about paypal REST execute process. 我想问一下关于贝宝REST执行过程。 As defined in the documentation, 根据文档中的定义,

curl -v https://api.sandbox.paypal.com/v1/payments/payment/payment_id/execute/ \\
  -H "Content-Type:application/json" \\
  -H "Authorization: Bearer Access-Token" \\
  -d '{
  "payer_id": "payer_id"
}'

the code is for curl version which I want to change to guzzle version but am bit confused about "Authorization: Bearer Access-Token" 该代码适用于curl版本,我想更改为guzzle版本,但对“授权:承载访问令牌”感到有些困惑

Is "Authorization: Bearer Access-Token" is placed on header config like "Content-Type:application/json" ? 是否在“ Content-Type:application / json”之类的标头配置中放置了“授权:承载访问令牌

Because I always get error 500 from Paypal sandbox server and when I tried to access API Call history page on Paypal sandbox dashboard it always show "Something went wrong fetching sandbox API calls. Try again." 因为我总是从Paypal沙箱服务器收到错误500,并且当我尝试访问Paypal沙箱仪表板上的API调用历史记录页面时,它始终显示“获取沙箱API调用时出错。请重试。”

Yes, currently the best option to implement Bearer authentication is to add a header: 是的,当前实现Bearer身份验证的最佳选择是添加标头:

$response = $client->post(
    'https://api.sandbox.paypal.com/v1/payments/payment/payment_id/execute/',
    [
        'headers' => ['Authorization' => 'Bearer #your_token#'],
        'json' => ['payer_id' => '#your_payer_id#'],
    ]
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM