A well typed React Native library providing support for Stripe payments on both iOS and Android.
Starting September 14, 2019 new payments regulation is being rolled out in Europe, which mandates Strong Customer Authentication (SCA) for many online payments in the European Economic Area (EEA). SCA is part of the second Payment Services Directive (PSD2).
This library provides simple way to integrate SCA compliant Stripe payments into your react native app with a first class Typescript support.
$ yarn add react-native-stripe-payments
$ npx react-native link react-native-stripe-payments
The library ships with platform native code that needs to be compiled together with React Native. This requires you to configure your build tools which can be done with autolinking.
First of all you have to obtain Stripe account publishabe key. And then you need to set it for module.
import stripe from 'react-native-stripe-payments';
stripe.setOptions({ publishingKey: 'STRIPE_PUBLISHING_KEY' });
import stripe from 'react-native-stripe-payments';
const isCardValid = stripe.isCardValid({
number: '4242424242424242',
expMonth: 10,
expYear: 21,
cvc: '888',
});
import stripe from 'react-native-stripe-payments';
const cardDetails = {
number: '4242424242424242',
expMonth: 10,
expYear: 21,
cvc: '888',
}
stripe.confirmPayment('client_secret_from_backend', cardDetails)
.then(result => {
// result of type PaymentResult
})
.catch(err =>
// error performing payment
)
Not supported yet, though as we’re highly invested in development of our product which depends on this library we’ll do it as soon as possible!
Author: Fitpassu
GitHub: https://github.com/Fitpassu/react-native-stripe-payments
#react-native #react #mobile-apps