Session.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\BillingPortal;
  4. /**
  5. * The Billing customer portal is a Stripe-hosted UI for subscription and
  6. * billing management.
  7. *
  8. * A portal configuration describes the functionality and features that you
  9. * want to provide to your customers through the portal.
  10. *
  11. * A portal session describes the instantiation of the customer portal for
  12. * a particular customer. By visiting the session's URL, the customer
  13. * can manage their subscriptions and billing details. For security reasons,
  14. * sessions are short-lived and will expire if the customer does not visit the URL.
  15. * Create sessions on-demand when customers intend to manage their subscriptions
  16. * and billing details.
  17. *
  18. * Learn more in the <a href="https://stripe.com/docs/billing/subscriptions/integrating-customer-portal">integration guide</a>.
  19. *
  20. * @property string $id Unique identifier for the object.
  21. * @property string $object String representing the object's type. Objects of the same type share the same value.
  22. * @property string|\Stripe\BillingPortal\Configuration $configuration The configuration used by this session, describing the features available.
  23. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  24. * @property string $customer The ID of the customer for this session.
  25. * @property null|\Stripe\StripeObject $flow Information about a specific flow for the customer to go through. See the <a href="https://stripe.com/docs/customer-management/portal-deep-links">docs</a> to learn more about using customer portal deep links and flows.
  26. * @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.
  27. * @property null|string $locale The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer’s <code>preferred_locales</code> or browser’s locale is used.
  28. * @property null|string $on_behalf_of The account for which the session was created on behalf of. When specified, only subscriptions and invoices with this <code>on_behalf_of</code> account appear in the portal. For more information, see the <a href="https://stripe.com/docs/connect/separate-charges-and-transfers#settlement-merchant">docs</a>. Use the <a href="https://stripe.com/docs/api/accounts/object#account_object-settings-branding">Accounts API</a> to modify the <code>on_behalf_of</code> account's branding settings, which the portal displays.
  29. * @property null|string $return_url The URL to redirect customers to when they click on the portal's link to return to your website.
  30. * @property string $url The short-lived URL of the session that gives customers access to the customer portal.
  31. */
  32. class Session extends \Stripe\ApiResource
  33. {
  34. const OBJECT_NAME = 'billing_portal.session';
  35. /**
  36. * Creates a session of the customer portal.
  37. *
  38. * @param null|array $params
  39. * @param null|array|string $options
  40. *
  41. * @throws \Stripe\Exception\ApiErrorException if the request fails
  42. *
  43. * @return \Stripe\BillingPortal\Session the created resource
  44. */
  45. public static function create($params = null, $options = null)
  46. {
  47. self::_validateParams($params);
  48. $url = static::classUrl();
  49. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  50. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  51. $obj->setLastResponse($response);
  52. return $obj;
  53. }
  54. }