After Payment Decorator with PaypalExpress

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
forons
Posts: 2
Joined: 29 Mar 2021, 14:30

After Payment Decorator with PaypalExpress

Post by forons » 29 Mar 2021, 14:41

Hi all,

I am using Aimeos 2020.10.6 with PHP 7.3. The system is pretty good!
The only issue I found up to now is to add a decorator that performs some operations after the payment (done through PaypalExpress).
I found a related topic laravel-package-f18/hook-into-order-com ... t2687.html, however, even following the procedure explained there I ended up with having problems.
Basically, I redefined the updatedSync function in this way:

Code: Select all

public function updateSync(
        \Psr\Http\Message\ServerRequestInterface $request,
        \Aimeos\MShop\Order\Item\Iface $order
    ): \Aimeos\MShop\Order\Item\Iface {
        ....
        if ($paymentStatus == \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED) {
           send_email_to_user_and_update_db
        }
        return $order;
}
I have a specific use case that doesn't allow me to use the cronjob function provided by Aimeos.
However, the status there is always pending.

I also tried to move the logic in the updatePush function, but the result is exactly the same.
Instead, if I remove the decorator I created, the payment succeed.

Can someone please help me? What am I doing wrong?

Looking forward for a reply, thanks for the time and help!

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

Re: After Payment Decorator with PaypalExpress

Post by aimeos » 31 Mar 2021, 17:03

If you write a decorator and want the underlying object to do its job, you need to call

Code: Select all

$this->getProvider()->updateSync($request, $orderItem);
first. Thus, your code should look like:

Code: Select all

public function updateSync(
        \Psr\Http\Message\ServerRequestInterface $request,
        \Aimeos\MShop\Order\Item\Iface $order
    ) : \Aimeos\MShop\Order\Item\Iface
{
	$order = $this->getProvider()->updateSync($request, $order);
 
        if ($order->getPaymentStatus() == \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED) {
           send_email_to_user_and_update_db
        }
        return $order;
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

forons
Posts: 2
Joined: 29 Mar 2021, 14:30

Re: After Payment Decorator with PaypalExpress

Post by forons » 01 Apr 2021, 16:57

Ok, thanks a lot for the reply. That solved the issue and is exactly what I was looking for!

Post Reply