Aimeos Headless - Route [aimeos_shop_confirm] not defined.

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!
spider
Posts: 7
Joined: 05 Apr 2023, 13:14

Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by spider » 05 Apr 2023, 13:24

Hi,
I am exploring the package for an upcoming project. Aimeos Headless is freshly pulled via composer aimeos/aimeos-headless, without any modification.

I am trying to complete an order via API calls. These steps have been successfully completed: Add product to basket; Add address to basket; Add payment to basket; Save/Complete the basket.

Next, while posting to jsonapi/order to create an order invoice, it responds an error of "#54 main
Route [aimeos_shop_confirm] not defined."

May I know if anything is misconfigured or if I have mistaken the ordering flow.

Thanks.

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

Re: Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by aimeos » 05 Apr 2023, 13:42

Seems like a problem due to the disabled standard routes in the headless distribution. The route is used in the JSON API implementation as target for redirects if you use an external payment service provider which doesn't provide a JS client like Stripe. Can you please add these lines to your ./routes/web.php and see if it fixes the problem?

Code: Select all

Route::group( ['prefix' => 'shop', 'middleware' => ['web']], function() {

    Route::match( array( 'GET', 'POST' ), 'confirm/{code?}', array(
        'as' => 'aimeos_shop_confirm',
        'uses' => 'Aimeos\Shop\Controller\CheckoutController@confirmAction'
    ) )->where( ['locale' => '[a-z]{2}(\_[A-Z]{2})?', 'site' => '[A-Za-z0-9\.\-]+'] );

});
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

spider
Posts: 7
Joined: 05 Apr 2023, 13:14

Re: Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by spider » 05 Apr 2023, 17:41

aimeos wrote: 05 Apr 2023, 13:42 Seems like a problem due to the disabled standard routes in the headless distribution. The route is used in the JSON API implementation as target for redirects if you use an external payment service provider which doesn't provide a JS client like Stripe. Can you please add these lines to your ./routes/web.php and see if it fixes the problem?

Code: Select all

Route::group( ['prefix' => 'shop', 'middleware' => ['web']], function() {

    Route::match( array( 'GET', 'POST' ), 'confirm/{code?}', array(
        'as' => 'aimeos_shop_confirm',
        'uses' => 'Aimeos\Shop\Controller\CheckoutController@confirmAction'
    ) )->where( ['locale' => '[a-z]{2}(\_[A-Z]{2})?', 'site' => '[A-Za-z0-9\.\-]+'] );

});
It worked at the first place. But then I wanted to try payment, and pulled "aimeos/ai-payments omnipay/stripe". I guess ai-payments has recently updated, and is incompatible with the headless distribution. It crashed something, and indeed showed a message like "unrecoverable error". (Likely crashed some routes. I could no longer logging into the admin dashboard again, always 404.)

So, I started again with a fresh headless distribution. But the route fix does not work this time. It returns 404 saying empty basket.

This also brings me more questions:
  • Should I use aimeos/aimeos or aimeos/aimeos-laravel instead? Seems they are more up-to-date. I have also tested on the aimeos/aimeos distribution, where I don't find the routing issue on 'aimeos_shop_confirm not found'.
  • What does aimeos/ai-payments actually does? I don't seem seeing it handling anything for me with Stripe.
Thanks.

spider
Posts: 7
Joined: 05 Apr 2023, 13:14

Re: Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by spider » 06 Apr 2023, 08:20

I have figured out the empty basket issue. It is fixed by changing the APP_URL.

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

Re: Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by aimeos » 06 Apr 2023, 09:31

spider wrote: 05 Apr 2023, 17:41 It worked at the first place. But then I wanted to try payment, and pulled "aimeos/ai-payments omnipay/stripe". I guess ai-payments has recently updated, and is incompatible with the headless distribution. It crashed something, and indeed showed a message like "unrecoverable error". (Likely crashed some routes. I could no longer logging into the admin dashboard again, always 404.)
If you use the headless distribution, the ai-payments extension isn't suitable at all because it requires the HTML frontend. You have to integrate Stripe using the Stripe JS API directly in your SPA instead.
spider wrote: 05 Apr 2023, 17:41 Should I use aimeos/aimeos or aimeos/aimeos-laravel instead? Seems they are more up-to-date. I have also tested on the aimeos/aimeos distribution, where I don't find the routing issue on 'aimeos_shop_confirm not found'.
The headless distribution is newer than the other two options but fully supported and always at the same version level. The Aimeos standalone distribution is the easiest to install and you don't have to code your own frontend (or adapt the Vue or React frontends offered by Skynet). The Aimeos Laravel package is best if you already have an existing Laravel application and want to integrate e-commerce features.
spider wrote: 05 Apr 2023, 17:41 What does aimeos/ai-payments actually does? I don't seem seeing it handling anything for me with Stripe.
Like said, not in the headless distribution. You can only use it in combination with the standalone distribution or the Laravel package (both provide the HTML frontend).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

spider
Posts: 7
Joined: 05 Apr 2023, 13:14

Re: Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by spider » 06 Apr 2023, 09:45

Thank you for the clarification.

P.S. It would be appreciated if Aimeos documentation could have explained in more details.

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

Re: Aimeos Headless - Route [aimeos_shop_confirm] not defined.

Post by aimeos » 07 Apr 2023, 08:41

We've added a note about this in the docs:
https://aimeos.org/docs/latest/manual/services/#payment
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply