npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stripe-react-sdk-prodio

v1.0.7

Published

Checkout form in ReactJS and supports all the options from stripe docs.

Downloads

4

Readme

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';

export default class PaymentClass extends React.Component {

  constructor(props) {
      super(props);
      this.state = {
        totalAmountToPay : 89,
        userEmail:"[email protected]"
      }
  }

  onToken = (token) => {
    let sampleMetaData = {
      "totalAmountToPay": this.state.totalAmountToPay,            //mandatory
      "userEmail": this.state.userEmail,                              //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.post(`http://{{hostname}}:3010/api/StripeConnector/verifyStripeToken`, sendData).then(result => {
        result.json().then(data => {
          alert(`Payment completed successfully`);
        });
      }).catch(error => {
        alert('Error while processing payment : '+JSON.stringify(error))
      });

  }

  // ...

  render() {
    return (
      // ...
      <StripeCheckout
        token={this.onToken}
        stripeKey="{publish_key_from_stripe}"
        amount={ (this.state.totalAmountToPay) * 100 } // cents
        currency="USD"
        email={(this.state.userEmail)}
        name="Payment Form"
        label="Pay" // text inside the Stripe button
        containerStyle={{height:100,width:200,background:"#fff"}}
        buttonStyle={{height:100,width:200,background:"#dddd"}}
      />
    )
  }
}

This will give you a default Stripe-style button which looks like this:

stripe checkout button

Send all the props!

<StripeCheckout
  name="Payment Transaction" // the pop-in header title
  description="Here you can write the description" // the pop-in header subtitle
  image="{REMOTE_URL_FOR_THE_IMAGE}" // the pop-in header image (default none)
  label="Let's Pay" // text inside the Stripe button
  panelLabel="Give Money" // prepended to the amount in the bottom pay button
  amount={1000000} // cents
  containerStyle={{}} //container style
  buttonStyle={{}} //payment button style object
  currency="USD"
  stripeKey="..."
  locale="en"
  email=""
  // Note: Enabling either address option will give the user the ability to
  // fill out both. Addresses are sent as a second parameter in the token callback.
  shippingAddress
  billingAddress={false}
  // Note: enabling both zipCode checks and billing or shipping address will
  // cause zipCheck to be pulled from billing address (set to shipping if none provided).
  zipCode={false}
  allowRememberMe // "Remember Me" option (default true)
  token={this.onToken} // submit callback
  opened={this.onOpened} // called when the checkout popin is opened (no IE6/7)
  closed={this.onClosed} // called when the checkout popin is closed (no IE6/7)
  >
  <button className="btn btn-primary">
    Use your own child component, which gets wrapped in whatever
    component you pass into as "ComponentClass" (defaults to span)
  </button>
</StripeCheckout>