Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Placing order using examples doesn't bounce browser to Klarna #40

Open
ghost opened this issue Jul 21, 2019 · 0 comments
Open

Placing order using examples doesn't bounce browser to Klarna #40

ghost opened this issue Jul 21, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 21, 2019

I'm trying to work with the a direct integration of the Klarna Payments API. I've been following the integration guide and I'm up to the Place Order stage (https://developers.klarna.com/documentation/klarna-payments/integration-guide/place-order). I'm using their example script to place an order (https://github.com/klarna/kco_rest_php/blob/v4.x/docs/examples/PaymentsAPI/Orders/create_order.php).

Upon redirecting the user, the user is sent straight to the confirmation page rather than a Klarna page to enter their billing details (as described in the integration guide above).

I post the authorization_token to their example script using a form. Their example script responds with an array containing a redirect_url, which I redirect the script to. However, this leads to the order_confirmation page that is passed as an argument to order->create().

// The form I'm using to post to their example script:

form action="klarna_order.php" method="post"
input id="authorization_token" name="authorization_token" type="hidden"
input type="submit" value="Submit"
/form

// The part where the order is created and I redirect the page in the example // script:

try {
$order = new Klarna\Rest\Payments\Orders($connector, $authorizationToken);
$data = $order->create($data);
print_r($data);
header('Location: '.$data['redirect_url']);
die();
} catch (Exception $e) {
echo 'Caught exception: ' . $e->getMessage() . "\n";
}

The output of the klarna_order.php file (their example file) is this, which looks right:

'Array ( [order_id] => 1caa1e86-8e71-7bfa-bdd2-ff718365f1af [redirect_url] => https://klarna-payments-eu.playground.klarna.com/v1/sessions/dfa44305-aa56-7861-ac51-fee7c42ce986/redirect [fraud_status] => ACCEPTED [authorized_payment_method] => Array ( [type] => invoice ) )'

If I redirect them to the redirect_url in the response, as their guide says, the browser goes straight to the order_confirmation page instead of a Klarna page where the customer can enter their billing details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants