2016-02-05 46 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

是的,好點,我忘了改變它們時我複製了原件。 –