#Adrian Moreno

1 messages · Page 1 of 1 (latest)

rich kindleBOT
finite coral
#

hi! well you would use a clientSecret yes. It's no different from just using the PaymentSheet, so there shouldn't be anything different or any changes you need to make to billing detail collection, you just pass a PaymentIntent client_secret to the PaymentSheet as normal, if you have klarna in the payment_method_types of the PaymentIntent it should just show up as an option in the sheet.

sterile cave
#

I've done this but I'm not sure if it's correct since it's my first time using Klarna with Stripe:

let klarnaMethodParams = STPPaymentMethodParams(
klarna: STPPaymentMethodKlarnaParams(), billingDetails: billingDetails, metadata: nil)
let paymentIntentParams = STPPaymentIntentParams(clientSecret: clientSecret)
paymentIntentParams.paymentMethodParams = klarnaMethodParams
let paymentHandler = STPPaymentHandler.shared()
paymentHandler.confirmPayment(
paymentIntentParams,
with: authContext

finite coral
#

what you have there might work, was there an error when you tried?

sterile cave
#

I'm trying to get again the error so I can send you. It'll take me 1 minute

#

Do I need to complete the STPPaymentCardTextField to use Klarna? Because I think that was the issue

finite coral
#

you wouldn't need that no, since Klarna doesn't use card details, it's a redirect to Klarna's website(the redirect would happen when you confirm the PaymentIntent)

sterile cave
#

Okey, then it's another issue. I'll continue searching and will ask you better when I have more info, thanks

#

Oh, do I need StripeIsReady value?

finite coral
#

I'm not familiar with that value

sterile cave
#

Do I need to add the payment_method_type? Or it's automatically selected with the type of params I use?

finite coral
#

that doc seems completely unrelated to what you were asking about

#

it's for Checkout(hosted payment page), but you were talking about a mobile integration using iOS components and a directly-created PaymentIntent

sterile cave
#

Hmmmm, so I don't need it at all, good to know, thanks

#

Sorry for the noob questions, still trying to understand it all to know the best way to develop this. Thank you for your patience.

#

Okey, I updated the backend and now it's "working" but when I click on Klarna pay I always arrive to switch case Failed.

finite coral
#

can you share some code/screenshot of the UI/the PaymentIntent pi_xxx ?

#

also look in XCode for any errors in the logs for the app

#

I can try to help but again my advice here is to use the PaymentSheet, looks like maybe you're doing this in some custom way that I'm not too familiar with

sterile cave
#

I may change to PaymentSheet, but I had it like this and just wanted to add Klarna and it seems is more complicated than I initially though

#

That's the log I get:

2022-12-12 14:38:18.242734+0100 xxxx[81067:6386558] LOG ANALYTICS: ["device_type": "iPhone14,5", "app_name": "Sporttips", "source_type": "klarna", "apple_pay_enabled": 1, "required_shipping_address_fields": "none", "ui_usage_level": "card_text_field", "required_billing_address_fields": "zip", "analytics_ua": "analytics.stripeios-1.0", "product_usage": ["STPPaymentCardTextField"], "app_version": "2.1.9", "install": "S", "bindings_version": "22.6.0", "os_version": "16.1.1", "company_name": "xxxx", "event": "stripeios.payment_intent_confirmation", "additional_payment_methods": "none", "pay_var": "legacy", "shipping_type": "shipping", "apple_merchant_identifier": "unknown", "additional_info": [], "ocr_type": "none", "publishable_key": "pk_....."]

finite coral
#

can you capture and log the error?

#

in confirmPayment, don't just use _ to ignore the arguments , you can do

(status, paymentIntent, error) in
...
case .failed:
 if let error = error {
                        print("Payment failed: \n\(error.localizedDescription)")
                        let fullError = error as NSError
                        print(fullError.code)
                        print(fullError.description)
                        dump(fullError.userInfo)
                    }

for example

sterile cave
#

Yep, will do right now

finite coral
#

and again, share the PaymentIntent ID pi_xxx

finite coral
sterile cave
#

I had already this custom way, that's why I didn't want to change it.
But if I can't get it to work then I'll change to PaymentSheet

#

It seems I have to add klarna to the payment_method_type.

Error Domain=com.stripe.lib Code=50 "Se ha producido un error inesperado. Vuelve a intentarlo en unos segundos" UserInfo={com.stripe.lib:StripeErrorTypeKey=invalid_request_error, com.stripe.lib:ErrorMessageKey=No se admite el PaymentMethod provisto (klarna) para este PaymentIntent. Adjunta un PaymentMethod de uno de los siguientes tipos: card. También puedes actualizar los payment _method _types permitidos para este PaymentIntent a fin de incluir "klarna"., NSLocalizedDescription=Se ha producido un error inesperado. Vuelve a intentarlo en unos segundos, com.stripe.lib:StripeErrorCodeKey=}
▿ 4 key/value pairs
▿ (2 elements)
- key: "com.stripe.lib:StripeErrorTypeKey"
- value: "invalid_request_error"
▿ (2 elements)
- key: "com.stripe.lib:ErrorMessageKey"
- value: "No se admite el PaymentMethod provisto (klarna) para este PaymentIntent. Adjunta un PaymentMethod de uno de los siguientes tipos: card. También puedes actualizar los payment _method _types permitidos para este PaymentIntent a fin de incluir "klarna"."

I'm trying to get the paymentIntent id but it's always nil which is weird

finite coral
#

yes you need to add "klarna" in the payment_method_types of the PaymentIntent you create on the backend server

sterile cave
#

$paymentIntent = $stripe->paymentIntents->create([
'payment_method_types' => ['card','klarna'],
'amount' => $finalPrice*100,
'currency' => 'eur',
'setup_future_usage' => 'off_session',
'customer' => $userExist->getStripeCustomerId(),
]);

    $paymentIntentDTO = new StripePaymentIntentDTO();
    $paymentIntentDTO->setId($paymentIntent->id);
    $paymentIntentDTO->setClientSecret($paymentIntent->client_secret);
    $paymentIntentDTO->setAmount($paymentIntent->amount);
#

So this should work right?

toxic plank
#

Hey karllekko had to step out but I can help out here.

sterile cave
#

No problem, thanks for your help

toxic plank
#

Like they said, you need to add klarna to the payment_method_types argument when creating that payment intent

#

I think that would look like

            'payment_method_types' => ['card','klarna'],
            'amount' => $finalPrice*100,
            'currency' => 'eur',
            'setup_future_usage' => 'off_session',
            'customer' => $userExist->getStripeCustomerId(),
            'payment_method_types' => ['klarna']
        ]);```
sterile cave
#

I need payment_method_types twice?

#

One at the beginning and another one at the end?

toxic plank
#

Whoops sorry I don't know how I missed that in your code

#

You only need it one

#

My bad. Need more coffee

sterile cave
#

So my code should be fine, right?

toxic plank
#

Correct, should work as far as I can see

sterile cave
#

Okey, will try then with that new part, thanks!