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

usageRecords Create not triggering callback #451

Closed
thinkocapo opened this issue May 1, 2018 · 3 comments
Closed

usageRecords Create not triggering callback #451

thinkocapo opened this issue May 1, 2018 · 3 comments
Assignees

Comments

@thinkocapo
Copy link

Background

I upgraded from v5.6.1 to v5.8.0 to get access to stripe.usageRecords. Thank you for this improvement.

Problem

The callback to stripe.usageRecords.create is not executing. The call hangs. I went to my Dashboard.Stripe and saw the usage record was in fact created. Maybe something is going wrong in your stripe server endpoint?

router.post('/subscription/usage', async (req,res) => {
  // ...
  stripe.usageRecords.create({
    quantity: 1,
    timestamp: timestamp,
    subscription_item: subscription_item
  }, function(err, usageRecord) {
    console.log('usageRecord', usageRecord) // DOES NOT LOG
    if (err) {
      console.log('\n===== stripe usage error ====\n', err) // DOES NOT LOG
    } else {
      res.send(200) // DOES NOT HAPPEN, because my front-end says the call to /subscription/usage is still 'PENDING'
    }

Dashboard.Stripe verification the Usage Record was Created

Billing > Subscriptions > Selection Customer > Products/Pricing Plan > click 'View Usage This Period' > see timestamp for the call I just made in my testing, its now +1 more than previously

Overall, the Stripe Client is Working for me

I'm calling this stripe method the same why that i'm calling other things like stripe.subscriptions.create and stripe.customers.create, and handling the callback the same, per the api documentation. Those methods are working for me.

@remi-stripe
Copy link
Contributor

FWIW this works fine if you use the .then() approach. Example this works:

stripe.usageRecords.create({
  quantity: 100,
  timestamp: 1525204558,
  subscription_item: "si_1234"
}).then(function(usageRecord) {
  console.log("Usage Record" + JSON.stringify(usageRecord));
});

There must be something wrong with the way the UsageRecord object is setup in the library but I have not found what that is yet.

@thinkocapo
Copy link
Author

You are correct :) I should have tried that sooner! Hopefully .then() will work in other areas of the stripe-node lib.

Thank you

@remi-stripe
Copy link
Contributor

Yes it should work everywhere but you should not have to change your integration logic. I just have not been able to pinpoint the root cause yet but we'll hopefully find the problem over the next few days!

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

3 participants