MeterEvent.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Billing;
  4. /**
  5. * A billing meter event represents a customer's usage of a product. Meter events are used to bill a customer based on their usage.
  6. * Meter events are associated with billing meters, which define the shape of the event's payload and how those events are aggregated for billing.
  7. *
  8. * @property string $object String representing the object's type. Objects of the same type share the same value.
  9. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  10. * @property string $event_name The name of the meter event. Corresponds with the <code>event_name</code> field on a meter.
  11. * @property string $identifier A unique identifier for the event.
  12. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  13. * @property \Stripe\StripeObject $payload The payload of the event. This contains the fields corresponding to a meter's <code>customer_mapping.event_payload_key</code> (default is <code>stripe_customer_id</code>) and <code>value_settings.event_payload_key</code> (default is <code>value</code>). Read more about the <a href="https://stripe.com/docs/billing/subscriptions/usage-based/recording-usage#payload-key-overrides">payload</a>.
  14. * @property int $timestamp The timestamp passed in when creating the event. Measured in seconds since the Unix epoch.
  15. */
  16. class MeterEvent extends \Stripe\ApiResource
  17. {
  18. const OBJECT_NAME = 'billing.meter_event';
  19. /**
  20. * Creates a billing meter event.
  21. *
  22. * @param null|array $params
  23. * @param null|array|string $options
  24. *
  25. * @throws \Stripe\Exception\ApiErrorException if the request fails
  26. *
  27. * @return \Stripe\Billing\MeterEvent the created resource
  28. */
  29. public static function create($params = null, $options = null)
  30. {
  31. self::_validateParams($params);
  32. $url = static::classUrl();
  33. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  34. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  35. $obj->setLastResponse($response);
  36. return $obj;
  37. }
  38. }