2016-02-05 48 views
-1

我试图在Paypal付款完成后向我的应用程序中的项目支付我的重定向URL的费用。Paypal REST API - 在RedirectUrls中发送GET头()

//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}应该送过来的项目URL的价格,但我得到一个400错误:

exception 'PayPal\Exception\PayPalConnectionException' with message 'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment .' in /home1//public_html/Clients/rust/paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:174 Stack trace: #0 /home1//public_html/Clients/rust/paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php(74): PayPal\Core\PayPalHttpConnection->execute('{"intent":"sale...') #1 /home1//public_html/Clients/rust/paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php(102): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL) #2 /home1//public_html/Clients/rust/paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(579): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{"intent":"sale...', NULL, Object(PayPal\Rest\ApiContext), NULL) #3 /home1/*/public_html/Clients/rust/paypal/checkout.php(69): PayPal\Api\Payment->create(Object(PayPal\Rest\ApiContext)) #4 {main}

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

+0

需要有人去学习一些基本的PHP ... http://php.net/ manual/en/language.types.string.php#language.types.string.parsing – CBroe

回答

-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的

+0

仍然错......变量解析不会发生在用单引号分隔的字符串中。 – CBroe

+0

是的,好点,我忘了改变它们时我复制了原件。 –