Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nicnocquee/react-stripe-checkout

A sample project for integrating Stripe Checkout with React (CRA) app
https://github.com/nicnocquee/react-stripe-checkout

checkout create-react-app react sample stripe tutorial

Last synced: about 7 hours ago
JSON representation

A sample project for integrating Stripe Checkout with React (CRA) app

Awesome Lists containing this project

README

        

Integrating [Stripe's Checkout](https://stripe.com/docs/checkout/tutorial) with **custom pay button** to your react app is actually pretty simple. You don't need to install third party [package](https://github.com/azmenak/react-stripe-checkout). This project (bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app)) shows how to do it with a few lines of codes.

[DEMO VIDEO](https://youtu.be/UAKriPqatCA)

1. Add the following to [public/index.html](https://github.com/nicnocquee/react-stripe-checkout/blob/master/public/index.html#L30)

```html

```

2. Configure the Stripe Checkout in any component you want. In this sample, it's in [App.js](https://github.com/nicnocquee/react-stripe-checkout/blob/master/src/App.js#L15).

```javascript
this.stripeHandler = window.StripeCheckout.configure({
key: "",
image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
locale: 'auto',
token: this.onGetStripeToken.bind(this)
});
```

3. Open the Checkout modal when [the pay button is clicked](https://github.com/nicnocquee/react-stripe-checkout/blob/master/src/App.js#L39).

```javascript
this.stripeHandler.open({
name: 'My Delightful Shop',
description: 'An awesome product',
amount: 1000, // 10 USD -> 1000 cents
currency: 'usd',
opened: onCheckoutOpened.bind(this)
});
```

4. [Send the Stripe token to your server](https://github.com/nicnocquee/react-stripe-checkout/blob/master/src/App.js#L23) when your customer's card has been validated.
5. ...
6. **PROFIT!** πŸ€‘πŸ’°πŸ’΅πŸ’ΈπŸŒˆπŸš€

# Getting Started

- Clone this repo.
- `yarn install` or `npm install`
- Open `src/App.js` and replace `` with your [Stripe's publishable key](https://dashboard.stripe.com/account/apikeys).
- `yarn run`

[@nicnocquee](https://twitter.com/nicnocquee).