ReactJS Stripe Checkout Component (Prodio)
Stripe's Checkout makes it almost too easy to take people's money. This should make it even easier if you're building a react application.
Installation
Get started by installing with npm
npm install stripe-react-sdk-prodio --save
Requirements
token
and stripeKey
are the only required props,
everything else is optional as per the stripe docs. See Checkout
Docs. All props
go through simple validation and are passed to stripe checkout, they're
also documented in StripeCheckout.js
.
import React from 'react'import StripeCheckout from 'stripe-react-sdk-prodio'; Component { ; thisstate = totalAmountToPay : 89 userEmail:"shashikant@prodio.in" } { let sampleMetaData = "totalAmountToPay": thisstatetotalAmountToPay //mandatory "userEmail": thisstateuserEmail //mandatory "title": "Payment for services" //madatory - payment reference title "payerId":"" //madatory - from prodio payment module "merchantId":"" //madatory - from prodio payment module "webhookUrl":"" //optional - if you want to receive complete metaData in your apis "businessName":"" //You can add any key value pairs "customKey":"customValue" let sendData = "metaData": sampleMetaData "token": token ## NOTE : If you using API_GATEWAY - then create api gateway end point and point it to the below api url //To get this URL working you need to run "Prodio-payment-services" on the server //{{hostname}} is server domain or IP. axios; } // ... { return // ... <StripeCheckout = ="{publish_key_from_stripe}" = // ="USD" = ="Payment Form" ="Pay" // = = /> }
This will give you a default Stripe-style button which looks like this:
Send all the props!
<StripeCheckout ="Payment Transaction" // ="Here you can write the description" // ="{REMOTE_URL_FOR_THE_IMAGE}" // ( ) ="Let's Pay" // ="Give Money" // = // = // = // ="USD" ="..." ="en" ="" // // . . = // // ( ). = // "Remember Me" ( ) = // = // ( /) = // ( /) > <button ="btn btn-primary"> Use your own child component which gets wrapped in whatever component you pass into as "ComponentClass" defaults to span </button></StripeCheckout>