Code Monkey home page Code Monkey logo

fitpassu / react-native-stripe-payments Goto Github PK

View Code? Open in Web Editor NEW
98.0 10.0 31.0 426 KB

Lightweight, easy to integrate and use React native library for Stripe payments (using Payment Intents) compliant with SCA (strong customer authentication)

License: MIT License

Objective-C 4.38% Ruby 8.56% TypeScript 7.61% Kotlin 58.08% Swift 21.37%
react-native stripe stripe-payment payments ios android strong-customer-authentication payment-intent typescript

react-native-stripe-payments's Introduction

Important!

We highly recommend using official Stripe react native library. This library was created prior to the introduction of the official one and is currently not developed further. It's maintained to support current users but they're also encouraged to migrate to using the official library.

React Native Stripe payments

A well typed React Native library providing support for Stripe payments on both iOS and Android.

React Native Stripe payments

Getting started

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.

Installation

$ 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.

Additional iOS setup

As Stripe SDK is now in Swift, the following changes must be done or the compilation will fail.

  1. Create a "Dummy" swift file (xcode -> open your project -> right click on the folder named after your project, where Info.plist resides -> new File -> Swift -> say YES when asked for the bridging header)
  2. Remove the swift-5.0 search path, or you will get an error about undefined symbols. Take a look here -> react-native-community/upgrade-support#62 (comment)

Usage

Setup

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' });

Validate the given card details

import stripe from 'react-native-stripe-payments';

const isCardValid = stripe.isCardValid({
  number: '4242424242424242',
  expMonth: 10,
  expYear: 21,
  cvc: '888',
});

One-time payments

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
  )

Reusing cards

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!

Development and contribution

Demo app

Unfortunately currently broken.

Demo server

To start local web server which mocks server side behaviour execute yarn server from demo directory.

react-native-stripe-payments's People

Contributors

krinish291 avatar magrinj avatar migleb avatar viktorasl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-stripe-payments's Issues

Project scope?

Hey man good idea of making a new stripe library.
I was wondering do you see the future of the library be a replacement for tipsi-stripe if yes I would love to help in any way. even though my knowledge is mostly ts.
Maybe it would be good if you added stuff in the projects tab so people could see what you are working on

No option for payment amount?

The ReadMe shows the code necessary for completing a One-Time Payment, but does not show how to insert the amount. How do we submit the amount to be paid to the Stripe account?

(Example from the ReadMe)
`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
)`

Can't use chrome debugger

I am getting an Invariant Violation any time I attempt to use the Debugger in React Native. This only occurred after I installed your package.

I looked in your source code and found some methods in the Java package that are synchronous.

After checking the lib/index.tsx file I saw that the StripePayments.init method gets invoked automatically when you use the setOptions method. I found that if I comment out the StripePayments.init line in the compiled JS code, my debugger then starts working properly.

Any advice? Thank you for the library.

Screenshot_1610056399

J

Mmm

CocoaPods could not find compatible versions for pod "react-native-stripe-payments"

[!] CocoaPods could not find compatible versions for pod "react-native-stripe-payments":
In Podfile:
react-native-stripe-payments (from ../node_modules/react-native-stripe-payments)

Specs satisfying the react-native-stripe-payments (from ../node_modules/react-native-stripe-payments) dependency were found, but they required a higher minimum deployment target.

Xcode: 12.2

Is manual capture supported?

I have been trying to implement a solution where I need to use a manual capture from stripe. I am currently generating a client secret where capture_method is set to manual.

When I run stripe.confirmPayment(clientSecret, card), I am getting the following error [Error: requires_capture]. Is there way to manually capture payments using this package?

My app is getting crashed when I'm trying to make payment!

My app is getting crashed when I'm trying to pay using test credentials.
I'm getting card valid to true but not when I go to confirmPayment app crashes without any log or error.

stripe.confirmPayment('client_secret_from_backend', cardDetails)
  .then(result => {
    console.log("result ", result)
  })
  .catch(err =>
    console.log("err ", err)
  )

Issue with library on xcode 14

Hi Team,

Screenshot 2023-02-19 at 16 37 14

I am getting the above error from react-native-stripe-payments(CardDetailsEditView component). I have been on it for almost two days trying to update my app on app store. Please for any suggestion for way round this.

Support Stripe Connect (connected accounts)

First of all, let me applaud you that you're implementing a new way to integrate Stripe into React Native Apps, especially since the future of tipsi-stripe is kind of unknown.

Are there any plans to support Stripe Connect in the future? I did not look into the details yet on what this would entail, but at the very least this would necessitate setting a connected account ID for all payment-related requests to Stripe.

Build error on Xcode 12.5 beta 2

Error: 'new' is unavailable: You cannot directly instantiate an STPIssuingCardPin

This is using react-native-stripe-payments version 1.0.6. Which requires Stripe ~>19.0.
Apparently Stripe issued a fix for this on version 21.4.0, however when trying to force react-native-stripe-payments to use this latest version (Podfile: pod 'Stripe', '~> 21.4.0') throws the error below:

[!] CocoaPods could not find compatible versions for pod "Stripe":
  In Podfile:
    Stripe (~> 21.4.0)

    react-native-stripe-payments (from `../node_modules/react-native-stripe-payments`) was resolved to 1.0.6, which depends on
      Stripe (~> 19.0)

Specs satisfying the `Stripe (~> 21.4.0), Stripe (~> 19.0)` dependency were found, but they required a higher minimum deployment target.

Any ideas?

Update version 14.2.1 of the SDK Stripe Android SDK (com.stripe: stripe-android) version 16.9.0, For security reasons according to Google

Please update version 14.2.1 of the Stripe Android SDK (com.stripe: stripe-android) to version 16.9.0, because Google Play won't let me upload the apk for security reasons.

the reason from the Google Play part is as follows:

Version 14.2.1 of the Stripe Android SDK (com.stripe: stripe-android) makes it easy to transmit or collect personal and sensitive information. This feature must meet the Google Play Disclosure and Consent Notices Visibility Requirements, as well as the applicable privacy policy requirements outlined in the User Data policy. You cannot publish this version due to a problem with this @Policy.

In order to publish it, we recommend that you update the SDK to version 16.9.0, the one recommended by the SDK provider. For more information, contact the vendor of the SDK.

If you have reviewed the policy and you think we made this decision in error, please contact our Policy Support team.


Thank you very much @Fitpassu, for that great library, although stripe recently released a library with support for react native ๐Ÿ‘

confirmPayment method doesnot work, got error There was an unexpected error -- try again in a few seconds

I need to create payment method id for client but never success and always got below error.

React native version
react-native-cli: 2.0.1
react-native: 0.62.0

iOS : 14.0

Error: There was an unexpected error -- try again in a few seconds
    at Object.promiseMethodWrapper [as confirmPayment] (NativeModules.js:103)
    at Stripe.confirmPayment (index.js:16)
    at AddCard.handlePayment (AddCard.js:41)
    at Object.onPress (AddCard.js:100)
    at onPress (TouchableHighlight.js:209)
    at Pressability._performTransitionSideEffects (Pressability.js:655)
    at Pressability._receiveSignal (Pressability.js:589)
    at onResponderRelease (Pressability.js:499)
    at Object.invokeGuardedCallbackImpl (ReactNativeRenderer-dev.js:286)
    at invokeGuardedCallback (ReactNativeRenderer-dev.js:497)

Please help us for above error

Error on confirmPayment

I got this error while trying to confirm the payment.

error : There was an unexpected error -- try again in a few seconds
error : StripeModule.failed

I am using
"react-native": "0.63.3"
"react-native-stripe-payments": "^1.0.6"

Do I need to test it in physical device instead of simulator?

URGENT - Android Build Fails When Targeting API LEVEL 31 & Above

Hey @viktorasl ,

Commendations for the great work you have done with the React Native Stripe Payments implementation.
I've been a user of this library on our mobile app for about a year now and everything seemed to work fine until very recently;

We have just made some very important UI and feature updates to our mobile app, and following the very recent deadline enforcement by Google to ensure that app bundles uploaded to the Play Store must target the API Level 31 & Above, we have also targeted the said API level.

However, since targeting API Level 31 & above, the android app build fails at every attempt with the error reference to the React Native Stripe Payments module. But when we reverse back to target API Level 30 (the previous API level at development time), the build becomes successful.

Is it likely that you can look into this issue to find a possible fix as we are currently stuck on options to get important updates to the Store for our users to access.

Thanks

Umbrella Features โ˜‚๏ธ

Details

Opening this issue so we can coordinate development in this library in order to build all the missing features for full SCA using Stripe. The goal is to add all the missing pieces to the library for the 1st of September.

@viktorasl let me know what you think of the following API:

// Setup Intent
setupPayment(clientSecret, cardDetails)
// Using card details on the fly
confirmPaymentWithCard(clientSecret, cardDetails)
// Using existing card
confirmPaymentWithId(clientSecret, paymentMethodId)

Tasks

  • Setup Intents on iOS
    Setup intents is almost the same setup on iOS as the payment intents, we need to pass card details through to the native side, support billing details, and return a card object on successful creation.
  • Payment Intents Support ID on iOS
    Currently the payment intents only supports taking an object of card details. We can modify this function to make cardParams optional and add a parameter called paymentMethodId, depending on which parameter is present, we can create the STPPaymentIntentParams. This will allow us to confirmPayment with card details or an existing card.

The same above is true for Android:

  • Setup Intents on Android

  • Payment Intents Support ID on Android
    Change this function here to support optionally either cardParams or paymentMethodId.

  • TypeScript API

If I have missed any important features, please let me know in the comments.

issue running module locally

Hi, thanks for the nice module.
Pls, would you advise what I am doing wrong when running it?
I ran both commands:
$ yarn add react-native-stripe-payments

$ npx react-native link react-native-stripe-payments

Built ios app

and running it from VS code using : npx react-native run-ios --verbose

and getting error:
This error is located at:
in App (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
[Tue May 04 2021 15:06:19.848] ERROR TypeError: null is not an object (evaluating 'StripePayments.init')

This error is located at:
in App (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)

Screen Shot 2021-05-04 at 3 08 15 PM

Many thanks

Save Card Details

Any chance you guys are going to implement this? I'd be glad to help out where I can.

stripe.confirmPayment returns an error every time

I'm getting the following error whenever I try to call stripe.confirmPayment with my Stripe secret key and valid CC data:

Error: There was an unexpected error -- try again in a few seconds
    at Object.fn [as confirmPayment] (NativeModules.js:99)
    at Stripe.confirmPayment (index.js:16)
    at handleSave$ (payment-method.tsx:43)
    at tryCatch (runtime.js:45)
    at Generator.invoke [as _invoke] (runtime.js:271)
    at Generator.prototype.<computed> [as next] (runtime.js:97)
    at tryCatch (runtime.js:45)
    at invoke (runtime.js:135)
    at runtime.js:145
    at tryCallOne (core.js:37)

Any idea as to what could be causing this issue? Thanks!

'STPCardScanner' is only available in iOS 13 or newer

Hi Team,

I getting this error while making the build and it's very urgent

Screenshot 2023-03-15 at 4 46 08 PM

/ios/Pods/Stripe/Stripe/STPAddCardViewController.swift:119:35: error: 'STPCardScanner' is only available in iOS 13 or newer
private lazy var cardScanner: STPCardScanner? = nil
^
/ios/Pods/Stripe/Stripe/STPAddCardViewController.swift:12:14: note: add @available attribute to enclosing class
public class STPAddCardViewController: STPCoreTableViewController, STPAddressViewModelDelegate,
^
/ios/Pods/Stripe/Stripe/STPBSBNumberValidator.swift:133:42: warning: 'IndexDistance' is deprecated: All index distances are now of type Int
private let kBSBNumberDashIndex = String.IndexDistance(3)

System Properties

Hardware Overview:

Model Name: MacBook Pro
Model Identifier: Mac14,7
Model Number: Z16R0006KHN/A
Chip: Apple M2
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 8419.60.44
OS Loader Version: 8419.60.44
Serial Number (system): XNCF29M0XY
Hardware UUID: 1A5B2A73-1CBE-5181-B82E-C0806D26B850
Provisioning UDID: 00008112-000E204A3A31401E
Activation Lock Status: Enabled

LocalizableStrings issues on iOS

Hi!
Your library is great, but we can't seem to be able to localize to strings on iOS.
It seems like it's not really finding the Bundle or the associated LocalizableStrings.

We are using the latest versions. Are we missing something?
Can you help us, please?

Thanks.

App Is Crashed On Android

  • Where:
    Build file '/Users/Eysa/FruiteMarketApp/node_modules/react-native-stripe-payments/android/build.gradle' line: 23

  • What went wrong:
    A problem occurred evaluating project ':react-native-stripe-payments'.

Plugin with id 'maven' not found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.