thephpleague / omnipay-mollie

Mollie driver for the Omnipay PHP payment processing library
MIT License
62 stars 38 forks source link

Research: integrate the Orders API to support Klarna #54

Closed Smitsel closed 6 years ago

Smitsel commented 6 years ago

We are currently in the process of creating a brand new API to support payment methods which use an authorise and capture flow. You can read more about that here: https://docs.mollie.com/orders/overview

Now im researching if we could add this to the omnipay mollie gateway and i'm running into some difficulties. There is some support for authorising and capturing documented here: https://omnipay.thephpleague.com/api/authorizing/

The first problem is sending the shopping cart to the mollie API. Which is solvable by adding certain fields and requirements to the purchase(array $options) call on the gateway:

From here the customer could select Klarna as a payment option, which will authorise the order and send the customer to their hosted payment page. That results in the order being authorised. Which from a shoppers perspective means the order is placed but for the merchant it means they should still capture.

This is the part i'm having trouble with to figure out how to implement it. I think we should document well that when a purchase comes back with authorised state the integrators of this package should do a capture call with the required parameters as described in our shipment Api.

Do you have any thoughts about this @barryvdh? Or do you see any problems when implementing it as described above?

roelvanduijnhoven commented 6 years ago

@willemstuursma Are there plans from Mollie to integrate Klarna into this repo? Would really help us!

And thanks again for the previous work on adding multicurrency support to this library :clap:

willemstuursma commented 6 years ago

We're not really sure how to add it to this library, hence this issue.

@roelvanduijnhoven To be frank, I think you would be better off implementing orders through our own library directly.

roelvanduijnhoven commented 6 years ago

Excuse me @willemstuursma; was not aware that @Smitsel was part of your team :).

To be frank, I think you would be better off implementing orders through our own library directly.

Do you say that that because you think it will take some time before this change will land in this repo? Or because it is incompatible; and (looks like it) can't be integrated?

Smitsel commented 6 years ago

For Klarna to be available through this library we need to use our new Mollie Orders API. Unfortunately the abstraction that Omnipay offers does not have extensive support for submitting orders and lines through the gateway.

So it is incompatible, unfortunately. And if we would, it would require a lot of customisation.

Therefor the best advise is to indeed implement the Mollie PHP SDK because it will probably be the same amount of work as implementing this library with orders.

Please have a look at: https://github.com/mollie/mollie-api-php

barryvdh commented 6 years ago

Yeah there is an ItemBag with Items which should represent a cart / order lines, but it's not really implemented the same in all gateways (or documented at all). There is an old discussion here: https://github.com/thephpleague/omnipay/issues/323 Perhaps it could be a good starting point for a new minor release, what do you think @judgej ?

willemstuursma commented 6 years ago

Do you say that that because you think it will take some time before this change will land in this repo? Or because it is incompatible; and (looks like it) can't be integrated?

I think it will be difficult to make it compatible across PSPs. For Klarna, we require a lot of information that you would would have to add in a specific way. Since the goal of Omnipay is the ability to swap out payment service providers, this would prevent you from switching.

Yeah there is an ItemBag with Items which should represent a cart / order lines, but it's not really implemented the same in all gateways (or documented at all).

Additionally, you will also need shipping support if you want to fully automate it.

barryvdh commented 6 years ago

I'm gonna look into this and try to integrate it!

barryvdh commented 6 years ago

Initial implementatie here: https://github.com/thephpleague/omnipay-mollie/pull/58 Let's continue the discussion there.