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

Added Support for New Usage Based Billing #1727

Open
wants to merge 5 commits into
base: 15.x
Choose a base branch
from

Conversation

Bark-fa
Copy link
Contributor

@Bark-fa Bark-fa commented Nov 26, 2024

This PR adds support for the new stripe usage billing based on billing meters


$startTime = $options['start_time'] ?? 1;

$endTime = $options['end_time'] ?? time();
Copy link
Member

Choose a reason for hiding this comment

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

Would these almost always be passed? If so, should we just make them arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Taylor, I think so, it's required as shown here https://docs.stripe.com/api/usage-record-summary/object

So yes, I think they would be better suited as arguments to the function

* @param array $requestOptions
* @return \Illuminate\Support\Collection
*/
public function meterEventSummaries(string $meterId, array $options = [], array $requestOptions = []): Collection
Copy link
Member

Choose a reason for hiding this comment

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

The reportMeterEvent uses $meter - this uses $meterId? Should they also both support Backed Enums?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, the $meter is the event name (the meter has to be configured to listen to a specific event name), but for the summaries endpoint, we need the meter ID that's created with the meter, different from the event_name. It could be a backed enum, but I envision someone using them by saving the value for their event names and meter IDs in config files or a DB if they are created dynamically.

They could be Enums, we could also have a data class that houses both the ID and the Event Name.

* @param array $requestOptions
* @return \Illuminate\Support\Collection
*/
public function meters(array $options = [], array $requestOptions = []): Collection
Copy link
Member

Choose a reason for hiding this comment

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

If we end up supporting Enums for meter names / IDs below, should we also support them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yes, if we end up passing meters around as an enum or a class, we should return them as such inside the collection.

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

Successfully merging this pull request may close these issues.

2 participants