checkout process with omnipay-pagseguro

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!
Mattheus
Posts: 2
Joined: 04 Jun 2020, 12:33

checkout process with omnipay-pagseguro

Post by Mattheus » 04 Jun 2020, 13:03

My setup:
"aimeos/aimeos-laravel": "~2019.10",
"aimeos/ai-payments": "~2019.10",
"abdala/omnipay-pagseguro": "^1.3.0",
PHP 7.4.6 on linux

Hello,

I'm new to aimeos and love it. Thank's for the great work !
I'm having trouble implementing the PagSeguro gateway for Omnipay as I'm getting the following error during the checkout process:

Code: Select all

Symfony\Component\Debug\Exception\FatalThrowableError
Argument 1 passed to Aimeos\MShop\Service\Provider\Payment\OmniPay::getRedirectForm()
must be an instance of Omnipay\Common\Message\RedirectResponseInterface,
instance of Omnipay\PagSeguro\Message\PurchaseResponse given,
called in */ext/ai-payments/lib/custom/src/MShop/Service/Provider/Payment/OmniPay.php on line 894
Do you have any clue what is causing my problem here? Thank you for your help.

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

Re: checkout process with omnipay-pagseguro

Post by aimeos » 05 Jun 2020, 14:32

The response object you return when

Code: Select all

$response = $provider->purchase( $data )->send();
is called must return a response object that implements

Code: Select all

Omnipay\Common\Message\RedirectResponseInterface
in case that

Code: Select all

$response->isRedirect()
returns "true". Then,

Code: Select all

$response->getRedirectData()
$response->getRedirectUrl()
$response->getRedirectMethod()
can be used here:
https://github.com/aimeoscom/ai-payment ... #L816-L830
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Mattheus
Posts: 2
Joined: 04 Jun 2020, 12:33

Re: checkout process with omnipay-pagseguro

Post by Mattheus » 09 Jun 2020, 14:52

Thank you for your explanation, I got it working by simply implementing

Code: Select all

Omnipay\Common\Message\RedirectResponseInterface
in Omnipay\PagSeguro\Message\PurchaseResponse. I hope that was the proper way to go about it.

However I have a subsequent problem : it seems that the PagSeguro API gives me a code 400 - Bad Request because it is expecting to receive the items' details (description, quantity, amount...) in the purchase request. How can I include those informations?

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

Re: checkout process with omnipay-pagseguro

Post by aimeos » 11 Jun 2020, 10:59

You have to extend the Omnipay.php class in the ai-payment package like done for other gateways because detailed order data is not passed to the payment gateway by default:
https://github.com/aimeoscom/ai-payment ... er/Payment

The getData() method is a good one for adding those data:
https://github.com/aimeoscom/ai-payment ... #L678-L706
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply