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

时间:2016-03-14 11:42:34

标签: php redirect paypal omnipay

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

  

重定向到   https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=-=TOKEN   在这里 -

我想知道的是,如果有人知道如何在没有此中间页的情况下停止显示页面并直接重定向到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 个答案:

答案 0 :(得分:0)

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

  2. 替换此代码:

    $响应 - >重定向();

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