njosefbeck / gatsby-source-stripe Goto Github PK
View Code? Open in Web Editor NEWGatsby source plugin for building websites using Stripe as a data source
Gatsby source plugin for building websites using Stripe as a data source
It would be very useful to be able to extract prices while querying allStripeProducts or stripeProduct. It is currently possible to get products from price query, but not other way around.
I am trying to implement the retrigger the gatsby develop automatically whenever something changes in headless cms as this feature provided by gatsby-source-stripe. I found that when something changes in the product information on stripe website a webhook is retriggered and gatsby build initiated on the client side. But I didn't find the code which handles this trigger event in the source code. can anyone point out the code where we handle the webhook retrigger please!
I read in one closed issue in the repo of the tutorial I followed that this can happen because of the wrong Stripe secret key, but I don't think that's the reason in my case. I've added the right secret key exactly as described here: https://www.gatsbyjs.org/tutorial/ecommerce-tutorial/, I've even hardcoded it and it still doesn't work, I rolled the secret key and tried with the new one and I have the same problem. I even created a new account and still the same.
gatsby-source-stripe
to your projectgatsby-config.js
Expected behavior: To have that query
Actual behavior: Graphql error Unknown field 'allStripeSku' on type 'Query'.
Reproduces how often: Every time
os: macOs Mojave 10.14.5
node: 10.16.0
npm: 6.9.0
gatsby: 2.17.11
gatsby-source-stripe: 3.0.4
Here's the full log. Maybe this line can tell something warn The gatsby-source-stripe plugin has generated no Gatsby nodes. Do you need it?
> [email protected] develop /Users/developera/moje/ecommerce-gatsby-tutorial
> gatsby develop
success open and validate gatsby-configs - 0.040s
success load plugins - 2.058s
success onPreInit - 0.006s
success initialize cache - 0.029s
success copy gatsby files - 0.213s
success onPreBootstrap - 0.020s
warn The gatsby-source-stripe plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes - 0.733s
success building schema - 0.382s
success createPages - 0.002s
success createPagesStatefully - 0.052s
success onPreExtractQueries - 0.011s
success update schema - 0.023s
ERROR #85907 GRAPHQL
There was an error in your GraphQL query:
- Unknown field 'allStripeSku' on type 'Query'.
File: src/components/Skus.js
failed extract queries from components - 0.343s
success write out requires - 0.033s
success write out redirect data - 0.002s
success Build manifest and related icons - 0.125s
success onPostBootstrap - 0.148s
⠀
info bootstrap finished - 14.662 s
⠀
success run queries - 0.055s - 5/5 91.65/s
ERROR #98123 WEBPACK
Generating development JavaScript bundle failed
/Users/developera/moje/ecommerce-gatsby-tutorial/src/components/Skus.js
8:9 error Cannot query field "allStripeSku" on type "Query". Did you mean "allSite"? graphql/template-strings
✖ 1 problem (1 error, 0 warnings)
File: src/components/Skus.js
failed Building development bundle - 6.482s
————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
5 pages Failed gatsby-starter-default
Prerequisites
[X] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
GrapghQL query for the product field as a property of a price object (allStripePrice
) errors with:
Cannot query field "product" on type "Query"
This includes a suggestion that the field cannot be queried if it is optional, as Gatsby can't infer the type in the schema.
To Reproduce
Steps to reproduce the behavior:
gatsby-source-stripe
to use objects: ['Product', 'Price']
query Shop {
allStripePrice(filter: {active: {eq: true}}) {
edges {
node {
unit_amount
product {
id
}
}
}
}
}
Expected behavior
product field can be queried on price objects as it always present on responses from the Stripe API (expandable).
Screenshots
If applicable, add screenshots to help explain your problem.
Versions (please complete the following information):
os: macOS 10.15.7
node: 14.15.5
npm: 6.14.11
gatsby: 2.32.3
gatsby-source-stripe: 3.2.1
Gatsby config:
Copy the portion of your Gatsby config for this plugin here. Do not include your secretKey
.
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Product', 'Price'],
secretKey: '...',
downloadFiles: false,
},
}
Additional context
If I run this query in the GraphiQL explorer, it works fine!
Prerequisites
[ X ] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
Is there a way of getting back the price of a subscription (Product)
Using product
argument on allStripeSku
results in error Unknown argument "product" on field "allStripeSku" of type "Query".
If the argument is changed to another argument, like limit
it works as expected. The documentation shows product
is a valid argument.
query productDetail {
product: stripeProduct(id: {eq: "prod_NNNNN"}) {
id
name,
},
skus: allStripeSku(product: {eq: "prod_NNNNN"}) {
edges {
node {
id
}
}
}
}
Expected behavior: [What you expect to happen]
The query should return a single product, and all SKUs belonging to that product.
Actual behavior: [What actually happens]
Returns an error Unknown argument "product" on field "allStripeSku" of type "Query".
Reproduces how often: [What percentage of the time does it reproduce?]
100%
os: Mac 10.14.3
node: 10.15.1
npm: 6.4.1
gatsby: 2.4.1
gatsby-source-stripe: 2.1.7
I'm looping over SKU's displaying prices etc.
I want to do the same with subscriptions and show the subscription information i.e free trial dates, renewal times etc.
Is there a way to do this, I can't see anything come back in graphql.
I just updated to the newest release, but I'm running into this error on develop/build:
error Unable to find plugin "gatsby-source-stripe". Perhaps you need to install its package?
I checked and the plugin is indeed in my node_modules. I've also tried deleting node_modules & package-lock.json and then reinstalling.
Same deal on both projects I tested.
@njosefbeck Looks like the publishing setup changed, maybe something's not quite right?
os: Linux / Solus 4
node: 10.11.0
npm: 6.5.0
gatsby: 2.5.7
gatsby-source-stripe: 2.2.0
@brxck
Hey! The downloading files integration needs to be looked at a bit, if you have the time. Ran into some issues recently.
(1) For some reason, I can't get "localFiles" to show up anymore for Skus. I'm running the latest version of Gatsby, am getting no console errors, but when I go to query the "localFiles" field in GraphiQL it says the field is unqueryable. I haven't tested other Stripe object types, but thought I'd reach out about Skus to begin with.
{
allStripeSku {
edges {
node {
id,
active,
localFiles,
product {
id
}
}
}
}
}
Here's the contents my gatsby-config.js file in case that's helpful.
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
},
plugins: [
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
},
},
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Sku'],
secretKey: 'xxx',
downloadFiles: true
}
}
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.app/offline
// 'gatsby-plugin-offline',
],
}
(2) If you run the plugin with the same exact config as found in the README, it errors out. In LocalFile.js, line 16 seems to error out because "fields" becomes undefined and line 47 errors out because payload.data is undefined. Maybe there needs to be some logic in there to return early if certain things don't exist.
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Balance', 'BalanceTransaction', 'Product', 'ApplicationFee', 'Sku', 'Subscription'],
secretKey: 'stripe_secret_key_here',
downloadFiles: true
}
}
]
Let me know if you have the bandwidth to look into these things, otherwise I can dig deeper! Thanks!
The pagination never ends as the args never change.
I'll need to deal with Event objects for skus and products having the same attributes key, but having different data types (i.e. sku.attributes is an object, and product.attributes is an array). This currently causes Gatsby to strip out the attributes field, which is not desired.
Hello, today I noticed that stripe is recommending we use their new Prices API for Stripe Checkout. I was wondering if you were aware of this new API and if so, do you have a timeline for when Prices will be added as a supported type?
Here is a link to the stripe docs migration guide:
https://stripe.com/docs/payments/checkout/migrating-prices
Thank you for your time 😄
Prerequisites
[ x ] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
The "Product" object is not showing up. I can add other objects, such as "Price" and "Customer" and they show up in the graphQL, but Product does not. I can get to products through the price object, but it does not have all of the attributes of the product that I need to display.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect to see the allStripeProduct in the graphQL
Versions (please complete the following information):
os: Mac OS 13.0
node: v18.6.0
npm: 8.13.2
gatsby: 4.5.4
gatsby-source-stripe: 4.0.0
Gatsby config:
'gatsby-plugin-netlify',
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Price', 'Product', 'Customer'],
secretKey: process.env.STRIPE_SECRET_KEY,
downloadFiles: false,
},
},
Prerequisites
[x] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
The stripe version for this library is now about 3 years old. https://github.com/njosefbeck/gatsby-source-stripe/blob/main/package.json#L51 ([email protected]
) and I'm needing some newer functionality from the sdk for my netlify worker functions. Any chance of updating this to the current version of Stripe API (apiVersion: 2022-11-15
at the time of this writing)?
Fwiw, I've used this project a ton for helping small businesses depend on stripe as a source for gatsby builds. I'm also willing to attempt the upgrade myself but want to check that such a PR would be well received before I attempt
To Reproduce
Attempt to access newer stripe sdk methods
Expected behavior
They work
Versions (please complete the following information):
os: [macos]
node: [16]
npm: [9]
gatsby: [4]
gatsby-source-stripe: [4]
Gatsby config:
Copy the portion of your Gatsby config for this plugin here. Do not include your secretKey
.
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Sku', 'Product', 'Customer'],
secretKey: '...',
downloadFiles: true,
}
}
Additional context
Add any other context about the problem here.
I've also been experiencing issues with the image download. My images are hosted in a Google Cloud Platform Storage Bucket (which is public), however the request to grab those images includes an Authorization header which causes Google to send back a 401 (Unauthorized). In order to avoid this it would be helpful to either remove the auth options when fetching the images (after having already fetched the URLs from Stripe) and/or provide a way for users to provide auth details in the options for the plugin if required.
In the gatsby-node file you create an instance of LocalFile with one of the options passed through being:
auth: { htaccess_user: secretKey }
This is then passed through to createRemoteFileNode (gatsby-source-filesystem) which is finally passed through to an npm module called got as one of its options. By passing this auth option got adds in an Authorization header to the HTTP request. This triggers google to send back a 401 because the contents of the header doesn't match anything google knows about.
Turns out that files/images hosted on Stripe don't actually require you to authenticate with your Stripe credentials. They are entirely public. This means that there isn't ever a need for you to provide the auth header - it should simply always be removed. I have tested this locally and can now successfully pull down all images.
I'm happy to create a PR that will remove the auth option, remove the auth header in every instance, and simplify LocalFile.js since the downloadStripeHostedFile method is now no longer needed. @njosefbeck @brxck let me know if I'm forgetting something important.
This means that the file can be downloaded without any cookies being provided for authentication.
To test this plugin, I typically use the test data provided by Stripe. I would love to test the plugin across more complex, larger Stripe data.
Do you have a Stripe account with a lot of data in it?
Are you a Stripe Connect user?
Are you a part of any closed betas (thinking: issuing)?
If so, it would be great if you would test this plugin using that data.
I'm building some e-commerce functionality, pulling product data from stripe. Is there a way to link products and skus together? Since we need to pull information like description etc from the product API and things like price etc from the SKU api.
Ideally we could make a query like this.
{
allStripeSku {
edges {
node {
id
active
price
products {
id
name
description
}
}
}
}
}
Is something like this possible, or would I need to chain several queries to get the product which belongs to a sku?
It would be really great if the source plugin supported the downloading of product and sku images. This would make it possible to use things like gatsby-image with the resulting nodes.
@njosefbeck, you mentioned that a separate transformer plugin might be the way to do this, but I think it might be better to keep this within the source plugin. The transformer plugin wouldn't be able to place links to the new File nodes directly on the Stripe nodes, because they cannot be directly modified after creation. Instead links would have to be placed within fields
using createNodeField.
The difference is in querying
{ stripeProduct (id: { eq: "..." }) { localImages } }
vs
{ stripeProduct (id: { eq: "..." }) { fields { localImages } } }
Browsing around, it seems that this sort of thing is usually implemented by the source plugin itself, and that transformers usually create new types of nodes from others, rather than modifying old nodes.
In any case, I'd definitely like to help get this implemented. Let me know what you think!
I was playing a bit with your plugin tonight — thanks for making it! Noticed a couple of things that could be improved with the image downloading.
First, I noticed that sometimes my image processing query failed. Looking at the bootstrap output, I noticed that files didn't finish downloading until after bootstrap was finished. Which means that you're not waiting for the Promise returned by createRemoteFileNode to resolve before telling Gatsby you're finished.
Second, fairly recently we added a new required field to createRemoteFileNode — parentNodeId
https://www.gatsbyjs.org/packages/gatsby-source-filesystem/?=filesys#createremotefilenode
This is needed so that Gatsby knows what node the newly downloaded File is connected to. Without this, Gatsby will delete the File node when you restart the develop server.
Would appreciate a fix to these, thanks!
Prerequisites
[ ] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
When we try to query prices an error occures : {
"errors": [
{
"message": "Cannot query field "product" on type "StripePrice".",
"locations": [
{
"line": 9,
"column": 9
}
],
"extensions": {
"stack": [
"GraphQLError: Cannot query field "product" on type "StripePrice".",
" at Object.Field (D:\immal\immal.org\node_modules\graphql\validation\rules\FieldsOnCorrectTypeRule.js:48:31)",
" at Object.enter (D:\immal\immal.org\node_modules\graphql\language\visitor.js:323:29)",
" at Object.enter (D:\immal\immal.org\node_modules\graphql\utilities\TypeInfo.js:370:25)",
" at visit (D:\immal\immal.org\node_modules\graphql\language\visitor.js:243:26)",
" at validate (D:\immal\immal.org\node_modules\graphql\validation\validate.js:69:24)",
" at graphqlMiddleware (D:\immal\immal.org\node_modules\express-graphql\index.js:98:38)",
" at processTicksAndRejections (internal/process/task_queues.js:93:5)"
]
}
}
]
}
To Reproduce
Query : {
allStripePrice {
edges {
node {
id,
object,
active,
billing_scheme,
product,
type,
livemode,
unit_amount,
unit_amount_decimal,
currency
}
}
}
}
Gatsby config:
{
resolve: gatsby-source-stripe
,
options: {
objects: ["Product", "Price", "Plan"],
secretKey: process.env.STRIPE_SECRET_KEY,
downloadFiles: true,
},
},
Currently we try to use the url property of the Stripe file Object when downloading files is set too true. This never works as it doesn't actually point to any files. @brxck said previously that we don't use the urls contained in the objects that make up payload.links.data because:
The more I think about it the less this makes sense to me. My arguments for no longer using the url property and instead switching to links are:
I am currently chasing up the following two questions with Stripe support and will get post back when I have answers:
A reference to the File object: https://stripe.com/docs/api/files/object
The metadata parameter is useful for showing arbitrary information related to certain Stripe objects. According to the docs, Account, Charge, Customer, PaymentIntent, Refund, Subscription, and Transfer support this property, and I know that Plan and Product do as well.
Is it possible for metadata
to be one of the queryable fields?
Now that we're getting more contributors to this project (very exciting!), we need to formalize a couple of things that we do in this project. I plan on adding the following to the CONTRIBUTING.md:
If you add any dependencies to the project via package.json, we only use absolute versions and not 'fuzzy' versions. For example, 2.2.6
instead of ^2.2.6
. This helps with consistency across npm installs.
For commits, we prefer the active voice / imperative mood. For more info (and a great article), check here.
Encourage frequent running of ESLint and Prettier, to ensure consistency across how we code.
Prerequisites
[X] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
Using the latest gatsby-source-stripe with Gatsby 3 triggers a deprecation warning:
warning Calling "touchNode" with an object containing the nodeId is deprecated. Please pass the node directly to the function: touchNode(node) "touchNode" was called by gatsby-source-stripe
The touchNode
call in question is here.
To Reproduce
Steps to reproduce the behavior:
Versions (please complete the following information):
gatsby: 3.1.2
gatsby-source-stripe: 3.2.2
Gatsby config:
{
resolve: `gatsby-source-stripe`,
options: {
objects: ["Price"],
secretKey: process.env.STRIPE_SECRET_KEY,
downloadFiles: true,
auth: false,
},
},
Dependency of gatsby-source-stripe not working
Good-bye first-person references, hello "we"!
Annnd the develop section needs a little more love (explain project structure, the different scripts, etc).
The Stripe API allows for the auto-expansion of objects returned. To handle auto-expansion, I've added a methodArgs
key to each Stripe Object in stripeObjects.json
. Inside that methodArgs
key, an expand
array is defined (example here).
Ultimately this looks like:
"methodArgs": {
"expand": [
"data.source.destination",
"data.source.customer",
"data.source.invoice"
]
}
Where I need help, is that there are MANY more expansion possibilities across the Stripe objects that this plugin supports. I need help looking through the Stripe API documentation for "expandable" fields, and also subsequent "expandable" sub-fields.
Additionally, someone would need to test to ensure that these expandable fields actually work, by running the plugin in a Gatsby project. If the field isn't expandable, and you've specified that it is, stripe-node will error out. We want to avoid fields that error out!
Feel free to:
stripeObjects.json
with additional expandable fieldsAny and all help would be awesome. ❤️
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.
Prerequisites
[X] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
Images are not downloaded for Price objects even when the downloadFiles
is set to true
.
To Reproduce
Steps to reproduce the behavior:
objects
to ["Price"]
downloadFiles
to true
.Expected behavior
Images should also be downloaded for products based on the new Prices API setup.
Versions (please complete the following information):
os: Linux (Pop!_OS 20.04)
node: 14.13.1
npm: 6.14.8
gatsby: 2.12.109
gatsby-source-stripe: 3.1.1
Gatsby config:
Copy the portion of your Gatsby config for this plugin here. Do not include your secretKey
.
{
resolve: `gatsby-source-stripe`,
options: {
objects: ["Price"],
secretKey: process.env.STRIPE_SECRET_KEY,
downloadFiles: true,
},
}
Additional context
I can force the images to download by adding case "price"
following the same path as case "sku"
to both downloadAndAddTo()
in the FileDownloadService.js and to extractUrls()
in extractUrls.js. I'm not sure if there are any further changes necessary for full integration.
I'm trying to use this plugin to set up a Gatsby storefront for my company. However, we want our products to be subscription-based. The one time payment products show up fine, but the ones with recurring payments fail to show up on the storefront even after I stop my localhost and start it up again.
Expected behavior: The recurring payment product should show up on the store along with the one time payment products
Actual behavior: The recurring payment product does not show up.
Reproduces how often: 100% of the time
os: MacOS High Sierra 10.13.6
node: v10.7.0
npm: 6.14.2
gatsby: Gatsby CLI version: 2.8.22
gatsby-source-stripe: 2.2.2
None.
Thanks for creating this. It's extremely helpful.
I'm having an issue using the plugin with Gatsby Image.
I've changed downloadFiles to true, but when building the query for products in GraphiQL I'm unable to see a local files field mentioned in the read me. My query looks as follows.
query MyQuery {
allStripePrice {
edges {
node {
active
product {
id
images
}
}
}
}
}
Is there a way to use the plugin alongside Gatsby Image to optimize the images attached to each product? I've attached an image of what GraphiQL is giving me as options.
Thanks,
Jon
Do this so that people know that, since I'm using "createContentDigest" they'll need to be running at least Gatsby 2.0.15 or they'll get an error.
Prerequisites
[ X ] Put an X between the brackets on this line if you have done all of the following:
Describe the bug
A clear and concise description of what the bug is.
I've updated to GtsabyV4 - When running my site i get the following error
"gatsby-source-stripe" threw an error while running the sourceNodes lifecycle:
Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
This is not necessarily a BUG but maybe a request to update to support Gatsby V4.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Everything to run smoothly and all Stripe Graphql data to appear.
Screenshots
Versions (please complete the following information):
os: macOS Big Sur 11.6
node: v14.17.3
npm: 6.14.13
gatsby: 4.0.2
gatsby-source-stripe: 3.2.2
Gatsby config:
Copy the portion of your Gatsby config for this plugin here. Do not include your secretKey
.
{
resolve: `gatsby-source-stripe`,
options: {
objects: ['Price'],
secretKey: ...,
downloadFiles: true
}
},
Hey,
Thanks for an awesome plugin. I might be missing something; I read the documentation that you try to auto-expand as many objects as possible and also that the new Prices API is quite new.
However when running this query:
query {
prices: allStripePrice(
filter: { active: { eq: true } }
sort: { fields: [unit_amount] }
) {
edges {
node {
id
active
currency
billing_scheme
tiers_mode
unit_amount
product {
id
name
}
}
}
}
}
it seems tiers
are not available, I tried
tiers {
unit_amount
flat_amount
}
and only tiers etc, but seems it's not there. Am i missing something or is there no support yet for that /not expanded in the plugin? (This is the object I'm referring to https://stripe.com/docs/api/prices/object#price_object-tiers )
When running gatsby build
on a project that uses both gatsby-source-stripe
and gatsby-transformer-json
, the build fails with an error like the following:
Error: Nodes can only be updated by their owner. Node "prod_FKQdtEsTJLpdoG" is owned by "gatsby-source-stripe" and another plugin "gatsby-transformer-json" tried to update it.
With a non-zero exit code, the build fails.
gatsby-source-stripe
.env
filegatsby-transformer-json
to plugins section of gatsby-config.js
gatsby build
Expected behavior: gatsby-transformer-node
does nothing to the Stripe object nodes
Actual behavior: gatsby-transformer-node
sees an application/json
node internal type and tries to transform it.
Reproduces how often: 100% of builds
os: [version]
node: 10.13.0
npm: 6.7.0
gatsby: 2.10.4
gatsby-source-stripe: 3.0.1
If you modify the plugin to use a different internal mediaType in StripeObject.js
, the error disappears.
Hey! I've been having an issue with gatsby-starter-stripe and I'm finally getting around to figuring it out.
This started happening after upgrading the plugin to 3.0+. sku.product.images
is always empty unless sku.image
is present. I'll provide an example of two skus of the same product:
{
"node": {
"id": "sku_EsZzIlws0rJnTu",
"image": "https://raw.githubusercontent.com/brxck/gatsby-starter-stripe/master/images/osprey_aether_pro1.jpg",
"product": {
"name": "Osprey Aether Pro 70",
"id": "prod_EsZynTea7jNNWv",
"images": [ ... ],
"localFiles": [
// yep they're here
]
}
}
},
{
"node": {
"id": "sku_EsZzHhPj9lU0ck",
"image": null, // this is the only difference
"product": {
"name": "Osprey Aether Pro 70",
"id": "prod_EsZynTea7jNNWv",
"images": [ ... ],
"localFiles": null // but they're not here!
}
}
},
I haven't been able to figure out why this is happening yet.
Create a product with a product image. Create two skus for the product, one with a sku image (with_image
) and one without (without_image
).
Expected behavior: Both skus should have product images on sku.product.localFiles
.
Actual behavior: Only with_image.product.localFiles
contains file nodes. without_image.product.localFiles
is null.
Reproduces how often: Every time.
os: Linux
node: v10.11.0
npm: 6.9.0
gatsby: 2.5.12
gatsby-source-stripe: 3.0.2
So I know that the download files feature doesn't work with images uploaded to Stripe, so the errors I got make sense, BUT all the errors were a bit overwhelming. The URL in the "Failed to process remote content" seems to show up twice, and the formatting could be improved.
Ignore the non-capitalization of "stripe" in the screenshot. I fixed that and it's in the latest release.
Let me know your thoughts on how we might improve these error outputs @brxck and @Francesco-Lanciana !
Thanks!
For some reason, I get an error when attempting to iterate over the "File" type Stripe API response. The API method I use is a list method, so I'm not sure why I'm getting this error. Just making a note here that I (or someone else) needs to investigate this further.
Just putting a reminder here that I'd like to integrate unit tests into this project, especially now that more people are contributing to it.
I'm open to suggestions on unit testing frameworks. My first thought is Jest, as I have the most experience with that, but I'm not 100% married to the idea.
Just a list of some small updates want to do:
Is there a way to avoid putting the stripe secret key in the gatsby-config and accessing it from an environment variable instead? I'm a little weary of including sensitive keys in the repo.
This would likely also then allow us to upgrade to ESLint 8.
Could you change your package.json engines
to support the same versions as Gatsby e.g. 6+? Or at least 8+
Many people don't have Node 10 installed still so this plugin will break for them.
Any GraphQL File object that contains an image has a childImageSharp
field that you can query and pass to Gatsby image components (using gatsby-plugin-image
). It would be very cool if it were possible to do the same thing with gatsby-source-stripe
when retrieving Product images. This would allow seamless interaction between the gatsby-image-plugin
and gatsby-stripe-plugin
to display product images.
At present, querying for the image
field on a product returns something like the following;
{
"data": {
"stripePrice": {
"id": "price_1KEBiRGuNIhpNc5curNr3z04",
"product": {
"description": "A tote bag 4 u <3",
"images": [
"https://files.stripe.com/links/MDB8YWNjdF8xN2JIV29HdU5JaHBOYzVjfGZsX3Rlc3RfMUhlM0hwbEFaSkUxdDJjZkVtejNnQmR500hXn0ZUFq"
],
"name": "Fancy tote"
}
}
},
"extensions": {}
}
i.e. an array of links that can be used to download the image file. Somehow you'd need to convert this to a File(-like?) object so that GraphQL / gatsby-plugin-image
could expand an associated childImageSharp
field. From a glance, it looks like it might be possible to use the FileDownloadService
class to do this?
Docs for gatsby-plugin-image
: https://www.gatsbyjs.com/plugins/gatsby-plugin-image
Looks like we're missing a couple of Stripe resources and should add them:
https://stripe.com/docs/api/credit_notes/list
https://stripe.com/docs/api/radar/reviews/list
https://stripe.com/docs/api/radar/value_lists/list
I'm using the Stripe Checkout Beta, as well as images[]
field on Products. For Product images, an array of image URLs is added to a product via the Stripe API. These images are hosted elsewhere, in my case they live in the static
directory of my Gatsby site.
Here's an example of a query and it's response:
Query
query allProducts {
products: allStripeProduct {
edges {
node {
id
images
}
}
}
}
Response
{
"data": {
"products": {
"edges": [
{
"node": {
"id": "prod_EcDfq1CvGkdgbc",
"images": [
"http://localhost:8000/products/600.jpg"
]
}
},
...
]
}
}
}
If I change the query to add localFiles
, an error is returned.
Query
query allProducts {
products: allStripeProduct {
edges {
node {
id
images
localFiles
}
}
}
}
Response
{
"errors": [
{
"message": "Cannot query field \"localFiles\" on type \"StripeProduct\".",
"locations": [
{
"line": 7,
"column": 11
}
]
}
]
}
I've reviewed the existing issues related to this but it seems I'm doing everything correctly. I'm using Checkout Beta, but I believe that only comes into play on SKU images.
Is the current version of gatsby-source-stripe
setup to work with the Product images array?
os: Mac 10.14.3
node: 10.15.1
npm: 6.4.1
gatsby: 2.1.17
gatsby-source-stripe: 2.1.7
Right now the How to query section is looking kind of sad. Sure, it covers the basics, but it would be nice if there were more examples. Especially, more complex examples.
Mainly I'm interested in showing examples of how to:
Additionally, creating examples that show how to put together queries both in GraphiQL and how that query would look in code, in a GraphQL project. Both coded static queries and regular queries would be great, too.
Further, sharing how to access the "Docs" section in GraphiQL to peruse the schema (i.e. to answer a question like: "what are the fields on my StripeCustomer nodes").
If you're interested in helping beef up this section, feel free to:
Any and all help, as always, would be much appreciated. 🎉
Hi,
Not entirely sure if this is an issue but I'm not getting the whole product details especially price and it's api_id, i believed this api_id was sku before.
It's pulling the product name, images etc. but no price and api_id
gatsby config used
{
resolve: gatsby-source-stripe
,
options: {
objects: [
"Balance",
"BalanceTransaction",
"Product",
"ApplicationFee",
"Sku",
"Subscription",
],
secretKey: "my_secret_key",
downloadFiles: true,
},
},
Thanks
Is there a way to query the plans
for Subscription
objects?
It looks like I can only query allStripeSku
for skus or allStripeProduct
where I can get the product id of any type of product (product and services) but not the plan
id.
allStripeSubscription
Expected behavior: A way to query the different products that are plans of a subscription for a reoccurring payment
Actual behavior: Can't find it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.