Skip to content

Commit

Permalink
Merge pull request #1094 from stripe/latest-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Feb 20, 2021
2 parents e45b12f + 886477d commit cbce613
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ matrix:

env:
global:
- STRIPE_MOCK_VERSION=0.101.0
- STRIPE_MOCK_VERSION=0.103.0
cache:
directories:
- $HOME/.composer/cache/files
Expand Down
2 changes: 2 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
require __DIR__ . '/lib/Balance.php';
require __DIR__ . '/lib/BalanceTransaction.php';
require __DIR__ . '/lib/BankAccount.php';
require __DIR__ . '/lib/BillingPortal/Configuration.php';
require __DIR__ . '/lib/BillingPortal/Session.php';
require __DIR__ . '/lib/BitcoinReceiver.php';
require __DIR__ . '/lib/BitcoinTransaction.php';
Expand Down Expand Up @@ -164,6 +165,7 @@
require __DIR__ . '/lib/Service/ApplicationFeeService.php';
require __DIR__ . '/lib/Service/BalanceService.php';
require __DIR__ . '/lib/Service/BalanceTransactionService.php';
require __DIR__ . '/lib/Service/BillingPortal/ConfigurationService.php';
require __DIR__ . '/lib/Service/BillingPortal/SessionService.php';
require __DIR__ . '/lib/Service/ChargeService.php';
require __DIR__ . '/lib/Service/Checkout/SessionService.php';
Expand Down
31 changes: 31 additions & 0 deletions lib/BillingPortal/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\BillingPortal;

/**
* A portal configuration describes the functionality and behavior of a portal
* session.
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property bool $active Whether the configuration is active and can be used to create portal sessions.
* @property null|string $application ID of the Connect Application that created the configuration.
* @property \Stripe\StripeObject $business_profile
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string $default_return_url The default URL to redirect customers to when they click on the portal's link to return to your website. This can be <a href="https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url">overriden</a> when creating the session.
* @property \Stripe\StripeObject $features
* @property bool $is_default Whether the configuration is the default. If <code>true</code>, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
* @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.
* @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
*/
class Configuration extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing_portal.configuration';

use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;
use \Stripe\ApiOperations\Update;
}
26 changes: 18 additions & 8 deletions lib/BillingPortal/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,34 @@
namespace Stripe\BillingPortal;

/**
* A session describes the instantiation of the customer portal for a particular
* customer. By visiting the session's URL, the customer can manage their
* subscriptions and billing details. For security reasons, sessions are
* The Billing customer portal is a Stripe-hosted UI for subscription and billing
* management.
*
* A portal configuration describes the functionality and features that you want to
* provide to your customers through the portal.
*
* A portal session describes the instantiation of the customer portal for a
* particular customer. By visiting the session's URL, the customer can manage
* their subscriptions and billing details. For security reasons, sessions are
* short-lived and will expire if the customer does not visit the URL. Create
* sessions on-demand when customers intend to manage their subscriptions and
* billing details.
*
* Integration guide: <a
* href="https://stripe.com/docs/billing/subscriptions/integrating-customer-portal">Billing
* customer portal</a>.
* Learn more in the <a
* href="https://stripe.com/docs/billing/subscriptions/customer-portal">product
* overview</a> and <a
* href="https://stripe.com/docs/billing/subscriptions/integrating-customer-portal">integration
* guide</a>.
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property string|\Stripe\BillingPortal\Configuration $configuration The configuration used by this session, describing the features available.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $customer The ID of the customer for this session.
* @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.
* @property string $return_url The URL to which Stripe should send customers when they click on the link to return to your website.
* @property string $url The short-lived URL of the session giving customers access to the customer portal.
* @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/charges-transfers#on-behalf-of">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.
* @property string $return_url The URL to redirect customers to when they click on the portal's link to return to your website.
* @property string $url The short-lived URL of the session that gives customers access to the customer portal.
*/
class Session extends \Stripe\ApiResource
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property bool $active Whether the plan can be used for new purchases.
* @property null|string $aggregate_usage Specifies a usage aggregation strategy for plans of <code>usage_type=metered</code>. Allowed values are <code>sum</code> for summing up all usage during a period, <code>last_during_period</code> for using the last usage record reported within a period, <code>last_ever</code> for using the last usage record ever (across period bounds) or <code>max</code> which uses the usage record with the maximum reported usage during a period. Defaults to <code>sum</code>.
* @property null|int $amount The unit amount in %s to be charged, represented as a whole integer if possible.
* @property null|string $amount_decimal The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places.
* @property null|int $amount The unit amount in %s to be charged, represented as a whole integer if possible. Only set if <code>billing_scheme=per_unit</code>.
* @property null|string $amount_decimal The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set if <code>billing_scheme=per_unit</code>.
* @property string $billing_scheme Describes how to compute the price per period. Either <code>per_unit</code> or <code>tiered</code>. <code>per_unit</code> indicates that the fixed amount (specified in <code>amount</code>) will be charged per unit in <code>quantity</code> (for plans with <code>usage_type=licensed</code>), or per unit of total usage (for plans with <code>usage_type=metered</code>). <code>tiered</code> indicates that the unit pricing will be computed using a tiering strategy as defined using the <code>tiers</code> and <code>tiers_mode</code> attributes.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
Expand Down
4 changes: 2 additions & 2 deletions lib/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
* @property null|string $tiers_mode Defines if the tiering price should be <code>graduated</code> or <code>volume</code> based. In <code>volume</code>-based tiering, the maximum quantity within a period determines the per unit price. In <code>graduated</code> tiering, pricing can change as the quantity grows.
* @property null|\Stripe\StripeObject $transform_quantity Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with <code>tiers</code>.
* @property string $type One of <code>one_time</code> or <code>recurring</code> depending on whether the price is for a one-time purchase or a recurring (subscription) purchase.
* @property null|int $unit_amount The unit amount in %s to be charged, represented as a whole integer if possible.
* @property null|string $unit_amount_decimal The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places.
* @property null|int $unit_amount The unit amount in %s to be charged, represented as a whole integer if possible. Only set if <code>billing_scheme=per_unit</code>.
* @property null|string $unit_amount_decimal The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set if <code>billing_scheme=per_unit</code>.
*/
class Price extends ApiResource
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/BillingPortal/BillingPortalServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
* Service factory class for API resources in the BillingPortal namespace.
*
* @property ConfigurationService $configurations
* @property SessionService $sessions
*/
class BillingPortalServiceFactory extends \Stripe\Service\AbstractServiceFactory
Expand All @@ -15,6 +16,7 @@ class BillingPortalServiceFactory extends \Stripe\Service\AbstractServiceFactory
* @var array<string, string>
*/
private static $classMap = [
'configurations' => ConfigurationService::class,
'sessions' => SessionService::class,
];

Expand Down
73 changes: 73 additions & 0 deletions lib/Service/BillingPortal/ConfigurationService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service\BillingPortal;

class ConfigurationService extends \Stripe\Service\AbstractService
{
/**
* Returns a list of configurations that describe the functionality of the customer
* portal.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection
*/
public function all($params = null, $opts = null)
{
return $this->requestCollection('get', '/v1/billing_portal/configurations', $params, $opts);
}

/**
* Creates a configuration that describes the functionality and behavior of a
* PortalSession.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\BillingPortal\Configuration
*/
public function create($params = null, $opts = null)
{
return $this->request('post', '/v1/billing_portal/configurations', $params, $opts);
}

/**
* Retrieves a configuration that describes the functionality of the customer
* portal.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\BillingPortal\Configuration
*/
public function retrieve($id, $params = null, $opts = null)
{
return $this->request('get', $this->buildPath('/v1/billing_portal/configurations/%s', $id), $params, $opts);
}

/**
* Updates a configuration that describes the functionality of the customer portal.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\BillingPortal\Configuration
*/
public function update($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/billing_portal/configurations/%s', $id), $params, $opts);
}
}
1 change: 1 addition & 0 deletions lib/Util/ObjectTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ObjectTypes
\Stripe\Balance::OBJECT_NAME => \Stripe\Balance::class,
\Stripe\BalanceTransaction::OBJECT_NAME => \Stripe\BalanceTransaction::class,
\Stripe\BankAccount::OBJECT_NAME => \Stripe\BankAccount::class,
\Stripe\BillingPortal\Configuration::OBJECT_NAME => \Stripe\BillingPortal\Configuration::class,
\Stripe\BillingPortal\Session::OBJECT_NAME => \Stripe\BillingPortal\Session::class,
\Stripe\BitcoinReceiver::OBJECT_NAME => \Stripe\BitcoinReceiver::class,
\Stripe\BitcoinTransaction::OBJECT_NAME => \Stripe\BitcoinTransaction::class,
Expand Down
82 changes: 82 additions & 0 deletions tests/Stripe/Service/BillingPortal/ConfigurationServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace Stripe\Service\BillingPortal;

/**
* @internal
* @covers \Stripe\Service\BillingPortal\ConfigurationService
*/
final class ConfigurationServiceTest extends \PHPUnit\Framework\TestCase
{
use \Stripe\TestHelper;

const TEST_RESOURCE_ID = 'bpc_123';

/** @var \Stripe\StripeClient */
private $client;

/** @var ConfigurationService */
private $service;

/**
* @before
*/
protected function setUpService()
{
$this->client = new \Stripe\StripeClient(['api_key' => 'sk_test_123', 'api_base' => MOCK_URL]);
$this->service = new ConfigurationService($this->client);
}

public function testCreate()
{
$this->expectsRequest(
'post',
'/v1/billing_portal/configurations'
);
$resource = $this->service->create([
'business_profile' => [
'terms_of_service_url' => 'https://example.com/tos',
'privacy_policy_url' => 'https://example.com/privacy',
],
'features' => [
'customer_update' => [
'allowed_updates' => ['address'],
'enabled' => true,
],
],
]);
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource);
}

public function testUpdate()
{
$this->expectsRequest(
'post',
'/v1/billing_portal/configurations/bpc_xyz'
);
$resource = $this->service->update('bpc_xyz', [
'active' => false,
]);
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource);
}

public function testRetrieve()
{
$this->expectsRequest(
'get',
'/v1/billing_portal/configurations/bpc_xyz'
);
$resource = $this->service->retrieve('bpc_xyz');
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource);
}

public function testList()
{
$this->expectsRequest(
'get',
'/v1/billing_portal/configurations'
);
$resource = $this->service->all();
static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $resource->data[0]);
}
}

0 comments on commit cbce613

Please sign in to comment.