Aimeos manual order creation (webhook Stripe)

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!
Kevin
Posts: 13
Joined: 28 Nov 2017, 19:54

Aimeos manual order creation (webhook Stripe)

Post by Kevin » 20 Dec 2017, 10:18

Hi all,

I'm using Aimeos for single products and subscriptions. So far, everything is working pretty fine. The last step to finalize the platform is to receive a webhook from Stripe when the subscription auto-renews.

When a subscription renews, I would like to add an order in the same way a normal order is placed via the backend. In other words, I want the order to appear in the order history of the client, I want the order to appear in my list of order to handle etc...

Someone has experience with this? Or someone can advise me on the best way to set this up?
I can directly input the database, but that would not be so clean. So I assume there are better options to build this.

Thanks for advising me on this one.

Regards,
Kevin

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

Re: Aimeos manual order creation (webhook Stripe)

Post by aimeos » 20 Dec 2017, 22:07

You only have to create an additional record in the mshop_order table, best using the order manager:

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
$invoice = $manager->createItem();
$invoice->setBaseId( '<ID of mshop_order_base table with the related order>' );
$invoice->setType( \Aimeos\MShop\Order\Item\Base::TYPE_REPEAT );
$invoice->setDatePayment( date( 'Y-m-d H:i:s' ) );
$invoice->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED );
$manager->saveItem( $invoice );
You only need the Aimeos context for this.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Kevin
Posts: 13
Joined: 28 Nov 2017, 19:54

Re: Aimeos manual order creation (webhook Stripe)

Post by Kevin » 22 Dec 2017, 16:11

Thank you for the feedback. Looking at your code I assume you attach an order to an already existing base item. That could work for me. But how do I use the code you provide into a standard Laravel controller?

I defined context like:

Code: Select all

$context = app( '\Aimeos\Shop\Base\Context' )->get( false );
But I receive following error "Locale object not available"...

Can you guide me on this please?

K.

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Aimeos manual order creation (webhook Stripe)

Post by Travin » 24 Dec 2017, 18:11

Hi Kevin!
Could you tell me how do you use Stripe subscriptions? Are you use ai-payments for this? Will you create a new order type at db and at Aimeos for subscriptions?
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

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

Re: Aimeos manual order creation (webhook Stripe)

Post by aimeos » 25 Dec 2017, 13:42

Kevin wrote: I defined context like:

Code: Select all

$context = app( '\Aimeos\Shop\Base\Context' )->get( false );
But I receive following error "Locale object not available"...
If you use false for the get() method, no locale object is added. Using no parameter will add the locale object:
https://aimeos.org/docs/Laravel/Extend_Aimeos
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Kevin
Posts: 13
Joined: 28 Nov 2017, 19:54

Re: Aimeos manual order creation (webhook Stripe)

Post by Kevin » 15 Feb 2018, 14:43

Hi!

Everything is working fine, except the mailing is send in English... Not in the language defined in the base item. How can I use the language that was defined in the base?

Code: Select all

$context = app( '\Aimeos\Shop\Base\Context' )->get(  );
		
		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
		$invoice = $manager->createItem();
		$invoice->setBaseId(101);
		$invoice->setType( \Aimeos\MShop\Order\Item\Base::TYPE_REPEAT );
		$invoice->setDatePayment( date( 'Y-m-d H:i:s' ) );
		$invoice->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED );
		$invoice->setDeliveryStatus(\Aimeos\MShop\Order\Item\Base::STAT_PROGRESS);
		$manager->saveItem( $invoice );

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

Re: Aimeos manual order creation (webhook Stripe)

Post by aimeos » 15 Feb 2018, 21:08

In the released versions, the language ID of the address is used for the e-mail language. In the dev-master branch a fall-back to the language of the order is now implemented
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply