Code Monkey home page Code Monkey logo

netlify-stripe-subscriptions's People

Contributors

bensontrent avatar cjavilla-stripe avatar dependabot[bot] avatar jlengstorf avatar rsedighi avatar thorsten-stripe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

netlify-stripe-subscriptions's Issues

Strip customer portal does not recognise user is logged out

Bug report

Describe the bug

Stripe customer portal doesn't recognise that a user is logged out.

To Reproduce

Using the demo:
Register in the portal.
Manage subscription.
Update plan.
Change plan and confirm.
Return to jamstack subscriptions.
Logout.
Click back in the browser, then Stripe payment details are shown.

Expected behavior

I would expect that a user would not be able to access their payment details in the Stripe customer portal after logging out.

Webhook: "cannot read property split of null" - Nickname setting not in UI of product/plan?

Missing Steps

Describe the bug

Webhook fails to update Netlify Identity user role.

It appears that in the payload sent to webhook, the nickname value used to update the Netlify Identity role is null.

In example, this is the stripeEvent.data.object.plan assigned to subscription sent in payload:
`
{
id: 'price_1IE***********,

object: 'plan',

active: true,

aggregate_usage: null,

amount: 4000,

amount_decimal: '4000',

billing_scheme: 'per_unit',

created: 1611793975,

currency: 'usd',

interval: 'month',

interval_count: 1,

livemode: false,

metadata: {},

nickname: null,

product: 'prod_I***********',

tiers_mode: null,

transform_usage: null,

trial_period_days: null,

usage_type: 'licensed'
}
`
This causes an error of "cannot read property split of null" in reference to line 38 of functions/handle-subscription-change, and visible in the Stripe webhook log.

`
// lines 36-39 below

// take the first word of the plan name and use it as the role

const plan = subscription.items.data[0].plan.nickname;

const role = plan.split(' ')[0].toLowerCase();`

Why ?

There doesn't seem to be an option to set nickname in dashboard during product/price creation. The UI is definitely different now than in the video showing this setup.

Screengrab from tutorial vid with @jlengstorf and @thorsten-stripe
Screen Shot 2021-01-28 at 1 04 57 PM

What I see today adding a pricing:
Screen Shot 2021-01-28 at 1 03 31 PM

Was told in stripe chat that product/price may need be created/updated via api rather than dashboard to add nickname value.

Seems like maybe a UI change in the dashboard has kinda messed up the straightforwardness of this.

To Reproduce

I just followed the tutorial. But the key points of it:

Creating product and pricing in dashboard of test account doesn't offer ability to set nickname

1.) create at least two products
2.) create customer with subscription
3.) change customer's subscription

Webhook fails with cannot read property split of null - visible in webhook log of Stripe dashboard

Expected behavior

Webhook would update Netlify Identity user role.

A Note

A put this here even though it isn't a "bug" (everything code wise clearly working as intended), but since the nickname is integral to the user -> customer -> purchase -> role -> content gate concept and the repo and tutorial as-is appear to run into this issue where the nickname can't be set by the UI. (unless, as is always possible, I have missed some glaring and important step ;) )

But I have to add the tutorial was wonderful

Not writing to FaunaDB - "Invalid database secret" - GraphQL endpoints

It has taken me three days to track down why I could not get data written to the faunaDB. I am sharing here to save anyone else the frustration.

I was getting the error: Invalid database secret.

In the tutorial the database address is given as: https://graphql.fauna.com/graphql however this will only work if, when you created the database in Fauna you chose "Classic".

I chose "United States (US)" as the region, and so the issue was that the address needed to be:

https://graphql.us.fauna.com/graphql.

I discovered this at the top of the page: https://docs.fauna.com/fauna/current/api/graphql/endpoints

Anyway, putting here to help others.

Help converting fauna.js to be compatible with node-fetch (v3) and ES modules

I have been trying all day to figure out how to fix /functions/utils/fauna.js as it is now failing due to node-fetch (3.0.0) and from what I understand is the new ES modules (ECMAScript modules).

I can't work out how to change the...

const fetch = require('node-fetch');

... into the new "import" format?

I have tried import fetch from 'node-fetch'; but this fails with a SyntaxError: Cannot use import statement outside a module error.

I can't define "type": "module" in package.json or I will get the following error: .eleventy.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.

Any help would be wonderful, thanks!

Original error

Discovered error from the Netlify functions log for identity-signup.js

Uncaught Exception {"errorType":"Error","errorMessage":"Must use import to load ES Module: /var/task/node_modules/node-fetch/src/index.js\nrequire() of ES modules is not supported.\nrequire() of /var/task/node_modules/node-fetch/src/index.js from /var/task/functifigur eons/utils/fauna.js is an ES module file as it is a .js file whose nearest parent package.json contains \"type\": \"module\" which defines all .js files in that package scope as ES modules.\nInstead rename index.js to end in .cjs, change the requiring code to use import(), or remove \"type\": \"module\" from /var/task/node_modules/node-fetch/package.json.\n","code":"ERR_REQUIRE_ESM","stack":["Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /var/task/node_modules/node-fetch/src/index.js","require() of ES modules is not supported.","require() of /var/task/node_modules/node-fetch/src/index.js from /var/task/functions/utils/fauna.js is an ES module file as it is a .js file whose nearest parent package.json contains \"type\": \"module\" which defines all .js files in that package scope as ES modules.","Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove \"type\": \"module\" from /var/task/node_modules/node-fetch/package.json.",""," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Module.require (internal/modules/cjs/loader.js:887:19)"," at require (internal/modules/cjs/helpers.js:74:18)"," at Object.<anonymous> (/var/task/functions/utils/fauna.js:3:15)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"]}

Signup using Identity is not working

Bug report

Describe the bug

I'm following instructions on Manage Subscriptions and Protect Content With Stripe, but it seems like this step is no longer working:

Copy the link address from the email. It contains a hash starting with confirmation_token= — add that hash to the end of http://localhost:8888 and you’ll be able to confirm your user account locally

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Follow instructions in tutorial linked above until you get to the step where you sign up as a new customer.
  2. Reload page with hash containing token as instructed.
  3. Getting this error:

image

Expected behavior

I'm expected to be able to sign up and log in.

Screenshots

See above.

System information

  • OS: Windows
  • Browser (if applies): Chrome
  • Server environment: Serverless

After adding functions, email will not confirm for authentication

Bug report

Before I began to add functions in /functions/, everything was working. Then, in the commit after I added /functions/, when I tried to sign up as a new user the email failed to confirm.

Describe the bug

I get this error message:
image

System information

-SSG: 11ty

Manage Subscription links to /[Object, object] when I spin this up on my own Netlify site.

Bug report

Describe the bug

After spinning this up on my own Netlify site, the "Manage Subscription" link is broken and I can't figure out why... Clicking it takes me to /[object%20Object]

To Reproduce

I followed the steps from this blog post...
https://www.netlify.com/blog/2020/07/13/manage-subscriptions-and-protect-content-with-stripe/

  1. Go to https://steady-cocada-5186f1.netlify.app/
  2. Click on "Manage Subscription"
  3. See error at https://steady-cocada-5186f1.netlify.app**/[object%20Object]**

Expected behavior

I expected it to redirect to the stripe subscription management page like it does in your live demo.
image

Screenshots

This is what I get when I try on my site after clicking "Manage Subscription"...
image

System information

  • OS: Windows 10
  • Chrome
  • Server environment: Node

Additional context

Sorry for creating an issue about this since your live demo is working correctly but I can't figure out why it work when I try to do it all myself.

Here is my repo...
https://github.com/cmarabate/netlify-stripe-subscriptions
But the only thing that I changed from the original repo is the Fauna graphql endpoint, I changed it to the US endpoint...
image

When I spin it up locally and click the Manage Subscription my terminal tells me...

Request from ::1: POST /.netlify/functions/create-manage-link
{"level":"error","message":"End - Error:"}
{"errorMessage":"Cannot read properties of undefined (reading 'getUserByNetlifyID')","errorType":"TypeError","level":"error","stackTrace":["Object.exports.handler (C:\\Users\\Owner\\_Dev\\_Sites\\_RaidChamps\\netlify-stripe-subscriptions\\functions\\create-manage-link.js:20:36)","processTicksAndRejections (node:internal/process/task_queues:96:5)"]}
Response with status 500 in 857 ms.

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.