Subscription > payment provider

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Subscription > payment provider

Post by cyrotek » 18 Nov 2019, 14:47

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Subscription > payment provider

Post by aimeos » 19 Nov 2019, 10:02

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Subscription > payment provider

Post by cyrotek » 19 Nov 2019, 11:34

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
{

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Subscription > payment provider

Post by cyrotek » 19 Nov 2019, 14:29

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Subscription > payment provider

Post by aimeos » 19 Nov 2019, 22:56

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Subscription > payment provider

Post by cyrotek » 19 Nov 2019, 23:41

$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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Subscription > payment provider

Post by aimeos » 20 Nov 2019, 00:01

That method isn't available in the subscription processor and I doubt you need one if you implement repay() in your payment service provider.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Subscription > payment provider

Post by cyrotek » 20 Nov 2019, 07:36

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Subscription > payment provider

Post by aimeos » 20 Nov 2019, 12:22

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

cyrotek
Posts: 58
Joined: 27 Jun 2019, 16:43

Re: Subscription > payment provider

Post by cyrotek » 20 Nov 2019, 12:51

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?

Post Reply