Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-klarna-inapp-sdk

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-klarna-inapp-sdk

This library wraps Klarna Mobile SDK and exposes its functionality as React Native components.

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
decreased by-29.08%
Maintainers
1
Weekly downloads
 
Created
Source

Klarna Mobile SDK React Native

NPM React Native Platforms License Developed at Klarna

This library wraps Klarna Mobile SDK and exposes its functionality as React Native components. It currently supports Klarna Payments via a Payment View component.

This repository also includes a test application that you can use to see how it works.

SDK for Other Platforms

Requirements

  • iOS 10 or later.
  • Android 4.4 or later.

Documentations

Getting started

Add Dependency

NPM
npm install react-native-klarna-inapp-sdk --save
Yarn
yarn add react-native-klarna-inapp-sdk

Warning regarding Android integration

Both the iOS and Android integrations depend on the native SDK.

We've experienced issues with React Native 59 and above where 3rd party Gradle repositories won't be recognized in the Android project's build.gradle. To address this, you'll need to add a reference to the repository in your own app's build.gradle.

You can do it by adding the lines between the comments below:

allprojects {
    repositories {
        ...
        // Add the lines below
        maven {
            url 'https://x.klarnacdn.net/mobile-sdk/'
        }
    }
}

Usage

You can import the KlarnaPaymentView from the library. You'll then be able to add it as a component to your app. This component exposes callbacks as props and methods you can call via the component's ref.

The view will self-size height-wise and grow it fill it containing view's width.

Props

It has the following props:

NameTypeDescription
categoryStringThe payment method category you want to render in your view.
returnUrlStringAn app-defined URL scheme the component uses to return customers to your app.
onInitialized() => {}The initialize call completed.
onLoaded() => {}The load call completed.
onLoadedPaymentReview() => {}The load payment review call completed.
onAuthorized(approved, authToken, finalizeRequired) => {}The authorize call completed.
onReauthorized(approved, authToken) => {}The reauthorize call completed.
onFinalized(approved, authToken) => {}The finalize call completed.
onError(error) => {}An error occurred.

Return URL

You can read more about how the return URL works and how to add it tou your iOS application here and for your Android application here.


Prop callback parameters


approved: boolean

Determines whether the previous operation was successful and yielded an authorization token.

Available on:
  • onAuthorized
  • onReauthorized
  • onFinalized

authToken: string | null

If authorize(), reauthorize() or finalize() succeeded, they will return a token you can submit to your backend.

Available on:
  • onAuthorized
  • onReauthorized
  • onFinalized

finalizeRequired: boolean | null

If authorize() requires that you additionally call finalize(), .

Available on:
  • onAuthorized

error: KlarnaPaymentsSDKError

If a method failed, onError() will let you know via an error object. Contains name, message, action, isFatal, sessionId properties.

Available on:
  • onError


View methods

Each payment view exposes a set of methods via a view's ref. You can see in the test app or in the below example how these can be called. The methods are the following:


initialize()

Initializes the view with a session token. You have to have added the view to your application and supplied a payment method category.

Parameters
NameTypeDescription
clientTokenstringThe client token you get from Klarna Payments API.

load()

Loads the view. This will render content in the view.

Parameters
NameTypeDescription
sessionDatastring | undefinedA JSON object with updated session data serialized into a string.

loadPaymentReview()

Renders a description of the payment terms your customer has agreed to.

Once a session is authorized, you can then either render a payment review in the existing payment view or initialize() a new payment view with the same session token and call this method.

Note:

This only works with specific payment methods and countries.


authorize()

Authorizes the payment session.

Parameters
NameTypeDescription
autoFinalizeboolean | undefinedA flag used to turn on/off auto-finalization for direct bank transfer.
sessionDatastring | undefinedA JSON object with updated session data serialized into a string.

reauthorize()

If the details of the session (e.g. cart contents, customer data) have changed, call this to update the session and get a new authorization token.

Parameters
NameTypeDescription
sessionDatastring | undefinedA JSON object with updated session data serialized into a string.

finalize()

If a specific payment method needs you to trigger a second authorization, call finalize when you're ready.

Parameters
NameTypeDescription
sessionDataString | undefinedA JSON object with updated session data serialized into a string.

Support

If you are having any issues using the SDK in your project or if you think that something is wrong with the SDK itself, please follow our support guide.

Contribution

If you want to contribute to this project please follow our contribution guide.

License

This project is licensed under Apache License, Version 2.0.

Keywords

FAQs

Package last updated on 22 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc