Gatsby source plugin for building websites using Stripe as a data source
JavaScript
Switch branches/tags
Nothing to show
Latest commit 0951804 Oct 30, 2017 @njosefbeck njosefbeck 1.0.1
Permalink
Failed to load latest commit information.
src Initial commit Oct 30, 2017
.babelrc Initial commit Oct 30, 2017
.gitignore Initial commit Oct 30, 2017
README.md Initial commit Oct 30, 2017
build-node.js Initial commit Oct 30, 2017
build-nodes.js Initial commit Oct 30, 2017
capitalize.js Initial commit Oct 30, 2017
fetch-objects.js Initial commit Oct 30, 2017
fetch-stripe-data.js Initial commit Oct 30, 2017
gatsby-node.js Initial commit Oct 30, 2017
package.json 1.0.1 Oct 30, 2017
paginate.js Initial commit Oct 30, 2017
singularize.js Initial commit Oct 30, 2017
yarn.lock Initial commit Oct 30, 2017

README.md

gatsby-source-stripe

Source plugin for pulling in data from the Stripe API. Specifically, with this plugin you are able to access data found at these API methods:

stripe.balance.listTransactions
stripe.charges.list
stripe.customers.list
stripe.disputes.list
stripe.events.list
stripe.fileUploads.list
stripe.payouts.list
stripe.refunds.list
stripe.coupons.list
stripe.invoices.list
stripe.invoiceItems.list
stripe.plans.list
stripe.subscriptions.list
stripe.accounts.list
stripe.applicationFees.list
stripe.countrySpecs.list
stripe.transfers.list
stripe.orders.list
stripe.products.list
stripe.orderReturns.list
stripe.skus.list
stripe.scheduledQueryRuns.list

This plugin is a source plugin, so it only brings in the data (to be used, for example, in creating a Stripe dashboard, or an e-commerce store). To actually edit the data in your Stripe account, to handle transactions, make charges, you will need to use some kind of backend server. I favor a serverless setup using clay.run, but really it's whatever floats your boat!

Install

npm install gatsby-source-stripe

or

yarn add gatsby-source-stripe

How to use

Note: In your objects array, the strings match the middle object name from the API. So, for example, if I want to get all of my customers' data, which can be found at stripe.customers.list, I would use the string 'customers' in my objects array. Example below.

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-stripe`,
    options: {
      objects: ['balance', 'customers', 'products', 'applicationFees', 'skus', 'subscriptions'],
      secretKey: 'stripe_secret_key_here'
    }
  }
]

How to query

You can query all of the different Stripe object data like the following:

{
  allStripeCustomer {
    edges {
      node {
        id,
        active,
        attributes,
        skus {
          id
        }
      }
    }
  }
}

Just replace "Customer" with the singular version of the string used in the objects array in gatsby-config.js.

You can also query for a specific product like this:

{
  StripeCustomer(id: { eq: "customer_id_here" }) {
    id,
    name
  }
}