Setting shipping info in OmniPay

橙三吉。 提交于 2019-12-07 15:39:53

问题


I'm trying to set a shipping info (name,address, email, etc) using OmniPay for PayPal Express. I've tried adding shipping info in options array in purchase($options) object:

$options = array(
// required fields (username, pass, etc) 
// .....
'shippingAddress1' => 'Elm Street'
'shippingCity' => 'Elm', 
'shippingPostcode' => '1000'
// etc. 
);

I also tried passing this info to CreditCard object:

$card = new Omnipay\Common\CreditCard($card_options); without any success. The code:

$gateway = GatewayFactory::create('PayPal_Express');
        $gateway->setUsername(USERNAME);
        $gateway->setPassword(PASS);
        $gateway->setSignature(SIGNATURE);
        $gateway->setTestMode(true);

        $card_options = array(
         'shippingAddress1' => 'Elm Street',
         'shippingCity' => 'Elm',
         'shippingPostcode' => '10000',
         'shippingState' => '',
         'shippingCountry' => 'NEverland',
         'shippingPhone' => '123465789',
         'company' => '',
         'email' => 'shipping@test.com'
         );
        $card = new Omnipay\Common\CreditCard($card_options);

        $response = $gateway->purchase(
            array(
                'cancelUrl'=>'http://localhost/laravel_paypal/',
                'returnUrl'=>'http://localhost/laravel_paypal/public/paypalexpress_confirm',
                'amount' =>  '0.99',
                'currency' => 'USD',
                'card' => $card

            )
        )->send();

How to add shipping info to PayPal Express using OmniPay?

BTW, I'm using Laravel with PayPal Sandbox.


回答1:


This problem has recently been fixed (https://github.com/adrianmacneil/omnipay/pull/140) so it should now be possible to set shipping info properly.



来源:https://stackoverflow.com/questions/18495788/setting-shipping-info-in-omnipay

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!