Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-native-klarna-inapp-sdk
Advanced tools
This library wraps Klarna Mobile SDK and exposes its functionality as React Native components.
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.
npm install react-native-klarna-inapp-sdk --save
yarn add react-native-klarna-inapp-sdk
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/'
}
}
}
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.
It has the following props:
Name | Type | Description |
---|---|---|
category | String | The payment method category you want to render in your view. |
returnUrl | String | An 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. |
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.
boolean
Determines whether the previous operation was successful and yielded an authorization token.
onAuthorized
onReauthorized
onFinalized
string | null
If authorize()
, reauthorize()
or finalize()
succeeded, they will return a token you can submit
to your backend.
onAuthorized
onReauthorized
onFinalized
boolean | null
If authorize()
requires that you additionally call finalize()
, .
onAuthorized
KlarnaPaymentsSDKError
If a method failed, onError()
will let you know via an error object. Contains name
, message
,
action
, isFatal
, sessionId
properties.
onError
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:
Initializes the view with a session token. You have to have added the view to your application and supplied a payment method category.
Name | Type | Description |
---|---|---|
clientToken | string | The client token you get from Klarna Payments API. |
Loads the view. This will render content in the view.
Name | Type | Description |
---|---|---|
sessionData | string | undefined | A JSON object with updated session data serialized into a string. |
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.
This only works with specific payment methods and countries.
Authorizes the payment session.
Name | Type | Description |
---|---|---|
autoFinalize | boolean | undefined | A flag used to turn on/off auto-finalization for direct bank transfer. |
sessionData | string | undefined | A JSON object with updated session data serialized into a string. |
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.
Name | Type | Description |
---|---|---|
sessionData | string | undefined | A JSON object with updated session data serialized into a string. |
If a specific payment method needs you to trigger a second authorization, call finalize when you're ready.
Name | Type | Description |
---|---|---|
sessionData | String | undefined | A JSON object with updated session data serialized into a string. |
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.
If you want to contribute to this project please follow our contribution guide.
This project is licensed under Apache License, Version 2.0.
[2.2.0] - 2023-12-22
FAQs
This library wraps Klarna Mobile SDK and exposes its functionality as React Native components.
The npm package react-native-klarna-inapp-sdk receives a total of 1,031 weekly downloads. As such, react-native-klarna-inapp-sdk popularity was classified as popular.
We found that react-native-klarna-inapp-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.