|
1 | 1 | # Getting Started with Paystack and React |
2 | 2 |
|
3 | | -This is the code for the app written in the Getting Started with Paystack and React App. |
| 3 | +This repository includes an sample application that shows how to integrate Paystack payments to your React apps. |
4 | 4 |
|
5 | | -## Getting Started |
| 5 | +The sample app is a simple checkout form to purchase an item and check out using the [Paystack Popup](https://paystack.com/docs/payments/accept-payments/#popup) checkout. It uses [iamraphson's](https://github.com/iamraphson) [react-paystack](https://github.com/iamraphson/react-paystack) library. |
6 | 6 |
|
7 | | -### Demo |
8 | | -View a live demo of the app [here](https://google.com) |
| 7 | +The library offers 3 integration methods: |
| 8 | +- [Using hooks](https://github.com/iamraphson/react-paystack#1-using-the-paystack-hook) |
| 9 | +- [Using a `<PaystackButton/>` component](https://github.com/iamraphson/react-paystack#2-using-the-paystack-button) |
| 10 | +- [Using the Context API](https://github.com/iamraphson/react-paystack#3-using-the-paystack-consumer) |
| 11 | + |
| 12 | +This sample uses the `<PaystackButton/>` component, but you can swap it out for any of the other methods. All 3 methods will bear the same results |
| 13 | + |
| 14 | + |
| 15 | +## Demo |
| 16 | + |
| 17 | +View a live demo of the app [here](https://react-paystack-guide.netlify.app/) |
| 18 | + |
| 19 | +## Get Started |
| 20 | + |
| 21 | +1. Clone this repo: |
| 22 | +```git clone https://github.com/PaystackOSS/sample-react.git``` |
| 23 | + |
| 24 | +2. Navigate to the root directory and install dependencies |
| 25 | +```yarn install``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +1. Rename the `.env.example` file to `.env` and add your Paystack public key: |
| 30 | + |
| 31 | +```REACT_APP_PAYSTACK_PUBLIC_KEY=pk_domain_xxxxxx``` |
| 32 | + |
| 33 | +2. Start the application |
| 34 | + |
| 35 | +```yarn start``` |
| 36 | + |
| 37 | +3. Visit http://localhost:3000 in your browser, if React doesn't automatically open it for you. You should now see your checkout form, and be able to make a purchase. |
| 38 | + |
| 39 | +**Note**: This is a simple client-side integration, that uses a callback to perform post-payment logic. For a more stable, robust solution, you should use webhooks to listen for transaction success and perform any post-payment logic on your server. |
| 40 | + |
| 41 | + |
| 42 | +## Contributing |
| 43 | +If you notice any issues with this app, please [open an issue](https://github.com/PaystackOSS/sample-react/issues/new). PRs are also more than welcome, so feel free to [submit a PR](https://github.com/PaystackOSS/sample-react/compare) to fix an issue, or add a new feature! |
| 44 | + |
| 45 | +## License |
| 46 | + |
| 47 | +This repository is made available under the MIT license. Read [LICENSE.md](https://google.com) for more information. |
9 | 48 |
|
10 | | -### Development |
11 | | -To run locally, clone/download the repo, then `cd` into the app folder and run |
12 | | -``` |
13 | | -yarn install |
14 | | -yarn start |
15 | | -``` |
|
0 commit comments