Page 1 of 1

Updating Payment Info using API

Posted: 28 Nov 2017, 17:57
by MuraliGK
Hi Everyone,

I'm new to aimeos, and I'm using aimeos laravel package as the backend. I'm developing the frontend using react native, so that I can use it for both web and mobile.

My payment gateway is javascript based, once the payment gateway returns the status, i need to update the payment status in aimeos using an API. I have gone through the API documentation but couldn't find a way to update the payment status.

My environment: Laravel 5.5, PHP 7.1.5, Aimeos 2017.10

Kindly let me know how to proceed further.

Thanks in Advance.

Re: Updating Payment Info using API

Posted: 28 Nov 2017, 22:38
by aimeos
The JSON REST API doesn't currently have an endpoint for updating the order payment status. The main problem is: How can you update the payment status in a secure way without enabling attackers to update the status to any value theirselves?

Re: Updating Payment Info using API

Posted: 30 Nov 2017, 10:14
by aimeos
The best and most secure way to update the payment status in your setup is to pass the notification (update) URL to the payment gateway and use the returned payment status only for displaying it to the customer. The payment gateway will send a "server to server" notification with the payment status at the same time and will update the status value in the database.

Re: Updating Payment Info using API

Posted: 01 Dec 2017, 07:01
by MuraliGK
Thanks for your suggestion. I have checked the database tables, "mshop_order" is the table having the info about the payment status, is it enough to update this table or I need to update any other tables as well. Is there any predefined class / method available to update the payment status.

Re: Updating Payment Info using API

Posted: 01 Dec 2017, 10:44
by aimeos
You should always use the order controller to update the order items:
https://aimeos.org/api/latest/class-Aim ... ndard.html

Code: Select all

$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'order' );
$item = $cntl->getItem( $id, false );
$item->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED );
$cntl->saveItem( $item );