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

Report usage for usage-based billing? #12

Closed
phortx opened this issue Jun 24, 2024 · 10 comments
Closed

Report usage for usage-based billing? #12

phortx opened this issue Jun 24, 2024 · 10 comments

Comments

@phortx
Copy link
Contributor

phortx commented Jun 24, 2024

Is there currently a way to report the usage for usage-based billing?

from https://docs.lemonsqueezy.com/guides/developer-guide/usage-based-billing

POST https://api.lemonsqueezy.com/v1/usage-records

{
  "data": {
    "type": "usage-records",
    "attributes": {
      "quantity": 1,
      "action": "increment"
    },
    "relationships": {
      "subscription-item": {
        "data": {
          "type": "subscription-items",
          "id": "1"
        }
      }
    }
  }
}
@phortx
Copy link
Contributor Author

phortx commented Jun 24, 2024

Or at least the possibility to make custom requests?

@PJUllrich
Copy link
Owner

Hey! No, I don't support the usage-based billing yet, but you can always make custom requests with e.g. LemonEx.Request.get("/usage-records") which should return what you expect.

@PJUllrich
Copy link
Owner

@phortx just added UsageRecords and released a new version 0.2.3 👍 Hope it helps!

@phortx
Copy link
Contributor Author

phortx commented Jun 25, 2024

What the fork!? Dude, how fast was that 😄 🚀

Amazing! I will give it a try this week, thank you very much! So impressive, much fast, very wow 🐕 😄

@PJUllrich
Copy link
Owner

PJUllrich commented Jun 25, 2024 via email

@phortx
Copy link
Contributor Author

phortx commented Jun 27, 2024

Hi,

I think there is still a bug:

This line should be

"subscription-item": %{

instead of

subscription_item: %{

According to https://docs.lemonsqueezy.com/api/usage-records#create-a-usage-record

@phortx
Copy link
Contributor Author

phortx commented Jun 27, 2024

I created a PR to fix that :) With that fix, everything works well. Thank you!

@PJUllrich
Copy link
Owner

merged! Thank you! ❤️

@PJUllrich
Copy link
Owner

Published as 0.2.4

@phortx
Copy link
Contributor Author

phortx commented Jun 27, 2024

Perfect, thank you :)

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