Adding payment option to cart

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!
User avatar
aimeos
Administrator
Posts: 8725
Joined: 01 Jan 1970, 00:00

Re: Adding payment option to cart

Post by aimeos » 25 Jan 2026, 14:15

Just use the Aimeos namespace. Then, you don't need your workaround:

Code: Select all

namespace Aimeos\MShop\Service\Provider\Delivery

class InfoForwarder
{
}
Place the class in your Aimeos extension in ./src/MShop/Service/Provider/Delivery/InfoForwarder.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
matish
Posts: 51
Joined: 04 Nov 2025, 11:52

Re: Adding payment option to cart

Post by matish » 28 Jan 2026, 16:24

aimeos wrote: 25 Jan 2026, 14:15 Just use the Aimeos namespace. Then, you don't need your workaround:

Code: Select all

namespace Aimeos\MShop\Service\Provider\Delivery

class InfoForwarder
{
}
Place the class in your Aimeos extension in ./src/MShop/Service/Provider/Delivery/InfoForwarder.php
This is the thing that I wanted to avoid. And it halfway worked. The payment method became listed under the menu, but when doing the checkout itself, then it started demanding the class to be inside Aimeos namespace.

But another question.
I have a code like this:

Code: Select all

    /**
     * Calculate delivery price using the "price" attribute
     */
    public function calcPrice(\Aimeos\MShop\Order\Item\Iface $basket, array $options = []
    ): \Aimeos\MShop\Price\Item\Iface
    {

        $manager = \Aimeos\MShop::create( $this->context(), 'price' );

        $price = $manager->create();
        $price->setCosts( (double)($options['eabi_info_carrier.price']??0) );
        return $price;
    }

It works, but it does not account any taxes. How can I make the shpping/payment method to include taxes in the cost?
Also how can I make the payment "paid" or "authorized" right away at the moment of order placement?

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

Re: Adding payment option to cart

Post by aimeos » 29 Jan 2026, 08:24

To add tax, use the setTaxRate() method to add the tax rate in percent.

The order must be is set to "authorized" or "received" if the payment was the successful in the updateSync() method (and updatePush() if you use a payment service provider):
https://aimeos.org/docs/latest/provider ... us-updates
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
matish
Posts: 51
Joined: 04 Nov 2025, 11:52

Re: Adding payment option to cart

Post by matish » 29 Jan 2026, 15:53

Ok, taxes now work. Thanks!

But the payment stuff still does not work.
I am using this API call:
https://aimeos.org/docs/latest/frontend ... eate-order

I want the order payment to be authorized right away at the order placement. Not later. Because my external system collects the payment before sending out the order details.
If I place the order via regular Aimeos frontend and use "PostPay" as payment provider, then the payment is immediately authorized after the order placement. But if I do that over the API (see link above) then the order is not authorized.

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

Re: Adding payment option to cart

Post by aimeos » 02 Feb 2026, 11:20

Do you add a "PostPay" option as payment service provider over the API too?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
matish
Posts: 51
Joined: 04 Nov 2025, 11:52

Re: Adding payment option to cart

Post by matish » 02 Feb 2026, 16:21

aimeos wrote: 02 Feb 2026, 11:20 Do you add a "PostPay" option as payment service provider over the API too?
Well, I did not. I just copied some of the code from it to my custom payment method.
But now I did the tests.

First I created an order over the API using PostPay. Placed order was not authorized.
Then I created same order over the frontend using PostPay. This time placed order was authorized.
Image

But I am not planning to use PostPay itself, I was just looking at its code to figure out, on how to get the order as Authorized at the moment of order creation.

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

Re: Adding payment option to cart

Post by aimeos » 02 Feb 2026, 16:38

You need to set a payment option. Otherwise:
- the order can't be created by default due to ServicesAvailable basket plugin
- or the order will be in payment unfinished state if you disable ServicesAvailable basket plugin
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
matish
Posts: 51
Joined: 04 Nov 2025, 11:52

Re: Adding payment option to cart

Post by matish » 02 Feb 2026, 18:40

I have the payment option.
The order is created just fine.
Only the order state is incorrect. It should be "authorized" or any other state so it would not be auto-deleted.
Picture:
Image

Or what kind of "payment option" are you exactly talking about?

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

Re: Adding payment option to cart

Post by aimeos » 03 Feb 2026, 08:12

If you use your own payment service provider, you have to set the payment status in the updateSync() method of your service provider.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
matish
Posts: 51
Joined: 04 Nov 2025, 11:52

Re: Adding payment option to cart

Post by matish » 03 Feb 2026, 14:45

I have it. Copied the method from \Aimeos\MShop\Service\Provider\Payment\PostPay
But the end result is the same. Order is not authorized, when it is placed over the JSON API, but it is authorized when I place the order via regular AimeOS frontend.
Same thing with default PostPay provider.

Post Reply