Giter VIP home page Giter VIP logo

gatsby-source-stripe's Issues

Get Price in stripeProduct query

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.

[question] how rebuild happens automatically when something changes in product information!

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Description

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!

Cannot query field "allStripeSku" on type "Query" even with a valid secret key

Prerequisites

  • [ x] Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Description

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.

Steps to Reproduce

  1. Just add gatsby-source-stripe to your project
  2. Add what's needed to be added to the gatsby-config.js
  3. Try example query allStripeSku

Expected behavior: To have that query

Actual behavior: Graphql error Unknown field 'allStripeSku' on type 'Query'.

Reproduces how often: Every time

Versions

os: macOs Mojave 10.14.5
node: 10.16.0
npm: 6.9.0
gatsby: 2.17.11
gatsby-source-stripe: 3.0.4

Additional Information

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

Cannot query product field on price object

Prerequisites

[X] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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:

  1. Configure gatsby-source-stripe to use objects: ['Product', 'Price']
  2. Set up a page query similar to: (simplified for brevity)
  query Shop {
    allStripePrice(filter: {active: {eq: true}}) {
      edges {
        node {
          unit_amount
          product {
            id
          }
        }
      }
    }
  }
  1. Run in develop mode or build site
  2. Error is displayed

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!

Is there a way of getting back the price of a subscription (product)

Prerequisites

[ X ] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

Describe the bug
Is there a way of getting back the price of a subscription (Product)

Unknown argument "product" on field "allStripeSku" of type "Query"

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Description

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.

Steps to Reproduce

  1. Consider the following query:
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%

Versions

os: Mac 10.14.3
node: 10.15.1
npm: 6.4.1
gatsby: 2.4.1
gatsby-source-stripe: 2.1.7

'Unable to find plugin' After 2.20 Update

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?

Versions

os: Linux / Solus 4
node: 10.11.0
npm: 6.5.0
gatsby: 2.5.7
gatsby-source-stripe: 2.2.0

Issues with downloading files feature

@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!

Product object not showing in the graphQL

Prerequisites

[ x ] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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:

  1. add the product object to gatsby-config.js
  2. restart
  3. check graphQL

Expected behavior
I would expect to see the allStripeProduct in the graphQL

Screenshots
Screenshot 2022-11-08 at 8 36 49 PM

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,
      },
    },

Out of date Stripe SDK API version

Prerequisites

[x] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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.

Allow more control around auth headers for image downloads

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.

More details

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.

Remove auth header entirely

Description

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.

Steps to Reproduce

  1. Grab one of the URLs that points to an image hosted on Stripe.
  2. Open up an incognito window and paste in the address.
  3. Hit enter and the file should download

This means that the file can be downloaded without any cookies being provided for authentication.

More robust testing

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.

Linking products and SKUs

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?

Support Image Downloading

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!

Fix issues with downloading files

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!

Error "Cannot query field \"product\" on type \"StripePrice\"."

Prerequisites

[ ] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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
}
}
}
}

image

Gatsby config:
{
resolve: gatsby-source-stripe,
options: {
objects: ["Product", "Price", "Plan"],
secretKey: process.env.STRIPE_SECRET_KEY,
downloadFiles: true,
},
},

Stop trying to download the file object URL

Description

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:

  1. We want to avoid downloading files multiple times if it has multiple links
  2. It only contains links to publicly accessable files.

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:

  1. The url property will never work (at least I don't currently know how to make it work)
  2. I'm not aware of any way to provide multiple links to the same file in Stripe
    2a. Even if there were it's still better to download multiple than nothing at all
  3. I'm currently chasing this up with Stripe support but I don't actually think it's possible to make files private. All Stripe hosted files seem to be public.

Steps to Reproduce

  1. Upload an image to Stripe (SKU's let you upload an image to Stripe)
  2. Add "File" to options.objects of this plugin
  3. Run "npm run start" and you will see that the URLs associated with the File object will fail

Additional Information

I am currently chasing up the following two questions with Stripe support and will get post back when I have answers:

  1. What is the URL property of the File object actually used for? Can we make some use of it?
  2. Are all images hosted by Stripe public or is it possible to have private images/files.
    2a. In this case what HTTP headers would need to be provided to pull down these files.

A reference to the File object: https://stripe.com/docs/api/files/object

Possible to include `metadata` parameter in object response?

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?

Update CONTRIBUTING.md about how we handle dep versioning & committing

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:

  1. 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.

  2. For commits, we prefer the active voice / imperative mood. For more info (and a great article), check here.

  3. Encourage frequent running of ESLint and Prettier, to ensure consistency across how we code.

Gatsby 3 touchNode deprecation warning

Prerequisites

[X] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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:

  1. Start Gatsby 3 development server

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,
    },
},

Expand all the objects and sub-objects, oh my!

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:

  1. Fork the project
  2. Update stripeObjects.json with additional expandable fields
  3. Test in a local Gatsby project that those additions actually work
  4. Submit a pull request so I can test

Any and all help would be awesome. ❤️

Price instead of SKU

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.

Images not downloaded for Price objects

Prerequisites

[X] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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:

  1. Add the source plugin
  2. Set objects to ["Price"]
  3. Set 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.

Products with recurring payment not shown on Gatsby shop

Prerequisites

  • [ X] Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Description

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.

Steps to Reproduce

  1. Add product to Stripe with recurring payment
  2. Close local server and restart
  3. The recurring payment product does not show up

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

Versions

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

Additional Information

None.

Using Gatsby Image with Gatsby Source Stripe

Screen Shot 2021-05-23 at 10 13 28 AM

Hi,

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

[HELP WANTED] - GatsbyV4 [bug] - error while running the sourceNodes lifecycle

Prerequisites

[ X ] Put an X between the brackets on this line if you have done all of the following:

  • Read through the README fully.
  • Ensured you are running Node v.10 or above.
  • Made sure you're using at least Gatsby v.2.0.15.
  • Checked that your issue isn't already filed.

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:

  1. Update all packages to the latest Gatsby V4
  2. Run Gatsby in Develop or on Serve.
  3. error appears, and does not allow Stripe Graphwl to be generated

Expected behavior
Everything to run smoothly and all Stripe Graphql data to appear.

Screenshots

Screenshot 2021-11-01 at 16 50 22

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
      }
    },

Support for "tiers" on the Prices API

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 )

Using gatsby-transformer-json in the same project causes build errors

Pre-requisites

  • Read through the README fully
  • Ensured you are running Node v.10 or above
  • Made sure you're using at least Gatsby v.2.0.15
  • Checked that your issue isn't already filed

Description

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.

Steps to Reproduce

  1. Create a new Gatsby project that uses gatsby-source-stripe
  2. Add your stripe credentials via environment variable or .env file
  3. Add gatsby-transformer-json to plugins section of gatsby-config.js
  4. Run 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

Versions

os: [version]
node: 10.13.0
npm: 6.7.0
gatsby: 2.10.4
gatsby-source-stripe: 3.0.1

Additional Information

If you modify the plugin to use a different internal mediaType in StripeObject.js, the error disappears.

sku.product.localFiles is empty unless sku.image is present

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Description

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.

Steps to Reproduce

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.

Versions

os: Linux
node: v10.11.0
npm: 6.9.0
gatsby: 2.5.12
gatsby-source-stripe: 3.0.2

Format download files errors better

Screen Shot 2019-04-13 at 7 51 30 AM

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!

Write unit tests for project

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.

Q1 Updates

Just a list of some small updates want to do:

  • Add a "gotchas" section to the README and add example of Subscription products vs skus.
  • Use GitHub's new Issues template and remove old one.
  • Update usage of getAppInfo to remove deprecation warning.

Avoid stripe secret key in gatsby-config?

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.

Support Node 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.

Enable GraphQL support for Product images

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

Error: Cannot query field "localFiles" on type "StripeProduct".

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Question

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?

Versions

os: Mac 10.14.3
node: 10.15.1
npm: 6.4.1
gatsby: 2.1.17
gatsby-source-stripe: 2.1.7

Update README.md with more querying examples

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:

  • Sort
  • Filter
  • Limit

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:

  1. Fork the project
  2. Update the README.md
  3. Submit a PR!

Any and all help, as always, would be much appreciated. 🎉

Pulling product details

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

Subscription Plan Query Example

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Read through the README fully
    • Ensured you are running Node v.10 or above
    • Made sure you're using at least Gatsby v.2.0.15
    • Checked that your issue isn't already filed

Description

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.

Steps to Reproduce

  1. Search for an 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.