Payment service 'process' not being called

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
createanet
Posts: 72
Joined: 22 Mar 2021, 16:56

Payment service 'process' not being called

Post by createanet » 20 May 2021, 18:37

Hello,

I have a custom payment service and have implemented calcPrice, isAvailable and finally process.

Initially I was working with a decorator along with the PostPay provider.

No matter what I do, when hit buy now my process method is never called, I've followed the docs example below just to set the default status of the order to PAY_RECEIVED.

Code: Select all

public function process(
    \Aimeos\MShop\Order\Item\Iface $order,
    array $params = []
): ?\Aimeos\MShop\Common\Helper\Form\Iface {

    $status = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED;
    $order->setPaymentStatus($status);
    $this->saveOrder($order);

    return parent::process($order, $params);
}
Nothing is being changed, the status is always assigned PAY_AUTHORIZED.

I'm not sure it makes any different but my order total is intentionally 0.00.
You should implement the process() method so your payment service provider does something useful even if a default implementation exists that redirects the customer to the confirmation page.
Ive traced it back to the Aimeos\Client\Html\Checkout\Standard\Process class and the process method and I can see the `processPayment` call is returning null. I just wondered if perhaps im misunderstanding the documentation and what I am trying to do isn't possible?

Im using aimeos/aimeos-laravel:2020.10.7.

Thanks

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

Re: Payment service 'process' not being called

Post by aimeos » 23 May 2021, 07:32

Have you checked if the payment status is overwritten by the updateSync() or updatePush() methods? Especially if you implement a decorator, the underlying object is likely to set the payment status again in these methods.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

createanet
Posts: 72
Joined: 22 Mar 2021, 16:56

Re: Payment service 'process' not being called

Post by createanet » 24 May 2021, 07:28

Morning,

It was initially a decorator, then I switched over to a service so I could narrow down where or what might be changing it (or not)

As it is its owns service, the updatePush inherits from its parent whose default is a http response "not implemented", I have added in logging and this is never executed, as here is no payment gateway I wouldn't expect this to be executed?

I had also overridden the updateSync and explicitly setup the payment status to what is expected.

I have double checked this morning that the server provider has no further decorators applied to itself, however the results are still the same, the payment status is still assigned as authorized not received.

I might just setup a new install with an an extension that only contains this provider and run some tests on that to be sure that nothing else in my extension is interfering with the update.

createanet
Posts: 72
Joined: 22 Mar 2021, 16:56

Re: Payment service 'process' not being called

Post by createanet » 24 May 2021, 08:48

This is still true for a fresh install, neither my process or updatesync methods appear to ever be called.

Would this be because the provider has no gateway, and falls back on the default implementation that redirects the customer to the confirmation page?

[edit] As a test I put through an order with a value that has a total > 0.00, the confirmation page ends with the the provider code in the URL, where as when there is a total = 0.00 this provider code is not included in the url.

eg.

1. /confirm/{provider.code}
2. /confirm/

With these examples the #1 has now sets the status correctly (its calling my provider), #2 does not its ignoring the provider when the sum total is zero.

[edit] Ive come back to the standard checkout process class, below I can now see it returns null when the total is <= 0, this early return means it never gets the provider class to continue with processing and assumes there is no payment service available (which is guess is correct) but as a result im no longer able to manage processing.

https://github.com/aimeos/ai-client-htm ... #L376-L380

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

Re: Payment service 'process' not being called

Post by aimeos » 28 May 2021, 16:55

You are right, this is a shortcut to prevent initiating payment for a basket total of 0.00. If we pass the service code in the URL so updateSync() of the payment providers are always called, they may throw an error. The possible option would be:

1.) Make it configurable which payment status is set in that case
2.) Make it configurable if the service code is passed in that case

Do you see any other options?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

createanet
Posts: 72
Joined: 22 Mar 2021, 16:56

Re: Payment service 'process' not being called

Post by createanet » 01 Jun 2021, 14:18

I don't think so, both these options cover everything I have described.

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

Re: Payment service 'process' not being called

Post by aimeos » 04 Jun 2021, 06:13

We would prefer making the payment status configurable because it won't cause backward compatibility issues. What do you think?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

createanet
Posts: 72
Joined: 22 Mar 2021, 16:56

Re: Payment service 'process' not being called

Post by createanet » 04 Jun 2021, 07:34

Morning,

Sure, I understand option 1 being favourable.

My only question would be, aside of making this change it still won't be possible to hook into the providers methods to execute actions on the order? For eg. The initial query was with regards to the default assignment of 'authorized' for all zero balanced orders, these orders purchased in my instance are using a credit system on the customers account. This credit would need reducing once the order is placed and payment is 'received'.

There would still be in a situation where neither process or updateSync are executed to be able to make the necessary adjustments described above as my understanding is the process handles the job of the payment, where updateSync handles the result/status of the processed payment. - the only way these are executed is when the service code is passed :?

Do you perhaps have any suggestions? Flipping the responsibility over to a decorated delivery provider won't really work here. The reduction needs to happen instantly in case of multiple orders occurring during processing as the customers credit has not been reduced

Thanks for your time,

Mart

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

Re: Payment service 'process' not being called

Post by aimeos » 04 Jun 2021, 09:55

Seems like we have to go the hard route and pass the payment service code and see which payment providers will make problems. PayPal will do for sure.

Can you make a pull request on Github with the necessary changes?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

createanet
Posts: 72
Joined: 22 Mar 2021, 16:56

Re: Payment service 'process' not being called

Post by createanet » 04 Jun 2021, 12:51

Yeah of course, Id just like to make sure I am understanding the changes necessary.

At the moment I don't understand how the removal of the following lines will interfere with processing of other providers?

https://github.com/aimeos/ai-client-htm ... #L376-L380

I have made the changes locally for testing purpose and have no issues with providers I have implemented - klarna, braintree.

As a direct result of removal of the above, everything I am expecting to happen with my custom payment provider is now happening, along with normal checkout with values > 0 using other providers.

Post Reply