ai-payments icon indicating copy to clipboard operation
ai-payments copied to clipboard

Implement Orders API for pay later payment methods

Open nvindice opened this issue 5 years ago • 11 comments

This patch overrides a couple of Omnipay methods to implement the Mollie Orders API, which is needed for Klarna Pay later and Klarna Slice payment options.

I was not sure if it would be cleaner to modify some methods at Aimeos\MShop\Service\Provider\Payment\Omnipay directly, but ultimately decided to do it like this. Feel free to adapt or modify.

nvindice avatar Jun 04 '19 19:06 nvindice

Coverage Status

Coverage decreased (-11.5%) to 61.923% when pulling a3d9f79534121c644df243bb88847891aac7de87 on nvindice:2018.10 into b4a5103c251cf489301883bb5df8ff63341cb5b9 on aimeoscom:2018.10.

coveralls avatar Jun 04 '19 19:06 coveralls

What do you think of this solution altogether? It's not beautiful, because we have a lot of code duplicates here. However, the "order" methods might be too specific to add them to Aimeos\MShop\Service\Provider\Payment\Omnipay IMHO. Not sure how to do it best. What do you think?

EDIT: I will upload the changes later with some additional fixes for coupon handling.

nvindice avatar Jun 05 '19 08:06 nvindice

It's hard to split the updateSync and processOrder methods further so this is currently the best option. Can you please add tests so the code coverage doesn't decrease?

aimeos avatar Jun 05 '19 09:06 aimeos

Sorry, I'm not able to write the tests right now. Most of the tests from Omnipay should work, as the methods are copied with minor adaptions. The apiType = order is needed. Can you help me with that?

nvindice avatar Jun 05 '19 13:06 nvindice

Not at the moment

aimeos avatar Jun 06 '19 18:06 aimeos

@nvindice Any update on this?

aimeos avatar Sep 09 '19 12:09 aimeos

Well, we are using it in production without any issues - I'll try to build some tests in the next couple of weeks...

nvindice avatar Sep 09 '19 13:09 nvindice

Writing tests is more work than expected, because Omnipay/Dummy does not support orders, as Omnipay/omnipay-mollie does. Not sure how to continue best, as I'm not used to work with PHPUnit tests. Any tips for me?

nvindice avatar Nov 19 '19 19:11 nvindice

(Push)

nvindice avatar Dec 05 '19 11:12 nvindice

Are you going to add the missing tests for your code in the near future? Then, we could merge your PR

aimeos avatar Dec 13 '19 11:12 aimeos

As said, I need some help on how to write those tests without a fitting Omnipay/Dummy method. Can you help me with this?

IMO, this PR brings a valuable new component to Aimeos: paying with Mollie/Klarna-PayLater, Apple Pay (?) and other advanced payment methods.

nvindice avatar Dec 13 '19 11:12 nvindice