Implementing Klarna Checkout service not working
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Implementing Klarna Checkout service not working
Hi.
I'm having issues with understanding how to setup Klarna KCO from https://github.com/MyOnlineStore/omnipa ... a-checkout
I've installed ai-payments
I installed Klarna Checkout via composer require myonlinestore/omnipay-klarna-checkout
When setting up the new service, I've set
Type : Payment
Provider : OmniPay
Then I got the default opt/values for OmniPay
Then I added username & secret from our sandbox account at klarna
and type: KlarnaCheckout (tried with Klarna.Checkout as well)
The service shows as available in checkout, but when I go to pay I get "Class '\Omnipay\KlarnaCheckout\Gateway' not found"
In the https://github.com/MyOnlineStore/omnipa ... ateway.php I can see that the namespace is MyOnlineStore\Omnipay\KlarnaCheckout
So either I don't understand what to write in option/value "Type", or I've missed something else, perhaps in config files?
Never set up things like this via OmniPay/Aimeos before, just in pure code. So all help is appreciated.
Cheers/Dan
I'm having issues with understanding how to setup Klarna KCO from https://github.com/MyOnlineStore/omnipa ... a-checkout
I've installed ai-payments
I installed Klarna Checkout via composer require myonlinestore/omnipay-klarna-checkout
When setting up the new service, I've set
Type : Payment
Provider : OmniPay
Then I got the default opt/values for OmniPay
Then I added username & secret from our sandbox account at klarna
and type: KlarnaCheckout (tried with Klarna.Checkout as well)
The service shows as available in checkout, but when I go to pay I get "Class '\Omnipay\KlarnaCheckout\Gateway' not found"
In the https://github.com/MyOnlineStore/omnipa ... ateway.php I can see that the namespace is MyOnlineStore\Omnipay\KlarnaCheckout
So either I don't understand what to write in option/value "Type", or I've missed something else, perhaps in config files?
Never set up things like this via OmniPay/Aimeos before, just in pure code. So all help is appreciated.
Cheers/Dan
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Re: Implementing Klarna Checkout service not working
They use a different namespace like you mention (which isn't according to the Omnipay standards) and thus, the gateway class won't be found. The only option now is to create a custom Aimeos service payment provider that extends from the Omnipay provider class and overwrites the getProvider() method:
https://github.com/aimeoscom/ai-payment ... #L702-L712
https://github.com/aimeoscom/ai-payment ... #L702-L712
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Implementing Klarna Checkout service not working
Ok, thank you.
That's unfortunate of them, especially since they are on Omnipay list of plugins.
I'll take a look at creating a custom provider as you suggest.
But in theory, should I change the namespace in their code, then it should work with your Omnipay privider?
I won't do that since it's breaking all their updates of course, but only so I understand.
/Dan
That's unfortunate of them, especially since they are on Omnipay list of plugins.
I'll take a look at creating a custom provider as you suggest.
But in theory, should I change the namespace in their code, then it should work with your Omnipay privider?
I won't do that since it's breaking all their updates of course, but only so I understand.
/Dan
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Re: Implementing Klarna Checkout service not working
Unfortunately, this doesn't mean that the driver fully complies to the specs as there's no test suite to verify that.
Yes and you should create a PR or an issue telling them that their driver doesn't comply to Omnipay standards because this doesn't work:
Code: Select all
Omnipay\Omnipay::create( 'KlarnaCheckout' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Implementing Klarna Checkout service not working
I'll post an issue.
For now I'm slowly getting closer.
I've created a new provider in my extension that overrides the getProvider method from OmniPay
The provider is now visible under payment provider, and to init it successfully, I need to add "type": when I set it up instead of KlarnaCheckout, it seems to work, up to pressing pay, but then complains that the items array is empty, so now I'm getting to the point of figuring out all parameters it needs.
So thank you for the help so far
For now I'm slowly getting closer.
I've created a new provider in my extension that overrides the getProvider method from OmniPay
Code: Select all
<?php
namespace Aimeos\MShop\Service\Provider\Payment;
class KlarnaKco
extends \Aimeos\MShop\Service\Provider\Payment\OmniPay
implements \Aimeos\MShop\Service\Provider\Payment\Iface
{
/**
* Tries to get an authorization or captures the money immediately for the given
* order if capturing isn't supported or not configured by the shop owner.
*
* @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
* @param array $params Request parameter if available
* @return \Aimeos\MShop\Common\Helper\Form\Standard Form object with URL, action
* and parameters to redirect to (e.g. to an external server of the payment
* provider or to a local success page)
*/
public function process( \Aimeos\MShop\Order\Item\Iface $order, array $params = [] ) : ?\Aimeos\MShop\Common\Helper\Form\Iface
{
// perform your actions
return parent::process( $order, $params );
}
/**
* Returns the KlarnaKCO gateway provider object.
*
* @return \MyOnlineStore\Omnipay\KlarnaCheckout\GatewayInterface Gateway provider object
*/
protected function getProvider() : \MyOnlineStore\Omnipay\KlarnaCheckout\GatewayInterface
{
if( !isset( $this->provider ) )
{
$this->provider = OPay::create( $this->getValue( 'type' ) );
$this->provider->setTestMode( (bool) $this->getValue( 'testmode', false ) );
$this->provider->initialize( $this->getServiceItem()->getConfig() );
}
return $this->provider;
}
}
Code: Select all
\MyOnlineStore\Omnipay\KlarnaCheckout\Gateway
So thank you for the help so far
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Re: Implementing Klarna Checkout service not working
Your implementation of getProvider() is wrong. It must be:
Alternatively, you may not need to overwrite this method and use the Omnipay service provider if you add "\MyOnlineStore\Omnipay\KlarnaCheckout\Gateway" as type.
Code: Select all
protected function getProvider() : \Omnipay\Common\GatewayInterface
{
if( !isset( $this->provider ) )
{
$this->provider = new \MyOnlineStore\Omnipay\KlarnaCheckout\Gateway();
$this->provider->setTestMode( (bool) $this->getValue( 'testmode', false ) );
$this->provider->initialize( $this->getServiceItem()->getConfig() );
}
return $this->provider;
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Implementing Klarna Checkout service not working
Ah, ok.
Fixed the provider override where I was wrong, thanx.
Still getting the "The items parameter is required" when trying to pay
Also tried with the standard OmniPay provider and the type = \MyOnlineStore\Omnipay\KlarnaCheckout\Gateway
I'm getting the exact same result, so I think I'm missing something else here.
Fixed the provider override where I was wrong, thanx.
Still getting the "The items parameter is required" when trying to pay
Also tried with the standard OmniPay provider and the type = \MyOnlineStore\Omnipay\KlarnaCheckout\Gateway
I'm getting the exact same result, so I think I'm missing something else here.
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Re: Implementing Klarna Checkout service not working
After a lot of debugging, everything points to the OmniPay gateway not getting the items from the basket plus having different parameter names than expected in the Klarna service.
When I'm dumping the object here, there is no info on what products are in the basket: $data = $this->getData( $base, $order->getId(), $params );
Then when processOrder tries to send $this->sendRequest( $order, $data ) , the validation of what the klarna service needs acc to their specification for authorisation fails.
So either I'm totally lost here, or there is something odd going on.
When I'm dumping the object here, there is no info on what products are in the basket: $data = $this->getData( $base, $order->getId(), $params );
Then when processOrder tries to send $this->sendRequest( $order, $data ) , the validation of what the klarna service needs acc to their specification for authorisation fails.
So either I'm totally lost here, or there is something odd going on.
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Re: Implementing Klarna Checkout service not working
The Omnipay driver requires the products which are not passed by the Omnipay service provider.
Like you already noticed, the driver uses non-standard names for URLs and maybe there are other things that are non-standard too. The only options are now:
1.) fork the repository and make the code standard compliant
2.) create a custom Aimeos service provider
Like you already noticed, the driver uses non-standard names for URLs and maybe there are other things that are non-standard too. The only options are now:
1.) fork the repository and make the code standard compliant
2.) create a custom Aimeos service provider
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: Implementing Klarna Checkout service not working
Right, thank you,
It will have to be a custom service provider then.
It will have to be a custom service provider then.
_____________
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25
Laravel 8 with Aimeos 2021.10.7 + Marketplace. Setup via composer. Mac with Valet and MySql 8.0.25