#Songbox-klarna

1 messages · Page 1 of 1 (latest)

south orchid
#

@civic harbor I can try, what's the problem you're facing?

civic harbor
#

Thanks!

#

well... I feel like I'm pretty good with the stripe API but the docs on Klarna are a bit lacking just now, I guess coz its in beta which is totally understandable.

#

first of all if you could tell me if i'm even on the right path

#

I am creating a checkout session, passing in a one time payment with mode => payment and sending this all along to stripe.js

#

on stripe.js page i am creating a source as per the docs I could find

#

but checkout page is still just loading up as normal with only card payment accepted

#

This is my session

$session = Session::create([

            'customer' => $user->stripe_id,
            'payment_method_types' => ['card'],
            'line_items' => [
                [
                    'price' => 'price_1Jcoq0EP0PKPxODIMPPMLQxU',
                    'quantity' => 1
                ]
            ],
            'mode' => 'payment',

            'allow_promotion_codes' => true,
            'success_url' => env('APP_URL').'/account?session_id={CHECKOUT_SESSION_ID}',
            'cancel_url' => env('APP_URL'),
        ]);
#

and this is the stripe.js page:

<script src="https://js.stripe.com/v3/"></script>

<script>
    var stripe = Stripe('{{$pk}}');

    stripe.createSource({
        type: 'klarna',
        amount: 816,
        currency: 'eur',
        klarna: {
            product: 'payment',
            purchase_country: 'DE',
        },
        source_order: {
            items: [{
                type: 'sku',
                description: 'Grey cotton T-shirt',
                quantity: 2,
                currency: 'eur',
                amount: 796,
            }, {
                type: 'tax',
                description: 'Taxes',
                currency: 'eur',
                amount: 20,
            }, {
                type: 'shipping',
                description: 'Free Shipping',
                currency: 'eur',
                amount: 0,
            }],
        },
    }).then(function(result) {
        // handle result.error or result.source
    });

    stripe.redirectToCheckout({
        sessionId: '{{$session->id}}'
    }).then(function (result) {

    });


</script>
#

I'm assuming 'payment_method_types' => ['card'] is where i'm going wrong but i can't find a klarna equivalent

#
Invalid payment_method_types[0]: must be one of alipay, card, ideal, fpx, bacs_debit, bancontact, giropay, p24, eps, sofort, sepa_debit, grabpay, afterpay_clearpay, acss_debit, wechat_pay, boleto, or oxxo
#

👆If i don't choose "card"

south orchid
#

ok one sec

#

you would not create a CheckoutSession and then create a Source, they're completely separate, you can't pass the Source into Checkout or anything like that

civic harbor
#

Oh so i am doing that.... i think. I create the checkout session in a controller which points to tamplate page where the source is created

#

however... i get that i am kinda shooting in the dark here

south orchid
#

and yes, right now Checkout doesn't support taking Klarna payments unfortunately! So you have to integrate it directly(without Checkout) instead

#

now having said all that, now is a bad time to be integrating this

#

the public answer if you have to build this today ASAP is that you have to manually create a Source and authenticate it and do the whole process there, and not use Checkout or PaymentIntents

civic harbor
#

I got this yesterday from you guys. It says checkout now supports klarna.

south orchid
#

but we're rebuilding Klarna so it's supported on Checkout/PaymentIntents

#

oh hmm

civic harbor
#

404

south orchid
#

ok then you're not in the beta

#

and get yourself into that beta so you can use Klarna on Checkout

civic harbor
#

however... support have confirmed to me that klarna is active on my account... but i bet they don't mean the beta. Ok I'll get onto support and try and get into the beta

#

brilliant! I will do that now.

south orchid
#

I really would try to avoid spending time on the Sources integration and just get into that beta

civic harbor
#

yeah... I'm not into that at all. I thought I was on the beta

south orchid
#

well Klarna on Sources is also a beta

#

but instead of releasing it we're replacing it with Klarna on PI + Checkout

#

it's confusing

civic harbor
#

aye but i 100% am only interested in the checkout implementation

south orchid
#

yep, and you're right to be, that is best way to do this

civic harbor
#

Defo

#

may i ask another question

#

You're an actual stripe dev yeah?

south orchid
#

I work for Stripe yes

civic harbor
#

Reason I'm asking... in my dayjob (massive enterprise organisation) the devs would NEVER be allowed to chat to the public like this

#

the setup you guys have is... amazing!

#

this klarna thing is for my side hustle which is fast becoming more than that btw

south orchid
#

interesting!

civic harbor
#

Aye i just have dev envy of you Stripe folks