njosefbeck / gatsby-source-stripe

Gatsby source plugin for building websites using Stripe as a data source
74 stars 17 forks source link

Price instead of SKU #56

Closed vSterlin closed 4 years ago

vSterlin commented 4 years ago

It looks like SKUs are not used with Stripe Checkout anymore, they use Price object instead (there is no way to add SKU in Stripe dashboard). When I query allStripePrice with the plugin, I can retrieve the product's id but not its name, so I need a separate query for Stripe products to retrieve the product's name which is inconvenient. If it would be possible to retrieve product's name from price query it would be a great addition to plugin.

njosefbeck commented 4 years ago

Hello!

This will be easy enough to do, as it looks like product is expandable on the Price object. I won't be able to get to this until later in the week, but if you want to follow the pattern found in stripeObjects.json for expanding fields for other objects, feel free to add for Price and make a PR!

Thanks!

brittneypostma commented 4 years ago

It looks like the Price object has now been added to the stripeObjects.json is there a way to query for that now? The only example is see is still the allStripeSku, which does not work with newer accounts.

njosefbeck commented 4 years ago

@brittneypostma Hello! Having more examples of querying for other types of Stripe objects would be great - happy to accept any PRs updating the README with more examples.

As far as querying for Prices, have you tried adding it to your plugin config like so:

{
    resolve: `gatsby-source-stripe`,
    options: {
      objects: ['Price'],
      secretKey: 'stripe_secret_key_here',
    }
  }

If the above works, you should be able to open Graphiql and see allStripePrice. If you don't, happy to help you debug further!

@vSterlin also thanks for the PR, will get that merged this weekend!

brittneypostma commented 4 years ago

I have added it to the objects as shown above, but allStripe does not show up in Graphiql.

Edit: I realized I was using an older account with the sku api. After updating my keys to the correct account it is querying. I will try and add a pr for the readme if I get something working. Thanks!

njosefbeck commented 4 years ago

Oh great! Glad to hear that querying is working! Looking forward to that PR and don't hesitate to reach out if you run into additional issues / have additional questions.

njosefbeck commented 4 years ago

This is now merged! Feel free to create a new issue if you run into an issue :)