1

我将 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它应该可以正常工作。转储会话显示正确的计费和运输参数。

4

1 回答 1

0

它只需要刷新缓存。

于 2014-08-08T15:51:07.737 回答