Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: proactively set stripe ids #169

Merged
merged 1 commit into from
Jun 27, 2022
Merged

chore: proactively set stripe ids #169

merged 1 commit into from
Jun 27, 2022

Conversation

spence-s
Copy link
Contributor

  • Creates and Sets and stores the stripe id for the customer regardless of whether they checkout or not.
  • For some reason web tests would not pass for me.
  Uncaught exception in test/web/auth.js

  Error:
  Something went wrong installing the "sharp" module

  Module did not self-register: '/Users/spencer/Projects/forwardemail.net/node_modules/sharp/build/Release/sharp-darwin-x64.node'.

  Possible solutions:
  - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
  - Install for the current darwin-x64 runtime: "npm install --platform=darwin --arch=x64 sharp"
  - Consult the installation documentation: https://sharp.pixelplumbing.com/install

  › - Consult the installation documentation: https://sharp.pixelplumbing.com/install
  › Object.<anonymous> (node_modules/sharp/lib/sharp.js:34:9)
  › Module.replacementCompile (node_modules/append-transform/index.js:60:13)
  › node_modules/append-transform/index.js:64:4
  › Object.<anonymous> (node_modules/append-transform/index.js:64:4)
  › Object.<anonymous> (node_modules/sharp/lib/constructor.js:8:1)
  › Module.replacementCompile (node_modules/append-transform/index.js:60:13)
  › node_modules/append-transform/index.js:64:4

(node:88019) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/spencer/Projects/forwardemail.net/node_modules/factory-girl/package.json' of './src/index'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
  ✖ test/web/auth.js exited with a non-zero exit code: 1
  ─

  `--fail-fast` is on. 4 test files were skipped.

  5 tests passed
  1 uncaught exception

@spence-s
Copy link
Contributor Author

Seems as though the same test problems are happening here in CI

Copy link
Contributor

@titanism titanism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//
// create and validate stripe customer here
// (ensure valid customer before webhooks hit)
//
try {
  const customer = isSANB(ctx.state.user[config.userFields.stripeCustomerID]) ?
    await stripe.customers.retrieve(ctx.state.user[config.userFields.stripeCustomerID]) :
    await stripe.customers.create({ email: ctx.state.user.email });

  if (customer.deleted) {
    ctx.logger.warn('Stripe customer previously deleted', { customer });
    customer = await stripe.customers.create({ email: ctx.state.user.email });
  }

  ctx.state.user[config.userFields.stripeCustomerID] = customer.id;
  await ctx.state.user.save();
} catch (err) {
  ctx.logger.fatal(err);
  // email admins here
  try {
    await emailHelper({
      template: 'alert',
      message: {
        to: config.email.message.from,
        subject: `Error creating Stripe customer for ${ctx.state.user.email}`
      },
      locals: { message: err.message }
    });
  } catch (err) {
    ctx.logger.fatal(err);
  }

  throw ctx.translateError('UNKNOWN_ERROR');
}

@spence-s
Copy link
Contributor Author

spence-s commented Jun 26, 2022

Made all the requested changes - still seeing the same test issues, even after removing everything and reinstalling with NPM.

@spence-s spence-s requested a review from titanism June 26, 2022 15:07
@titanism titanism merged commit 1e26d09 into master Jun 27, 2022
@titanism titanism deleted the titanism-67 branch June 27, 2022 20:09
titanism added a commit that referenced this pull request Jul 1, 2022
chore: proactively set stripe ids
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants