Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Paypal php Rest API;获取Http响应代码404“;重定向错误_Php_Rest_Paypal_Laravel_Paypal Sandbox - Fatal编程技术网

Paypal php Rest API;获取Http响应代码404“;重定向错误

Paypal php Rest API;获取Http响应代码404“;重定向错误,php,rest,paypal,laravel,paypal-sandbox,Php,Rest,Paypal,Laravel,Paypal Sandbox,我使用的是Laravel,代码如下: 创建付款方式 public function create() { $payer = Paypalpayment::Payer(); $payer->setPayment_method("paypal"); $amount = Paypalpayment:: Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00");

我使用的是Laravel,代码如下:

创建付款方式

public function create() {
    $payer = Paypalpayment::Payer();
    $payer->setPayment_method("paypal");

    $amount = Paypalpayment:: Amount();
    $amount->setCurrency("USD");
    $amount->setTotal("1.00");

    $transaction = Paypalpayment:: Transaction();
    $transaction->setAmount($amount);
    $transaction->setDescription("This is the payment description.");

    $redirectUrls = Paypalpayment::RedirectUrls();
    $redirectUrls->setReturnUrl("http://mysite/prova/public/payment/execute")
            ->setCancelUrl("http://mysite/prova/public/payment/problema");

    $payment = Paypalpayment:: Payment();
    $payment->setIntent("sale");
    $payment->setPayer($payer); 
    $payment->setRedirectUrls($redirectUrls);
    $payment->setTransactions(array($transaction));

    try {
        $payment->create($this->_apiContext);
    } catch (PayPal\Exception\PPConnectionException $ex) {
        echo "Exception: " . $ex->getMessage() . PHP_EOL;
        echo "<pre>";
        var_dump($ex->getData());   
        echo "</pre>";
        exit(1);
    }


    foreach($payment->getLinks() as $link) {
        if($link->getRel() == 'approval_url') {
            $redirectUrl = $link->getHref();
            break;
        }
    }

    $_SESSION['paymentId'] = $payment->getId();
    if(isset($redirectUrl)) {
        header("Location: $redirectUrl");
        exit;
    }
}

public function execute() {
    $input = Input::all();

    echo "<pre>";
    print_r($input);
    echo "</pre>";
}
有什么想法吗

--------------------已解决--------------------

问题在于路径,似乎是在url中使用“payment”这个词导致了404错误

改变


问题解决了。。。但我不知道为什么

根据您自己的解决方案判断,您的路由文件中可能有类似的内容:
Route::get('payment/{whatever}',function(){…})它将捕获从付款开始的所有内容

PayPal\Core\PPHttpConnection: Connecting to https://api.sandbox.paypal.com/v1/oauth2/token
PayPal\Core\PPHttpConnection: Payload grant_type=client_credentials
PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.32-358.2.1.el6.x86_64;machine=x86_64;openssl=1.0.1e-fips;curl=7.19.7)
PayPal\Core\PPHttpConnection: Adding header Authorization: Basic QWRvemloQmxyYkNaNFNTOFNnQXczZjBlSHdKaXhSX0p4NkFWTVFVeUdGTUFQX0NnY2JRYm5UWXBDQmY4OkVIdmlkUkM3c2lkYXVaZjA3MnBITXp1Z1J3VHlXaGV3bUtKSFhMaFkzM0ZUWDF4WWc0UWpQbGZoR1hDVw==
PayPal\Core\PPHttpConnection: Adding header Accept: */*
PayPal\Core\PPHttpConnection: Connecting to https://api.sandbox.paypal.com/v1/payments/payment
PayPal\Core\PPHttpConnection: Payload {"intent":"sale","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"http:\/\/mysite\/prova\/public\/payment\/execute","cancel_url":"http:\/\/mysite\/prova\/public\/payment\/problema"},"transactions":[{"amount":{"currency":"USD","total":"1.00"},"description":"This is the payment description."}]}
PayPal\Core\PPHttpConnection: Adding header Content-Type: application/json
PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.32-358.2.1.el6.x86_64;machine=x86_64;openssl=1.0.1e-fips;curl=7.19.7)
PayPal\Core\PPHttpConnection: Adding header Authorization: Bearer A015CdyoK5GgT4ROb9n-iNBLY1OjO4tJvJeV-eOMdDVyKbc
PayPal\Core\PPHttpConnection: Adding header PayPal-Request-Id: 160110728012881140025562311630
PayPal\Transport\PPRestCall: {"id":"PAY-969088725C646431RKN3DJAY","create_time":"2014-05-16T15:53:39Z","update_time":"2014-05-16T15:53:39Z","state":"created","intent":"sale","payer":{"payment_method":"paypal","payer_info":{"shipping_address":{}}},"transactions":[{"amount":{"total":"1.00","currency":"USD","details":{"subtotal":"1.00"}},"description":"This is the payment description."}],"links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-969088725C646431RKN3DJAY","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-77W22205RV5104528","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-969088725C646431RKN3DJAY/execute","rel":"execute","method":"POST"}]}
PayPal\Core\PPHttpConnection: Connecting to https://api.sandbox.paypal.com/v1/oauth2/token
PayPal\Core\PPHttpConnection: Payload grant_type=client_credentials
PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.32-358.2.1.el6.x86_64;machine=x86_64;openssl=1.0.1e-fips;curl=7.19.7)
PayPal\Core\PPHttpConnection: Adding header Authorization: Basic QWRvemloQmxyYkNaNFNTOFNnQXczZjBlSHdKaXhSX0p4NkFWTVFVeUdGTUFQX0NnY2JRYm5UWXBDQmY4OkVIdmlkUkM3c2lkYXVaZjA3MnBITXp1Z1J3VHlXaGV3bUtKSFhMaFkzM0ZUWDF4WWc0UWpQbGZoR1hDVw==
PayPal\Core\PPHttpConnection: Adding header Accept: */*
PayPal\Core\PPHttpConnection: Connecting to https://api.sandbox.paypal.com/v1/payments/payment/execute
PayPal\Core\PPHttpConnection: Payload 
PayPal\Core\PPHttpConnection: Adding header Content-Type: application/json
PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.32-358.2.1.el6.x86_64;machine=x86_64;openssl=1.0.1e-fips;curl=7.19.7)
PayPal\Core\PPHttpConnection: Adding header Authorization: Bearer A015td4Q1TA1DUZ2e2Vh-3nGnXcFyBb3K6HRyjS6oZtDBII
$redirectUrls->setReturnUrl("http://mysite/prova/public/payment/execute")
            ->setCancelUrl("http://mysite/prova/public/payment/problema");
$redirectUrls->setReturnUrl("http://mysite/prova/public/pagamento/execute")
            ->setCancelUrl("http://mysite/prova/public/pagamento/problema");