forked from tolu360/react-native-paystack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ yarn add react-native-paystack | |
``` | ||
|
||
### Versioning | ||
- For `RN <=0.39` use version 2+ e.g. react-native-paystack@2.1.4 | ||
- For `RN >=0.40` use version 3+ e.g. react-native-paystack@3.0.4 | ||
- For `RN <=0.39` use version 2+ e.g. react-native-paystack@2.2.0 | ||
- For `RN >=0.40` use version 3+ e.g. react-native-paystack@3.1.0 | ||
|
||
### Configuration | ||
|
||
|
@@ -40,7 +40,7 @@ yarn add react-native-paystack | |
react-native link react-native-paystack | ||
``` | ||
- (iOS only): The next steps are necessary for iOS at this time as publishing to NPM seems to break symlinks contained in the Paystack iOS framework shipped with this package, thus causing XCode build errors. | ||
- Download a fresh copy of the `Paystack iOS framework` from [Dropbox](https://www.dropbox.com/s/rxds20w3ud4wqs2/PaystackiOS%20%283%29.zip?dl=0) or from their [releases page on Github](https://github.com/PaystackHQ/paystack-ios/releases/). | ||
- Download a fresh copy of the `Paystack iOS framework` from their [releases page on Github](https://github.com/PaystackHQ/paystack-ios/releases/). | ||
- Extract `Paystack.framework` from the downloaded zip. | ||
- In XCode's "Project navigator", right click on project name folder ➜ `Add Files to <Your-Project-Name>`. Ensure `Copy items if needed` and `Create groups` are checked and select your copy of `Paystack.framework`. | ||
- Your files tree in XCode should look similar to the screenshot below: | ||
|
@@ -101,7 +101,7 @@ protected List<ReactPackage> getPackages() { | |
{ | ||
... | ||
|
||
[Paystack setDefaultPublishableKey:@"INSERT-PUBLIC-KEY-HERE"]; | ||
[Paystack setDefaultPublicKey:@"INSERT-PUBLIC-KEY-HERE"]; | ||
... | ||
|
||
} | ||
|
@@ -110,27 +110,28 @@ protected List<ReactPackage> getPackages() { | |
- For Android, add the following tag in your `android/app/src/main/AndroidManifest.xml` file: | ||
|
||
```xml | ||
<meta-data android:name="co.paystack.android.PublishableKey" android:value="INSERT-PUBLIC-KEY-HERE"/> | ||
<meta-data android:name="co.paystack.android.PublicKey" android:value="INSERT-PUBLIC-KEY-HERE"/> | ||
``` | ||
|
||
### Getting a Token (iOS & Android - To be deprecated soon) | ||
It's a cinch to obtain a single-use card token using the react-native-paystack module. Pls note, the SDK assumes you are responsible for building the card form/UI. | ||
### Charging a Card with Access Code (iOS & Android) | ||
It's a cinch to charge a card token using the react-native-paystack module. This is the recommended or the most-preferred workflow favored by the folks at Paystack. Initiate a new transaction on your server side using the appropriate [Paystack endpoint](https://developers.paystack.co/reference#initialize-a-transaction) - obtain an `access_code` and complete the charge on your mobile application. Pls note, the SDK assumes you are responsible for building the card form/UI. | ||
|
||
```javascript | ||
RNPaystack.getToken(cardParams); | ||
RNPaystack.chargeCardWithAccessCode(cardParams); | ||
``` | ||
To be more elaborate, `cardParams` is a Javascript `Object` representing the card to be tokenized and `RNPaystack.getToken()` returns a Javascript `Promise` like: | ||
To be more elaborate, `cardParams` is a Javascript `Object` representing the card to be charged and `RNPaystack.chargeCardWithAccessCode()` returns a Javascript `Promise` like: | ||
|
||
```js | ||
import RNPaystack from 'react-native-paystack'; | ||
|
||
getToken() { | ||
chargeCard() { | ||
|
||
RNPaystack.getToken({ | ||
RNPaystack.chargeCardWithAccessCode({ | ||
cardNumber: '4123450131001381', | ||
expiryMonth: '10', | ||
expiryYear: '17', | ||
cvc: '883' | ||
cvc: '883', | ||
accessCode: '2p3j42th639duy4' | ||
}) | ||
.then(response => { | ||
console.log(response); // do stuff with the token | ||
|
@@ -152,43 +153,20 @@ getToken() { | |
| expiryMonth | string | the card expiry month as a double-digit ranging from 1-12 e.g 10 (October) | | ||
| expiryYear | string | the card expiry year as a double-digit e.g 15 | | ||
| cvc | string | the card 3/4 digit security code as a String e.g 123 | | ||
| accessCode | string | the access_code obtained for the charge | | ||
|
||
#### Response Object | ||
|
||
An object of the form is returned from a successful token request | ||
|
||
```javascript | ||
{ | ||
token: "PSTK_4aw6i0yizwvyzjx", | ||
last4: "1381" | ||
reference: "trx_1k2o600w" | ||
} | ||
``` | ||
|
||
|
||
### Charging the tokens. | ||
Send the token to your server and create a charge by calling the Paystack REST API. An authorization_code will be returned once the single-use token has been charged successfully. You can learn more about the Paystack API [here](https://developers.paystack.co/docs/getting-started). | ||
|
||
**Endpoint:** https://api.paystack.co/transaction/charge_token | ||
|
||
**Parameters:** | ||
|
||
- email - customer's email address (required) | ||
- reference - unique reference (required) | ||
- amount - Amount in Kobo (required) | ||
|
||
**Example** | ||
|
||
```bash | ||
curl https://api.paystack.co/transaction/charge_token \ | ||
-H "Authorization: Bearer SECRET_KEY" \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"token": "PSTK_r4ec2m75mrgsd8n9", "email": "[email protected]", "amount": 10000, "reference": "amutaJHSYGWakinlade256"}' \ | ||
-X POST | ||
|
||
``` | ||
|
||
### Charging a Card (iOS & Android) | ||
Using the react-native-paystack module, you can complete the transaction with the Paystack Android and iOS SDKs. Note that as with getting a card token, the SDK assumes you are responsible for building the card form/UI. | ||
Using the react-native-paystack module, you can start and complete a transaction with the mobile Paystack Android and iOS SDKs. With this option, you pass both your charge and card properties to the SDK - with this worklow, you initiate and complete a transaction on your mobile app. Note that as with charging with an access_code, the SDK assumes you are responsible for building the card form/UI. | ||
|
||
```javascript | ||
RNPaystack.chargeCard(chargeParams); | ||
|
@@ -279,7 +257,9 @@ Perhaps needless to say, this module leverages the [Paystack Android SDK](https: | |
+ 2.1.1: Upgraded to v2.1+ of both the Paystack iOS and Android SDKs. | ||
+ 2.1.1: Added support for `chargeCard` on both platforms. | ||
+ 2.1.1: Added support for `subscriptions` and `split-payments`. | ||
+ 2.1.1: For v2-specific documentations, see [v2 Docs](./v2-Docs.md) | ||
+ 3.1.0: Retired support for `getToken` on both platforms. | ||
+ 3.1.0: Added support for `chargeCardWithAccessCode` on both platforms. | ||
+ 3.1.0: Upgraded to v3.*+ of both the Paystack iOS and Android SDKs. | ||
|
||
## 6. License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"description": "React Native Wrappers for Paystack Android & iOS Mobile SDKs", | ||
"main": "index.js", | ||
"author": "Tolu Olowu (Arttitude 360) <[email protected]>", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"scripts": { | ||
}, | ||
"repository": { | ||
|