From 37becf0849f44f67838fdcd495209354c71da1f6 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 21 Apr 2020 17:22:55 -0700 Subject: [PATCH 1/2] Codegen for openapi 824d494 --- init.php | 1 + lib/BillingPortal/Session.php | 29 +++++++++++++++++++++++++++++ lib/Issuing/Authorization.php | 10 +--------- lib/Issuing/Card.php | 5 ++--- lib/Issuing/Cardholder.php | 2 -- lib/Issuing/Dispute.php | 8 -------- lib/Issuing/Transaction.php | 1 - lib/Payout.php | 2 +- lib/Plan.php | 7 +++---- lib/SubscriptionItem.php | 2 +- lib/SubscriptionSchedule.php | 1 - lib/WebhookEndpoint.php | 1 + 12 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 lib/BillingPortal/Session.php diff --git a/init.php b/init.php index d19490fff..75f4a8a3f 100644 --- a/init.php +++ b/init.php @@ -70,6 +70,7 @@ require __DIR__ . '/lib/Balance.php'; require __DIR__ . '/lib/BalanceTransaction.php'; require __DIR__ . '/lib/BankAccount.php'; +require __DIR__ . '/lib/BillingPortal/Session.php'; require __DIR__ . '/lib/BitcoinReceiver.php'; require __DIR__ . '/lib/BitcoinTransaction.php'; require __DIR__ . '/lib/Capability.php'; diff --git a/lib/BillingPortal/Session.php b/lib/BillingPortal/Session.php new file mode 100644 index 000000000..051eae519 --- /dev/null +++ b/lib/BillingPortal/Session.php @@ -0,0 +1,29 @@ +Self-serve + * Portal. + * + * @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 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 true if the object exists in live mode or the value false 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 self-serve portal. + */ +class Session extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'billing_portal.session'; + + use \Stripe\ApiOperations\Create; +} diff --git a/lib/Issuing/Authorization.php b/lib/Issuing/Authorization.php index d616c349d..f949be7b3 100644 --- a/lib/Issuing/Authorization.php +++ b/lib/Issuing/Authorization.php @@ -17,30 +17,22 @@ * @property int $amount The total amount that was authorized or rejected. This amount is in the card's currency and in the smallest currency unit. * @property bool $approved Whether the authorization has been approved. * @property string $authorization_method How the card details were provided. - * @property int $authorized_amount [DEPRECATED] The amount that has been authorized. This will be 0 when the object is created, and increase after it has been approved. - * @property string $authorized_currency [DEPRECATED] The currency that was presented to the cardholder for the authorization. Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property \Stripe\BalanceTransaction[] $balance_transactions List of balance transactions associated with this authorization. * @property \Stripe\Issuing\Card $card You can create physical or virtual cards that are issued to cardholders. * @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this authorization belongs. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property int $held_amount [DEPRECATED] The amount the authorization is expected to be in held_currency. When Stripe holds funds from you, this is the amount reserved for the authorization. This will be 0 when the object is created, and increase after it has been approved. For multi-currency transactions, held_amount can be used to determine the expected exchange rate. - * @property string $held_currency [DEPRECATED] The currency of the held amount. This will always be the card currency. - * @property bool $is_held_amount_controllable [DEPRECATED] If set true, you may provide held_amount to control how much to hold for the authorization. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property int $merchant_amount The total amount that was authorized or rejected. This amount is in the merchant_currency and in the smallest currency unit. * @property string $merchant_currency The currency that was presented to the cardholder for the authorization. Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property \Stripe\StripeObject $merchant_data * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property int $pending_authorized_amount [DEPRECATED] The amount the user is requesting to be authorized. This field will only be non-zero during an issuing_authorization.request webhook. - * @property int $pending_held_amount [DEPRECATED] The additional amount Stripe will hold if the authorization is approved. This field will only be non-zero during an issuing_authorization.request webhook. * @property null|\Stripe\StripeObject $pending_request The pending authorization request. This field will only be non-null during an issuing_authorization.request webhook. - * @property \Stripe\StripeObject[] $request_history History of every time the authorization was approved/denied (whether approved/denied by you directly, or by Stripe based on your authorization_controls). If the merchant changes the authorization by performing an incremental authorization or partial capture, you can look at request_history to see the previous states of the authorization. + * @property \Stripe\StripeObject[] $request_history History of every time the authorization was approved/denied (whether approved/denied by you directly or by Stripe based on your spending_controls). If the merchant changes the authorization by performing an incremental authorization or partial capture, you can look at this field to see the previous states of the authorization. * @property string $status The current status of the authorization in its lifecycle. * @property \Stripe\Issuing\Transaction[] $transactions List of transactions associated with this authorization. * @property \Stripe\StripeObject $verification_data * @property null|string $wallet What, if any, digital wallet was used for this authorization. One of apple_pay, google_pay, or samsung_pay. - * @property null|string $wallet_provider [DEPRECATED] What, if any, digital wallet was used for this authorization. One of apple_pay, google_pay, or samsung_pay. */ class Authorization extends \Stripe\ApiResource { diff --git a/lib/Issuing/Card.php b/lib/Issuing/Card.php index 17bc07cb0..81f416d27 100644 --- a/lib/Issuing/Card.php +++ b/lib/Issuing/Card.php @@ -8,19 +8,18 @@ * * @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 \Stripe\StripeObject $authorization_controls * @property string $brand The brand of the card. * @property null|string $cancellation_reason The reason why the card was canceled. * @property \Stripe\Issuing\Cardholder $cardholder

An Issuing Cardholder object represents an individual or business entity who is issued cards.

Related guide: How to create a Cardholder

* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. + * @property string $cvc The card's CVC. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with the expand parameter. Additionally, it's only available via the "Retrieve a card" endpoint, not via "List all cards" or any other endpoint. * @property int $exp_month The expiration month of the card. * @property int $exp_year The expiration year of the card. * @property string $last4 The last 4 digits of the card number. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string $name [DEPRECATED] The name of the cardholder, printed on the card. Refer to cardholder.name instead. - * @property null|\Stripe\StripeObject $pin Metadata about the PIN on the card. + * @property string $number The full unredacted card number. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with the expand parameter. Additionally, it's only available via the "Retrieve a card" endpoint, not via "List all cards" or any other endpoint. * @property null|string|\Stripe\Issuing\Card $replaced_by The latest card that replaces this card, if any. * @property null|string|\Stripe\Issuing\Card $replacement_for The card this card replaces, if any. * @property null|string $replacement_reason The reason why the previous card needed to be replaced. diff --git a/lib/Issuing/Cardholder.php b/lib/Issuing/Cardholder.php index a0b421af9..73b4642a0 100644 --- a/lib/Issuing/Cardholder.php +++ b/lib/Issuing/Cardholder.php @@ -12,13 +12,11 @@ * * @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 null|\Stripe\StripeObject $authorization_controls [DEPRECATED] Spending rules that give you some control over how this cardholder's cards can be used. Refer to our authorizations documentation for more details. * @property \Stripe\StripeObject $billing * @property null|\Stripe\StripeObject $company Additional information about a company cardholder. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property null|string $email The cardholder's email address. * @property null|\Stripe\StripeObject $individual Additional information about an individual cardholder. - * @property bool $is_default [DEPRECATED] Whether or not this cardholder is the default cardholder. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property string $name The cardholder's name. This will be printed on cards issued to them. diff --git a/lib/Issuing/Dispute.php b/lib/Issuing/Dispute.php index 56a89d867..5ba3f0480 100644 --- a/lib/Issuing/Dispute.php +++ b/lib/Issuing/Dispute.php @@ -14,15 +14,7 @@ * * @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 int $amount Disputed amount. Usually the amount of the disputed_transaction, but can differ (usually because of currency fluctuation or because only part of the order is disputed). - * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. - * @property string $currency The currency the disputed_transaction was made in. - * @property string|\Stripe\Issuing\Transaction $disputed_transaction The transaction being disputed. - * @property \Stripe\StripeObject $evidence * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. - * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property string $reason Reason for this dispute. One of duplicate, product_not_received, fraudulent, or other. - * @property string $status Current status of dispute. One of unsubmitted, under_review, won, or lost. */ class Dispute extends \Stripe\ApiResource { diff --git a/lib/Issuing/Transaction.php b/lib/Issuing/Transaction.php index f51226e98..324529364 100644 --- a/lib/Issuing/Transaction.php +++ b/lib/Issuing/Transaction.php @@ -21,7 +21,6 @@ * @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this transaction belongs. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. - * @property null|string|\Stripe\Issuing\Dispute $dispute If you've disputed the transaction, the ID of the dispute. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property int $merchant_amount The amount that the merchant will receive, denominated in merchant_currency and in the smallest currency unit. It will be different from amount if the merchant is taking payment in a different currency. * @property string $merchant_currency The currency with which the merchant is taking payment. diff --git a/lib/Payout.php b/lib/Payout.php index 15c24f905..5a47cc216 100644 --- a/lib/Payout.php +++ b/lib/Payout.php @@ -30,7 +30,7 @@ * @property string $method The method used to send this payout, which can be standard or instant. instant is only supported for payouts to debit cards. (See Instant payouts for marketplaces for more information.) * @property string $source_type The source balance this payout came from. One of card, fpx, or bank_account. * @property null|string $statement_descriptor Extra information about a payout to be displayed on the user's bank statement. - * @property string $status Current status of the payout (paid, pending, in_transit, canceled or failed). A payout will be pending until it is submitted to the bank, at which point it becomes in_transit. It will then change to paid if the transaction goes through. If it does not go through successfully, its status will change to failed or canceled. + * @property string $status Current status of the payout: paid, pending, in_transit, canceled or failed. A payout is pending until it is submitted to the bank, when it becomes in_transit. The status then changes to paid if the transaction goes through, or to failed or canceled (within 5 business days). Some failed payouts may initially show as paid but then change to failed. * @property string $type Can be bank_account or card. */ class Payout extends ApiResource diff --git a/lib/Plan.php b/lib/Plan.php index da39a20b7..a9f208e16 100644 --- a/lib/Plan.php +++ b/lib/Plan.php @@ -4,9 +4,8 @@ /** * Plans define the base price, currency, and billing cycle for subscriptions. For - * example, you might have a <currency>5</currency>/month plan that - * provides limited access to your products, and a - * <currency>15</currency>/month plan that allows full access. + * example, you might have a $5/month plan that provides limited access to your + * products, and a $15/month plan that allows full access. * * Related guides: Set up @@ -16,7 +15,7 @@ * * @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 plan is currently available for new subscriptions. + * @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 usage_type=metered. Allowed values are sum for summing up all usage during a period, last_during_period for using the last usage record reported within a period, last_ever for using the last usage record ever (across period bounds) or max which uses the usage record with the maximum reported usage during a period. Defaults to sum. * @property null|int $amount The amount in %s to be charged on the interval specified. * @property null|string $amount_decimal Same as amount, but contains a decimal value with at most 12 decimal places. diff --git a/lib/SubscriptionItem.php b/lib/SubscriptionItem.php index 6b40f6810..91678e165 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -11,7 +11,7 @@ * @property null|\Stripe\StripeObject $billing_thresholds Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - * @property \Stripe\Plan $plan

Plans define the base price, currency, and billing cycle for subscriptions. For example, you might have a <currency>5</currency>/month plan that provides limited access to your products, and a <currency>15</currency>/month plan that allows full access.

Related guides: Set up a subscription and more about products and plans.

+ * @property \Stripe\Plan $plan

Plans define the base price, currency, and billing cycle for subscriptions. For example, you might have a $5/month plan that provides limited access to your products, and a $15/month plan that allows full access.

Related guides: Set up a subscription and more about products and plans.

* @property int $quantity The quantity of the plan to which the customer should be subscribed. * @property string $subscription The subscription this subscription_item belongs to. * @property null|\Stripe\TaxRate[] $tax_rates The tax rates which apply to this subscription_item. When set, the default_tax_rates on the subscription do not apply to this subscription_item. diff --git a/lib/SubscriptionSchedule.php b/lib/SubscriptionSchedule.php index a5619caad..c27372724 100644 --- a/lib/SubscriptionSchedule.php +++ b/lib/SubscriptionSchedule.php @@ -24,7 +24,6 @@ * @property \Stripe\StripeObject[] $phases Configuration for the subscription schedule's phases. * @property null|int $released_at Time at which the subscription schedule was released. Measured in seconds since the Unix epoch. * @property null|string $released_subscription ID of the subscription once managed by the subscription schedule (if it is released). - * @property null|\Stripe\StripeObject $renewal_interval This field has been deprecated. Interval and duration at which the subscription schedule renews for when it ends if renewal_behavior is renew. * @property string $status The present status of the subscription schedule. Possible values are not_started, active, completed, released, and canceled. You can read more about the different states in our behavior guide. * @property null|string|\Stripe\Subscription $subscription ID of the subscription managed by the subscription schedule. */ diff --git a/lib/WebhookEndpoint.php b/lib/WebhookEndpoint.php index 6cee4feab..fb91339c6 100644 --- a/lib/WebhookEndpoint.php +++ b/lib/WebhookEndpoint.php @@ -19,6 +19,7 @@ * @property null|string $api_version The API version events are rendered as for this webhook endpoint. * @property null|string $application The ID of the associated Connect application. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. + * @property null|string $description An optional description of what the wehbook is used for. * @property string[] $enabled_events The list of events to enable for this endpoint. ['*'] indicates that all events are enabled, except those that require explicit selection. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. From 7d784d416ec715971e38a7dcadbe1594dce845bd Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 21 Apr 2020 18:34:56 -0700 Subject: [PATCH 2/2] Add missing details for codegen and tests --- .travis.yml | 2 +- lib/Util/Util.php | 1 + tests/Stripe/BillingPortal/SessionTest.php | 27 ++++++++++++++++++++++ tests/Stripe/Issuing/CardTest.php | 11 +++++++-- tests/Stripe/Issuing/DisputeTest.php | 24 +++---------------- tests/bootstrap.php | 2 +- 6 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 tests/Stripe/BillingPortal/SessionTest.php diff --git a/.travis.yml b/.travis.yml index cdc912220..6c1e8e859 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ matrix: env: global: - - STRIPE_MOCK_VERSION=0.79.0 + - STRIPE_MOCK_VERSION=0.88.0 cache: directories: - $HOME/.composer/cache/files diff --git a/lib/Util/Util.php b/lib/Util/Util.php index e6be0bbe7..e608561e7 100644 --- a/lib/Util/Util.php +++ b/lib/Util/Util.php @@ -57,6 +57,7 @@ public static function convertToStripeObject($resp, $opts) \Stripe\Balance::OBJECT_NAME => \Stripe\Balance::class, \Stripe\BalanceTransaction::OBJECT_NAME => \Stripe\BalanceTransaction::class, \Stripe\BankAccount::OBJECT_NAME => \Stripe\BankAccount::class, + \Stripe\BillingPortal\Session::OBJECT_NAME => \Stripe\BillingPortal\Session::class, \Stripe\BitcoinReceiver::OBJECT_NAME => \Stripe\BitcoinReceiver::class, \Stripe\BitcoinTransaction::OBJECT_NAME => \Stripe\BitcoinTransaction::class, \Stripe\Capability::OBJECT_NAME => \Stripe\Capability::class, diff --git a/tests/Stripe/BillingPortal/SessionTest.php b/tests/Stripe/BillingPortal/SessionTest.php new file mode 100644 index 000000000..f2a59b393 --- /dev/null +++ b/tests/Stripe/BillingPortal/SessionTest.php @@ -0,0 +1,27 @@ +expectsRequest( + 'post', + '/v1/billing_portal/sessions' + ); + $resource = Session::create([ + 'customer' => 'cus_123', + 'return_url' => 'https://stripe.com/return', + ]); + static::assertInstanceOf(\Stripe\BillingPortal\Session::class, $resource); + } +} diff --git a/tests/Stripe/Issuing/CardTest.php b/tests/Stripe/Issuing/CardTest.php index b9c396ab1..d82666861 100644 --- a/tests/Stripe/Issuing/CardTest.php +++ b/tests/Stripe/Issuing/CardTest.php @@ -62,10 +62,17 @@ public function testIsUpdatable() public function testCanRetrieveDetails() { $resource = Card::retrieve(self::TEST_RESOURCE_ID); - $this->expectsRequest( + + // stripe-mock does not support this anymore so we stub it + $this->stubRequest( 'get', - '/v1/issuing/cards/' . self::TEST_RESOURCE_ID . '/details' + '/v1/issuing/cards/' . self::TEST_RESOURCE_ID . '/details', + [], + null, + false, + ['object' => 'issuing.card_details'] ); + $details = $resource->details(); static::assertInstanceOf(\Stripe\Issuing\CardDetails::class, $details); } diff --git a/tests/Stripe/Issuing/DisputeTest.php b/tests/Stripe/Issuing/DisputeTest.php index 5f52d5dc1..f5e48dc26 100644 --- a/tests/Stripe/Issuing/DisputeTest.php +++ b/tests/Stripe/Issuing/DisputeTest.php @@ -14,10 +14,7 @@ final class DisputeTest extends \PHPUnit\Framework\TestCase public function testIsCreatable() { - $params = [ - 'reason' => 'fraudulent', - 'disputed_transaction' => 'ipi_123', - ]; + $params = []; $this->expectsRequest( 'post', @@ -49,29 +46,14 @@ public function testIsRetrievable() static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } - public function testIsSaveable() - { - $resource = Dispute::retrieve(self::TEST_RESOURCE_ID); - $resource->metadata['key'] = 'value'; - - $this->expectsRequest( - 'post', - '/v1/issuing/disputes/' . self::TEST_RESOURCE_ID - ); - $resource->save(); - static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); - } - public function testIsUpdatable() { $this->expectsRequest( 'post', '/v1/issuing/disputes/' . self::TEST_RESOURCE_ID, - ['metadata' => ['key' => 'value']] + [] ); - $resource = Dispute::update(self::TEST_RESOURCE_ID, [ - 'metadata' => ['key' => 'value'], - ]); + $resource = Dispute::update(self::TEST_RESOURCE_ID, []); static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index dd3443684..bf4ee03e6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/StripeMock.php'; -\define('MOCK_MINIMUM_VERSION', '0.79.0'); +\define('MOCK_MINIMUM_VERSION', '0.88.0'); if (\Stripe\StripeMock::start()) { \register_shutdown_function('\Stripe\StripeMock::stop');