<p>I am trying to create a custom payment gateway by extending / adding it to Omnipay which is already implemented in Craft.</p>

<p>I have used the Ogone and other plugins as base, but I cant seem to get it working properly, probably because Klarna Checkout has quite a different flow than the ones I have tried to copy.</p>

<p>The flow I am trying to create:</p>

<ol>
<li>The user have a cart with items, he press pay / checkout</li>
<li>On the payment page, he selects "Klarna Checkout" as payment option</li>
<li>At this point, we need to give Klarna some information about the customer and the items / price he is going to pay for along with some credentials. If all information is correct, Klarna returns a snippet (payment form) as HTML.</li>
<li>This snipped then needs to be embedded into the payment page (or redirected to a page that displays it).</li>
<li>When the user has payed using this payment form, klarna will redirect the user to a predefined endpoint, where we need to tell him, and Craft that the order is payed for.</li>
</ol>

<p>What I am having problems with is the plugin itself, I have done the initial setup, I can choose it as a payment option and the code runs, but we are having problems with the sendData() function in purchaseRequest.php</p>

<p>This function seems to send data to an endpoint, and get some response, but exactly what that response should be, I cant seem to find out. Since Klarna Checkout do not have an endpoint, but is a PHP class / a set of functions we have imported with Composer, we cant just send data directly to Klarna, but need to create a order request using this class, and that class will then contact Klarna to get the snippet (payment form).</p>

<p>What I am having trouble with is figuring out what this function needs, if we need to use it at all, and how to work around it to display the payment form to the end user.</p>

<p>Any nudge in the right direction would be greatly appreciated!</p>

<ul>
<li>Mathias</li>
</ul>

CC BY-SA 3.0
2017-03-23T02:49:19.577Z
Omnipay is great
wogsland
CC BY-SA 4.0
2018-07-20T09:32:36.907Z
@Syversen Could you solve this? I guess it was Craft Commerce 1, wasn't it?
obs
<plugin-development><plugin-craftcommerce><php><craft-features>
Klarna Checkout - Omnipay
# Klarna Checkout - Omnipay

(Asked by: username_0 on 2017-03-21)

I am trying to create a custom payment gateway by extending / adding it to Omnipay which is already implemented in Craft.

I have used the Ogone and other plugins as base, but I cant seem to get it working properly, probably because Klarna Checkout has quite a different flow than the ones I have tried to copy.

The flow I am trying to create:

1. The user have a cart with items, he press pay / checkout
2. On the payment page, he selects "Klarna Checkout" as payment option
3. At this point, we need to give Klarna some information about the customer and the items / price he is going to pay for along with some credentials. If all information is correct, Klarna returns a snippet (payment form) as HTML.
4. This snipped then needs to be embedded into the payment page (or redirected to a page that displays it).
5. When the user has payed using this payment form, klarna will redirect the user to a predefined endpoint, where we need to tell him, and Craft that the order is payed for.

What I am having problems with is the plugin itself, I have done the initial setup, I can choose it as a payment option and the code runs, but we are having problems with the sendData() function in purchaseRequest.php

This function seems to send data to an endpoint, and get some response, but exactly what that response should be, I cant seem to find out. Since Klarna Checkout do not have an endpoint, but is a PHP class / a set of functions we have imported with Composer, we cant just send data directly to Klarna, but need to create a order request using this class, and that class will then contact Klarna to get the snippet (payment form).

What I am having trouble with is figuring out what this function needs, if we need to use it at all, and how to work around it to display the payment form to the end user.

Any nudge in the right direction would be greatly appreciated!

* Mathias

**Tags:** plugin-development, plugin-craftcommerce, php, craft-features
> **Comments:**
> **username_1**: Omnipay is great  
> **username_2**: @Syversen Could you solve this? I guess it was Craft Commerce 1, wasn't it?  

---

## 0 answers

