3

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.

dede
  • 2,523
  • 2
  • 28
  • 32
  • 1
    Found a workaround. Class `ExpressAuthorizeRequest` in `getData()` method has haardcoded value for setting shipping prompt upon payment on PayPal. `$data['NOSHIPPING'] = 1;` – dede Aug 29 '13 at 01:19
  • If you change the value to `2`, then when redirected to PayPal Express page there will be option for setting shipping info (if necessary). I wish that this could be done with getters/setters on `purchase()` object – dede Aug 29 '13 at 01:27
  • 2
    Good point. I've made an issue for you here, will address this in a future version. For now probably easiest just to fork and edit the file directly. https://github.com/adrianmacneil/omnipay/issues/121 – Adrian Macneil Aug 29 '13 at 17:40
  • If you don't need shipping (paying for a service) use 'noShipping' => true – Marko Aleksić Jan 06 '17 at 15:28

1 Answers1

4

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

aderuwe
  • 1,013
  • 8
  • 11