Basket data in Payment Provider

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!
lockhart97
Posts: 28
Joined: 17 Aug 2023, 00:16

Basket data in Payment Provider

Post by lockhart97 » 10 Jun 2024, 03:19

Laravel: 11.0
Aimeos: 2024.04
PHP: 8.2
Environment: Linux

Hello, I am developing a Payment Service provider. I need customer data to capture the payment as per the Payment gateway that I am using. The process method for the provider take Order Invoice object as parameter. How do I get basket address in the Payment provider. The addresses field in Order Invoice object is an empty array.

I thought using a decorator might solve this problem. Can you please point me right direction as to how get basket address in Payment provider using decorators or without them?

lockhart97
Posts: 28
Joined: 17 Aug 2023, 00:16

Re: Basket data in Payment Provider

Post by lockhart97 » 12 Jun 2024, 03:58

I am using following method to access address in payment provider. Let me know if there is a better way

Code: Select all

    public function process(
        \Aimeos\MShop\Order\Item\Iface $order,
        array $params = []
    ): ?\Aimeos\MShop\Common\Helper\Form\Iface {
        // perform your actions
        $context = $this->context();
        $orderId = $params["order.id"];
        $orderAddress = \Aimeos\Controller\Frontend::create( $context, 'basket' )->load( $orderId, ['order/address'], false );
        return parent::process($order, $params);
    }

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

Re: Basket data in Payment Provider

Post by aimeos » 12 Jun 2024, 10:45

The order items already contains the address and you can use this to get the billing address:

Code: Select all

$order->getAddress('payment');
See: https://github.com/aimeos/aimeos-core/b ... e.php#L274
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lockhart97
Posts: 28
Joined: 17 Aug 2023, 00:16

Re: Basket data in Payment Provider

Post by lockhart97 » 12 Jun 2024, 12:04

This does not work. It returns null.

lockhart97
Posts: 28
Joined: 17 Aug 2023, 00:16

Re: Basket data in Payment Provider

Post by lockhart97 » 12 Jun 2024, 12:14

I am using JsonAPI to place order by making post request to basket. While writing a payment provider, the $order object is "order/service" object and it does not have address.

https://github.com/aimeos/ai-client-jso ... 11-L305C17

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

Re: Basket data in Payment Provider

Post by aimeos » 13 Jun 2024, 10:52

Does it work for you if you replace the line which this one instead:

Code: Select all

return \Aimeos\Controller\Frontend::create( $context, 'basket' )->load( $id, ['order/address', 'order/service'], false );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lockhart97
Posts: 28
Joined: 17 Aug 2023, 00:16

Re: Basket data in Payment Provider

Post by lockhart97 » 17 Jun 2024, 16:06

Yes, this is exactly what I thought. However, implementing this would require changes to the core Aimeos codebase. If this solution is acceptable, I would like to submit a pull request to the Aimeos project.

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

Re: Basket data in Payment Provider

Post by aimeos » 18 Jun 2024, 08:47

Yes, please create a PR and we are happy to merge the change into the core. It will be part of the next minor release then.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

lockhart97
Posts: 28
Joined: 17 Aug 2023, 00:16

Re: Basket data in Payment Provider

Post by lockhart97 » 18 Jun 2024, 13:39

Thank you for your response.

Post Reply