0.0.2 • Published 5 years ago

react-native-stripe-shop v0.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

react-native-stripe-shop

Basic Stripe integration with React Native. Oh and also npm install friendly!

The project just started, feel free to contribute. Forked from bamlab.

Getting started

$ npm install react-native-stripe-shop --save

Installation

iOS

  1. Settup cocoapod if not done yet.
  2. Add in your podfile, the following lines :
  pod 'react-native-stripe', path: '../../..'
  pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga/yoga.podspec'
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'DevSupport'
  ]
  1. Run pod install in your ios/ folder.

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNStripePackage; to the imports at the top of the file
  • Add new RNStripePackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-stripe'
    project(':react-native-stripe').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-stripe/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-stripe')

Usage

import Stripe from 'react-native-stripe';

Stripe.init({
  publishableKey: 'pk_...',
});

Stripe.createTokenWithCard({
    number: '4111 1111 1111 1111',
    cvc: '123',
    expMonth: 11,
    expYear: 22,
}).then(res => {
  console.log(res.token);
});