php - Omnipay Paypal Express 重定向显示重定向消息

标签 php redirect paypal omnipay

我的支付网关中的 Omnipay 运行良好,但是当系统重定向到 PayPal 时,我在重定向到 PayPal 之前在屏幕上看到以下内容:

Redirecting to https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=-=TOKEN IS HERE-

我想知道是否有人知道如何停止显示页面并在没有中间页面的情况下直接重定向到 PayPal。我的重定向代码如下:

$gateway=GatewayFactory::create('PayPal_Express');
$gateway->setUsername(['username']);
$gateway->setPassword(['password']);
$gateway->setSignature(['signature']);
$gateway->setTestMode(['testing']);

$totalamount=number_format(['ordertotal'],2);

try{
    $response=$gateway->purchase(
        array(
            'cancelUrl' =>  base_url('paymentMethod/'),
            'returnUrl' =>  base_url('paypalexpress/confirm'),
            'amount'    =>  $totalamount,
            'currency'  =>  'GBP'
        )
    )->send();

    if($response->isSuccessful()){
        print_r($response);
    }elseif($response->isRedirect()){
        $response->redirect();
    }else{
        echo $response->getMessage();
    }
}
catch(\Exception $e){
        $this->payment(1,$e->getMessage());
}

最佳答案

  1. 我建议您从 PayPal_Express 切换到 PayPal_Rest。将来您会找到更好的支持。

  2. 替换这段代码:

    $response->redirect();

... 使用一些特定于您的框架的代码。例如,如果您使用的是 Laravel 或 Symfony,它们都有 RedirectResponse 类。您可以使用 $response->getRedirectUrl() 而不是使用 redirect() 方法(这是在您的屏幕上显示重定向 flash 的方法)从响应中获取重定向 URL。

关于php - Omnipay Paypal Express 重定向显示重定向消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35986601/

相关文章:

php - Mysql语句,有没有办法改进这个?

php - "service httpd reload"会重新加载新的 php.ini 设置吗?

php - 根据发送的参数进行动态重定向php

drupal - 使用 UC 和 PayPal WPS 的匿名结账不起作用

CodeIgniter 的 IPN 库 - 脚本忽略了我的代码

php - 未定义索引 : _attribute_set in magento product csv import from admin

php - laravel 5.2 如何将另一个表的数据插入到另一个表中?

c++ - 重定向 cout -> std::stringstream,没有看到 EOL

ruby-on-rails - 如何使用带有 redirect_to 的字符串?

e-commerce - 收取一定比例付款的工作流程 (PayPal)