Updating Payment Info using API

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!
MuraliGK
Posts: 2
Joined: 28 Nov 2017, 17:30

Updating Payment Info using API

Post by MuraliGK » 28 Nov 2017, 17:57

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.

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

Re: Updating Payment Info using API

Post by aimeos » 28 Nov 2017, 22:38

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?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

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

Re: Updating Payment Info using API

Post by aimeos » 30 Nov 2017, 10:14

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

MuraliGK
Posts: 2
Joined: 28 Nov 2017, 17:30

Re: Updating Payment Info using API

Post by MuraliGK » 01 Dec 2017, 07:01

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.

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

Re: Updating Payment Info using API

Post by aimeos » 01 Dec 2017, 10:44

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 );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply