1

When I checkout via Paypal express if I don't already have an address added to the cart model, when the paypal checkout process returns back there will be no address attached to the order.

The reason I want the address to be sent back afterwards is that i want to send customers to paypal from the cart page so there is no address form prior to leaving to paypal. This flow is something possible on say, woocommerce.

1

Well, after a transaction, you can log the full gateway response etc using this event: https://craftcommerce.com/docs/events-reference#commerce_transactions.onsavetransaction

(See what you can get at/log at https://craftcommerce.com/docs/transaction-model)

craft()->on('commerce_transactions.onSaveTransaction', function ($event){

      $transaction = $event->params['transaction'];
      BusinessLogicPlugin::log($transaction->response);

 });

...that should hopefully get you started on grabbing the data you need (I presume PayPal returns the address) - and then adding that to the cart at that point.

| improve this answer | |
  • Thanks for the help, but unfortunately no, Paypal does not return the address. I ended up writing a plugin to make another request to Paypal onSaveTransaction to get the address for the order. Once this project is finished I'll post the github link here. – Stephen McKinney May 23 '17 at 15:48
  • Good to know but how odd it doesn't return it initially. I checked our main gateway and it apparently does, although there's no facility for the customer to change it with the gateway so it's really kinda pointless there other than to check it's receiving what we think it is receiving! – Jeremy Daalder May 23 '17 at 23:16
  • Well craft commerce hard codes the paypal parameter to hide shipping when it sends the request to paypal. I had to add in a hook to modify the request data to put it back in. I couldn't get paypal to return back the shipping address in the raw gateway response, but commerce will still have the shipping address you sent to paypal stored in the order. public function commerce_modifyPaymentRequest($data){ $data['noShipping'] = 0; return $data; } – Stephen McKinney May 25 '17 at 20:12
1

I ended up developing a real quick plugin to make an additional call to Paypal to get and store the address to the order.

https://github.com/wojodesign/paypaladdresser

| improve this answer | |
  • 1
    That's great - one does wonder, though, if perhaps Commerce itself shouldn't perhaps deal with it as Paypal customers do routinely use the Paypal facilities for address handling I guess. Perhaps you should raise this with Luke holder at some point? – Jeremy Daalder May 31 '17 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.