https://github.com/bamlab/react-native-stripe
https://github.com/bamlab/react-native-stripe
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bamlab/react-native-stripe
- Owner: bamlab
- Created: 2018-01-28T17:33:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T20:46:40.000Z (over 3 years ago)
- Last Synced: 2024-04-15T00:00:08.878Z (about 2 years ago)
- Language: Objective-C
- Size: 682 KB
- Stars: 32
- Watchers: 7
- Forks: 12
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-stripe
Basic Stripe integration with React Native.
The project just started, feel free to contribute.
## Getting started
`$ npm install react-native-stripe --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'
]
```
3. 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
2. 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')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-stripe')
```
## Usage
```javascript
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);
});
```