Page 1 of 2

Subscription > payment provider

Posted: 18 Nov 2019, 14:47
by cyrotek
Hello,

I currently plan to add a new service provider to handle subscription. Therefor i initially thought to "copy" the mollie omnipay gateway and adapt as needed, though, it may be easier to create a new payment provider from scratch that uses already v2 of the api, instead of dissecting the omnipay one.

Is there a suggestion on your end?

EDIT: While digging into it, I just noticed that the default OminPay Payment Provider does not create a customer id / reference, so I would need to make my own anyway, or am I wrong on that part?

Re: Subscription > payment provider

Posted: 19 Nov 2019, 10:02
by aimeos
If there's a Mollie v2 API that is incompatible with v1 API then yes, it's better to create a new Omnipay driver.

Aimeos uses a not yet standardized way in Omnipay to get the required token for subscription payments:
- Create token: https://github.com/aimeoscom/ai-payment ... y.php#L694
- Get token: https://github.com/aimeoscom/ai-payment ... y.php#L928
- Use token: https://github.com/aimeoscom/ai-payment ... y.php#L445

Re: Subscription > payment provider

Posted: 19 Nov 2019, 11:34
by cyrotek
Thanks, I already started to build my own payment driver. That seems to be the cleanest solution, as it'll just be used for subscriptions.

However, can you please tell me the difference between updatePush and updateSync?

The webhook URL calls update?action=update. Which one of it is it?

EDIT:

Alright, nevermind. Solved that one now. Though, I added my own processor for the subscription, but the class cant be found.

I edited the /config/controller.php and added my processor.

Code: Select all

return [
	'common' => [
		 'subscription' => [
            'process' => [
				'processors' => ['MollieSubscription']
            ]
        ]
	],
	'frontend' => [
	],
	'jobs' => [
	],
];
The Standard.php file is located in myExtensionName/controller/common/src/Controller/Common/Subscription/Process/Processor/MollieSubscription but i get the error Class "\Aimeos\Controller\Common\Subscription\Process\Processor\MollieSubscription\Standard" not found

Here is the first bits of my Class:

Code: Select all

namespace Aimeos\Controller\Common\Subscription\Process\Processor\MollieSubscription;
 
class MollieSubscription
	extends \Aimeos\Controller\Common\Subscription\Process\Processor\Base
	implements \Aimeos\Controller\Common\Subscription\Process\Processor\Iface
{

Re: Subscription > payment provider

Posted: 19 Nov 2019, 14:29
by cyrotek
Alright, it seems the manual at https://aimeos.org/docs/Developers/Cont ... processors is outdated. Once i changed the class name to Standard and adapted \Aimeos\MShop\Factory::createManager to \Aimeos\MShop::createManager it works.

I need to access the payment config, to be precise the apiKey I put there. How do I get it?

Re: Subscription > payment provider

Posted: 19 Nov 2019, 22:56
by aimeos
Thanks for the hint, documentation is updated now. Also, it must be:

Code: Select all

\Aimeos\MShop::create()
The update methods will be called at different occurences:
- updateSync: The customer hits the checkout confirm (thank you) page
- updatePush: The payment gateway notifies the shop via the checkout update page

You can get the configuration of the payment provider with:

Code: Select all

$this->getConfigValue( 'key' )
See also: https://aimeos.org/docs/Developers/Libr ... ng_methods

Re: Subscription > payment provider

Posted: 19 Nov 2019, 23:41
by cyrotek
$this->getConfigValue() was the first thing I tried but didn’t work. Call to undefined function.

Maybe I need to load the service properly before as I’m in the subscription processor?

Re: Subscription > payment provider

Posted: 20 Nov 2019, 00:01
by aimeos
That method isn't available in the subscription processor and I doubt you need one if you implement repay() in your payment service provider.

Re: Subscription > payment provider

Posted: 20 Nov 2019, 07:36
by cyrotek
Okay, maybe I have the wrong approach.

I am not using tokens, Mollie handles that completly. I make the first payment in the checkout and thought to use the subscription processor to start, stop and re-enable the subscription / recurring payment on mollie.

What would be your suggested approach? Also how to use repay() in the subscription processor?

Re: Subscription > payment provider

Posted: 20 Nov 2019, 12:22
by aimeos
Payment of subscriptions is completely handled by the subscription job, you don't have to care about that:
https://github.com/aimeos/ai-controller ... rd.php#L96

Your Omnipay driver only needs to take care of the code lines pointed to first so you may not even implement an Aimeos payment service provider. Only if the Mollie way of handling (recurring) payments doesn't fit into the Omnipay way, you have to implement that special case code in the repay() method of the Aimeos payment service provider for you Mollie implementation.

Re: Subscription > payment provider

Posted: 20 Nov 2019, 12:51
by cyrotek
Ah, Okay. So the Subscription Processor fires repay along the way.

Will the new "invoice" be send per mail or just process the payment in the background?