## Confirm a Klarna setup Use `stripe.confirmKlarnaSetup` in the [Klarna Payments with Setup Intents](/payments/klarna/set-up-payment.md) flow when the customer submits your setup form. When called, it will confirm the `SetupIntent` with `data` you provide, and it will automatically redirect the customer to authorize the setup. Once authorization is complete, the customer will be redirected back to your specified `return_url`. > Note that `stripe.confirmKlarnaSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmKlarnaSetup` will trigger a redirect when successful. If there is an error, it will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmKlarnaSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (string | object) The `id` of an existing [PaymentMethod](/api/payment_methods.md). See the use case sections below for details. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Use case: with an existing payment method Use `stripe.confirmKlarnaSetup` with an existing `PaymentMethod` by passing its `id` to `payment_method`. The `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with existing payment method ```js stripe .confirmKlarnaSetup('{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmKlarnaSetup( '{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmKlarnaSetup` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe .confirmKlarnaSetup('{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmKlarnaSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with self collected data Your customer's email and billing country are required for the Klarna authorization to succeed. You can pass in these properties directly to create a new `PaymentMethod` and confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm with the customer's email and billing country. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `email` and `address.country` are required. - `email` (string) **required** The customer's email. - `address` (object) **required** The customer's billing address. - `country` (string) **required** The customer's billing country. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with self collected data ```js stripe .confirmKlarnaSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { email: 'jenny@example.com', address: { country: 'DE', }, }, }, // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmKlarnaSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Confirm a Klarna setup ```js stripe .confirmKlarnaSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { email: 'jenny@example.com', address: { country: 'DE', }, }, }, // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmKlarnaSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ```