Paypal REST API - 在RedirectUrls中发送GET标题()

时间:2016-02-05 04:23:09

标签: php api paypal paypal-rest-sdk http-status-code-400

在Paypal付款完成后,我尝试将某人为我的应用中的商品付款的价格发送到我的重定向网址。

//Redirect
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL . '/paypal/pay.php?sucess=true&paid={$price}')
    ->setCancelUrl(SITE_URL . '/paypal/pay.php?sucess=false');

变量&paid={$price}应该将商品的价格发送到网址,但我收到400错误:

  

例外' PayPal \ Exception \ PayPalConnectionException'在访问https://api.sandbox.paypal.com/v1/payments/payment时收到消息'获得Http响应代码400。'在/home1//public_html/Clients/rust/paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:174堆栈跟踪:#0 / home1 / /public_html/Clients/rust/paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php(74):PayPal \ Core \ PayPalHttpConnection->执行(' { "意图":"销售......')#1 / home1 / / public_html /客户/生锈/ paypal / vendor / paypal / rest-api-sdk-php /lib/PayPal/Common/PayPalResourceModel.php(102):PayPal \ Transport \ PayPalRestCall->执行(数组,' / v1 / payments / pa ...',' POST&# 39;,' {"意图":"销售......',空白)#2 / home1 / / public_html /客户/生锈/ paypal / vendor / paypal / rest-api-sdk-php / lib / PayPal / Api / Payment.php(579):PayPal \ Common \ PayPalResourceModel :: executeCall(' / v1 / payments / pa ...&#39 ;,' POST',' {" intent":" sale ...',NULL,Object(PayPal \ Rest \ ApiContext),NULL )#3 /home1/*/public_html/Clients/rust/paypal/checkout.php(69):PayPal \ Api \ Payment->创建(对象(PayPal \ Rest \ ApiContext))#4 {main}

如果我从重定向中删除变量,一切都能正常工作 任何想法为什么这不起作用?

1 个答案:

答案 0 :(得分:-1)

删除花括号并使用双引号(“):

//Redirect
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL . "/paypal/pay.php?success=true&paid=$price")
->setCancelUrl(SITE_URL . '/paypal/pay.php?success=false');

*成功有两个'c'。