使用Omnipay在Paypal Express中显示帐单和送货信息

时间:2014-08-05 19:22:46

标签: php paypal omnipay

我正在使用Laravel和Omnipay进行电子商务应用。我们将客户引导至Paypal进行购买。我们在下订单之前需要发货和结算信息,我们希望这些信息能够继续使用Paypal,以便让他们更轻松。但是,只有名字和姓氏正确地交叉到Paypal。我们也可以使用没有问题的电子邮件。

        public function postPayment() {

       //var_dump(Session::get('shipping_info')); die;

        $info = Session::get('shipping_info');

        $gateway = Omnipay::gateway('paypal');

        //sandbox

        $gateway->setUsername('xxxx');
        $gateway->setPassword('xxxx');
        $gateway->setSignature('xxx');

        $gateway->setTestMode('true');

        //production
//        $gateway->setUsername('xxxx');
//        $gateway->setPassword('xxxx');
//        $gateway->setSignature('xxxx');

        $cardInput = array(
            'firstName' => $info['first_name_bill'],
            'lastName'  => $info['last_name_bill'],
            'billingAddress1' => $info['street_address_1_bill'],
            'billingAddress2' => $info['street_address_2_bill'],
            'billingPhone'  =>  $info['phone_bill'],
            'billingCity'   =>  $info['city_bill'],
            'billingState'  =>  $info['state_bill'],
            'billingPostCode'   => $info['zip_bill'],
            'shippingAddress1' => $info['street_address_1_ship'],
            'shippingAddress2' => $info['street_address_2_ship'],
            'shippingPhone'  =>  $info['phone_ship'],
            'shippingCity'   =>  $info['city_ship'],
            'shippingState'  =>  $info['state_ship'],
            'shippingPostCode'   => $info['zip_ship'],
        );

        $card = Omnipay::creditCard($cardInput);

       // var_dump($card); die;
        $response = Omnipay::purchase(
            array(
                'cancelUrl' => 'http://localhost/public/',
                'returnUrl' => 'http://localhost/public/',
                'amount' => Input::get('total'),
                'currency' => 'USD',
                'card' => $card,
                'description' => 'Stuff'
            )
        )->send();

        $response->redirect();

    }

根据文档https://github.com/omnipay/omnipay,它应该没有任何问题。转储会话会显示正确的结算和运输参数。

1 个答案:

答案 0 :(得分:0)

只需要缓存刷新。