Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

TypeError: stripePackage is not a function / TypeError: Stripe is not a constructor #495

Closed
ScottAgirs opened this issue Sep 4, 2018 · 1 comment

Comments

@ScottAgirs
Copy link

Trying to implement back-end and can't figure out if this is a bug or I'm missing something

Stack:
Meteor w/ React

Scenario #1:

import express from "express";
import stripePackage from "stripe";

const app = express;
const stripe = stripePackage("sk_test_CbS5kaXo77777777");

// ..

Result:

TypeError: stripePackage is not a function

Scenario #2:

import * as Stripe from 'stripe';
import express from "express";

const app = express;
const stripe = new Stripe('sk_test_CbS5kaXo77777777');
//…

Result:

TypeError: Stripe is not a constructor

@brandur-stripe
Copy link
Contributor

@ScottAgirs You can see in the source that Stripe is a conventional object constructor that's just a function:

function Stripe(key, version) {
...
}

Here's a simple test script that I ran locally that I think accomplish what you're trying to do (and works for me):

var stripeFunc = require("./lib/stripe");

const stripe = stripeFunc("sk_test_...");

stripe.charges.retrieve(
  "ch_1D6nxm2eZvKYlo2CmXVNxYDj",
  function(err, charge) {
    console.log("hello");
  }
);

I suspect something in your stack is causing this to fail, and I'd suggest seeing if you can find out what exactly the stripePackage variable contains in your setup.

I'm going to close this for now. Feel free to reopen if it looks like you've tripped across a real bug, but please provide more supporting material to back that up. If you're still having trouble, feel free to open a case with [email protected] and they'll see what they can do to help you out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants