-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure the repo for public release #2
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
08dbfa5
Configure the repo for public release
akshaybhalotia 91b3986
[docs] Minor formatting fixes in the README.
captn3m0 13cbac1
[docs] Fixes code alignment inside list
captn3m0 0e5593c
[docs] Moves links to the bottom in CONTRIBUTING.md
captn3m0 c88d8ab
Add postinstall script
akshaybhalotia 2f03794
Use Razorpay instead of RZP
akshaybhalotia 0b0e85f
Minor edit to reload script
akshaybhalotia 2bc04fc
Update README
akshaybhalotia c7c61ed
Namespace events to `Razorpay::`
akshaybhalotia 21ee2ae
Change public API to use JS promise
akshaybhalotia 91ea1b7
Add suggested changes as per review
akshaybhalotia 1a5805d
Merge pull request #3 from razorpay/f/promise_based_api
selvagsz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Contributing | ||
|
||
We love contributions from everyone. | ||
By participating in this project, | ||
you agree to abide by our [code_of_conduct]. | ||
|
||
We expect everyone to follow the code of conduct | ||
anywhere in Razorpay's project codebases, | ||
issue trackers, chatrooms, and mailing lists. | ||
|
||
## Contributing Code | ||
|
||
Checkout the latest master to make sure the feature hasn't been implemented or | ||
the bug hasn't been fixed yet. | ||
|
||
Check the issue tracker to make sure someone already hasn't requested it and/or | ||
contributed to it. | ||
|
||
Fork the repo. | ||
|
||
1. Use the example project to test the module. | ||
2. Change `"react-native-razorpay": ">=1.0.0"` in `package.json` of example to | ||
`"react-native-razorpay": "./../"`. | ||
3. Edit example/reload.sh to configure your path. | ||
4. Follow instructions to link your project with the iOS SDK, as given in the [README]. | ||
5. Run example/reload.sh every time you make a change to the module. | ||
|
||
Make your change. Follow this [style guide][style]. | ||
|
||
Push to your fork. Write a [good commit message][commit]. Submit a pull request. | ||
|
||
Others will give constructive feedback. | ||
This is a time for discussion and improvements, | ||
and making the necessary changes will be required before we can | ||
merge the contribution. | ||
|
||
[code_of_conduct]: code_of_conduct.md "Code of Conduct" | ||
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html "A short guide on how to write good commit messages" | ||
[README]: README.md#linking-ios-sdk "Linking to the iOS SDK" | ||
[style]: https://github.com/thoughtbot/guides/tree/master/style "Styleguides by Thoughtbot" |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2016 Razorpay Software Pvt. Ltd. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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 |
---|---|---|
@@ -1,47 +1,142 @@ | ||
|
||
# react-native-razorpay | ||
|
||
## Dev setup | ||
React Native wrapper around our Android and iOS mobile SDKs | ||
|
||
1. Use the examle project to test the module. | ||
2. Run example/reload_module.sh every time you make a change to the module | ||
To know more about Razorpay payment flow and steps involved, please read up here: | ||
<https://docs.razorpay.com/docs> | ||
|
||
## Installation | ||
|
||
## Getting started | ||
Run the following on terminal from your project directory: | ||
|
||
`$ npm install react-native-razorpay --save` | ||
```bash | ||
$ npm i react-native-razorpay --save | ||
``` | ||
|
||
### Mostly automatic installation | ||
### Automatic installation | ||
|
||
`$ react-native link react-native-razorpay` | ||
```bash | ||
$ react-native link react-native-razorpay | ||
``` | ||
|
||
### Manual installation | ||
|
||
If the above command doesn't work for you, try the following: | ||
|
||
#### iOS | ||
|
||
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` | ||
2. Go to `node_modules` ➜ `react-native-razorpay` and add `RNReactNativeRazorpay.xcodeproj` | ||
3. In XCode, in the project navigator, select your project. Add `libRNReactNativeRazorpay.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` | ||
4. Run your project (`Cmd+R`)< | ||
1. In XCode, in the project navigator, right click `Libraries` ➜ | ||
`Add Files to [your project's name]` | ||
2. Go to `node_modules` ➜ `react-native-razorpay` and add `RazorpayCheckout.xcodeproj` | ||
3. In XCode, in the project navigator, select your project. Add | ||
`libRazorpayCheckout.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` | ||
4. Run your project (`⌘+R`) | ||
|
||
#### Android | ||
|
||
1. Open up `android/app/src/main/java/[...]/MainApplication.java` | ||
- Add `import com.razorpay.rn.RazorpayPackage;` to the imports at the top of the file | ||
- Add `import com.razorpay.rn.RazorpayPackage;` to the imports at the top of | ||
the file | ||
- Add `new RazorpayPackage()` to the list returned by the `getPackages()` method | ||
2. Append the following lines to `android/settings.gradle`: | ||
``` | ||
include ':react-native-razorpay' | ||
project(':react-native-razorpay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-razorpay/android') | ||
``` | ||
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: | ||
``` | ||
compile project(':react-native-razorpay') | ||
``` | ||
|
||
|
||
### Usage | ||
|
||
TODO | ||
|
||
```gradle | ||
include ':react-native-razorpay' | ||
project(':react-native-razorpay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-razorpay/android') | ||
``` | ||
3. Insert the following lines inside the dependencies block in | ||
`android/app/build.gradle`: | ||
```gradle | ||
compile project(':react-native-razorpay') | ||
``` | ||
|
||
## Linking iOS SDK | ||
|
||
React Native creates static library for each plugin / library / framework / native module being used. | ||
|
||
Due to some limitation on the way Xcode links static and dynamic | ||
libraries / frameworks to projects, we require some additional | ||
steps to be followed to link our iOS SDK to the React Native project. | ||
|
||
You can skip steps 1, 2 and 3 if you used `npm`. | ||
|
||
1. Download [Razorpay's iOS SDK from here][ios-docs] and unzip it. | ||
2. Delete the `.framework` file from | ||
`path/to/your/project/node_modules/react-native-razorpay`. | ||
3. Copy the `.framework` file obtained in step 1 to | ||
`path/to/your/project/node_modules/react-native-razorpay`. | ||
4. Open `path/to/your/project/ios/<your_project>.xcworkspace` or | ||
`path/to/your/project/ios/<your_project>.xcodeproj` | ||
5. Also link the `.framework` file **_directly_ to your project** in Xcode. Check the | ||
`Copy items if needed` box and select your project target from the list below. | ||
6. Add the following line of code in your `AppDelegate.m` under the imports section: | ||
`#import <dlfcn.h>` | ||
7. Add the following line of code in your `AppDelegate.m` inside the | ||
`application:didFinishLaunchingWithOptions:` method: | ||
`dlopen("Razorpay.framework/Razorpay", RTLD_LAZY | RTLD_GLOBAL);` | ||
|
||
## Usage | ||
|
||
Sample code to integrate with Razorpay can be found in | ||
[index.js][index.js] in the included example directory. | ||
|
||
To run the example, simply do the following in example directory and then | ||
link iOS SDK as explained in the previous section: | ||
|
||
`$ npm i` | ||
|
||
### Steps | ||
|
||
1. Import RazorpayCheckout module to your component: | ||
```js | ||
import RazorpayCheckout from 'react-native-razorpay'; | ||
``` | ||
2. Call `RazorpayCheckout.open` method with the payment `options`. The method | ||
returns a **JS Promise** where `then` part corresponds to a successful payment | ||
and the `catch` part corresponds to payment failure. | ||
```js | ||
<TouchableHighlight onPress={() => { | ||
var options = { | ||
description: 'Credits towards consultation', | ||
image: 'https://i.imgur.com/3g7nmJC.png', | ||
currency: 'INR', | ||
key: 'rzp_test_1DP5mmOlF5G5ag', | ||
amount: '5000', | ||
name: 'foo', | ||
prefill: { | ||
email: '[email protected]', | ||
contact: '8955806560', | ||
name: 'Akshay Bhalotia' | ||
}, | ||
theme: {color: '#F37254'} | ||
} | ||
RazorpayCheckout.open(options).then(data => | ||
{ alert("Success: " + data.payment_id) } | ||
).catch(data => | ||
{ alert("Error: " + data.code + " | " + data.description) } | ||
); | ||
}}> | ||
``` | ||
A descriptive [list of valid options for checkout][options] is available (under | ||
Manual Checkout column). | ||
|
||
## Contributing | ||
|
||
See the [CONTRIBUTING] document. Thank you, [contributors]! | ||
|
||
## License | ||
|
||
react-native-razorpay is Copyright (c) 2016 Razorpay Software Pvt. Ltd. | ||
It is distributed under [the MIT License][LICENSE]. | ||
|
||
We ♥ open source software! | ||
See [our other supported plugins / SDKs][integrations] | ||
or [contact us][contact] to help you with integrations. | ||
|
||
[contact]: mailto:[email protected]?subject=Help%20with%20React%20Native "Send us a mail" | ||
[CONTRIBUTING]: CONTRIBUTING.md "Our contributings guidelines" | ||
[contributors]: https://github.com/razorpay/react-native-razorpay/graphs/contributors "List of contributors" | ||
[index.js]: example/index.js "index.js" | ||
[integrations]: https://razorpay.com/integrations "List of our integrations" | ||
[ios-docs]: https://docs.razorpay.com/v1/page/ios-integration "Documentation for the iOS Integration" | ||
[LICENSE]: /LICENSE "MIT License" | ||
[options]: https://docs.razorpay.com/docs/checkout-form#checkout-fields "Checkout Options" |
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
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
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, gender identity and expression, level of experience, | ||
nationality, personal appearance, race, religion, or sexual identity and | ||
orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at [[email protected]](mailto:[email protected]?subject=Code of Conduct Issue). All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
## Run this script after installing the module | ||
|
||
curl -O http://downloads.razorpay.com/Razorpay.framework-0.14.1.zip | ||
unzip ./Razorpay.framework-0.14.1.zip | ||
rm -r ./ios/Razorpay.framework | ||
cp -R ./Razorpay.framework ./ios/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to see the code snippet in usage section in addition to the example