From 23cfc8768af2f25c11ff0b88f652cfe1d8a52fe0 Mon Sep 17 00:00:00 2001 From: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 21:10:30 +0000 Subject: [PATCH] Update generated code for v1051 --- OPENAPI_VERSION | 2 +- lib/Account.php | 105 ++++++++++++++++++- lib/AccountLink.php | 19 +++- lib/AccountNotice.php | 48 ++++++++- lib/AccountSession.php | 18 +++- lib/ApplePayDomain.php | 62 +++++++++++- lib/ApplicationFee.php | 30 +++++- lib/Apps/Secret.php | 29 +++++- lib/Balance.php | 17 +++- lib/BalanceTransaction.php | 37 ++++++- lib/BankAccount.php | 40 +++++++- lib/Billing/Meter.php | 64 +++++++++++- lib/Billing/MeterEvent.php | 17 +++- lib/Billing/MeterEventAdjustment.php | 19 +++- lib/BillingPortal/Configuration.php | 67 ++++++++++++- lib/BillingPortal/Session.php | 17 +++- lib/Capability.php | 23 +++++ lib/Capital/FinancingOffer.php | 30 +++++- lib/Capital/FinancingSummary.php | 17 +++- lib/Capital/FinancingTransaction.php | 30 +++++- lib/Card.php | 40 +++++++- lib/Charge.php | 72 ++++++++++++- lib/Checkout/Session.php | 47 ++++++++- lib/Climate/Order.php | 67 ++++++++++++- lib/Climate/Product.php | 27 ++++- lib/Climate/Supplier.php | 29 +++++- lib/ConfirmationToken.php | 17 +++- lib/CountrySpec.php | 27 ++++- lib/Coupon.php | 99 +++++++++++++++++- lib/CreditNote.php | 83 ++++++++++++++- lib/Customer.php | 95 +++++++++++++++++- lib/CustomerSession.php | 19 +++- lib/Dispute.php | 54 +++++++++- lib/Entitlements/ActiveEntitlement.php | 27 ++++- lib/Entitlements/Feature.php | 64 +++++++++++- lib/EphemeralKey.php | 18 +++- lib/Event.php | 34 ++++++- lib/ExchangeRate.php | 29 +++++- lib/File.php | 33 +++++- lib/FileLink.php | 64 +++++++++++- lib/FinancialConnections/Account.php | 28 +++++- lib/FinancialConnections/Session.php | 37 ++++++- lib/FinancialConnections/Transaction.php | 29 +++++- lib/Forwarding/Request.php | 45 ++++++++- lib/GiftCards/Card.php | 64 +++++++++++- lib/GiftCards/Transaction.php | 64 +++++++++++- lib/Identity/VerificationReport.php | 29 +++++- lib/Identity/VerificationSession.php | 81 ++++++++++++++- lib/Invoice.php | 96 +++++++++++++++++- lib/InvoiceItem.php | 88 +++++++++++++++- lib/InvoiceLineItem.php | 23 +++++ lib/Issuing/Authorization.php | 50 +++++++++- lib/Issuing/Card.php | 67 ++++++++++++- lib/Issuing/Cardholder.php | 68 ++++++++++++- lib/Issuing/CreditUnderwritingRecord.php | 31 +++++- lib/Issuing/Dispute.php | 73 +++++++++++++- lib/Issuing/PersonalizationDesign.php | 66 +++++++++++- lib/Issuing/PhysicalBundle.php | 30 +++++- lib/Issuing/Token.php | 47 ++++++++- lib/Issuing/Transaction.php | 50 +++++++++- lib/Mandate.php | 17 +++- lib/Margin.php | 70 ++++++++++++- lib/Order.php | 68 ++++++++++++- lib/PaymentIntent.php | 87 +++++++++++++++- lib/PaymentLink.php | 64 +++++++++++- lib/PaymentMethod.php | 79 ++++++++++++++- lib/PaymentMethodConfiguration.php | 64 +++++++++++- lib/PaymentMethodDomain.php | 64 +++++++++++- lib/Payout.php | 80 ++++++++++++++- lib/Person.php | 23 +++++ lib/Plan.php | 86 +++++++++++++++- lib/Price.php | 68 ++++++++++++- lib/Product.php | 87 +++++++++++++++- lib/PromotionCode.php | 69 ++++++++++++- lib/Quote.php | 67 ++++++++++++- lib/QuotePhase.php | 29 +++++- lib/Radar/EarlyFraudWarning.php | 33 +++++- lib/Radar/ValueList.php | 88 +++++++++++++++- lib/Radar/ValueListItem.php | 66 +++++++++++- lib/Refund.php | 81 ++++++++++++++- lib/Reporting/ReportRun.php | 46 ++++++++- lib/Reporting/ReportType.php | 28 +++++- lib/Review.php | 31 +++++- lib/SetupAttempt.php | 11 +- lib/SetupIntent.php | 75 +++++++++++++- lib/ShippingRate.php | 64 +++++++++++- lib/Sigma/ScheduledQueryRun.php | 27 ++++- lib/Source.php | 60 ++++++++++- lib/Subscription.php | 122 ++++++++++++++++++++++- lib/SubscriptionItem.php | 83 ++++++++++++++- lib/SubscriptionSchedule.php | 67 ++++++++++++- lib/Tax/Calculation.php | 17 +++- lib/Tax/Form.php | 32 +++++- lib/Tax/Registration.php | 67 ++++++++++++- lib/Tax/Settings.php | 39 +++++++- lib/Tax/Transaction.php | 17 +++- lib/TaxCode.php | 29 +++++- lib/TaxId.php | 64 +++++++++++- lib/TaxRate.php | 65 +++++++++++- lib/Terminal/Configuration.php | 81 ++++++++++++++- lib/Terminal/ConnectionToken.php | 19 +++- lib/Terminal/Location.php | 84 +++++++++++++++- lib/Terminal/Reader.php | 82 ++++++++++++++- lib/TestHelpers/TestClock.php | 64 +++++++++++- lib/Token.php | 40 +++++++- lib/Topup.php | 67 ++++++++++++- lib/Transfer.php | 73 +++++++++++++- lib/Treasury/CreditReversal.php | 49 ++++++++- lib/Treasury/DebitReversal.php | 47 ++++++++- lib/Treasury/FinancialAccount.php | 65 +++++++++++- lib/Treasury/InboundTransfer.php | 47 ++++++++- lib/Treasury/OutboundPayment.php | 49 ++++++++- lib/Treasury/OutboundTransfer.php | 49 ++++++++- lib/Treasury/ReceivedCredit.php | 30 +++++- lib/Treasury/ReceivedDebit.php | 30 +++++- lib/Treasury/Transaction.php | 29 +++++- lib/Treasury/TransactionEntry.php | 29 +++++- lib/WebhookEndpoint.php | 92 ++++++++++++++++- 118 files changed, 5638 insertions(+), 324 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 09176b50fa..6661b2fdb8 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1048 \ No newline at end of file +v1051 \ No newline at end of file diff --git a/lib/Account.php b/lib/Account.php index 9d1a0f295c..5ab438954b 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -46,9 +46,6 @@ class Account extends ApiResource { const OBJECT_NAME = 'account'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; use ApiOperations\Update; @@ -62,6 +59,108 @@ class Account extends ApiResource const TYPE_NONE = 'none'; const TYPE_STANDARD = 'standard'; + /** + * With Connect, you can create Stripe accounts for + * your users. To do this, you’ll first need to register your + * platform. + * + * If you’ve already collected information for your connected accounts, you can prefill that information + * when creating the account. Connect Onboarding won’t ask for the prefilled + * information during account onboarding. You can prefill any information on the + * account. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * With Connect, you can delete accounts you manage. + * + * Test-mode accounts can be deleted at any time. + * + * Live-mode accounts where Stripe is responsible for negative account balances + * cannot be deleted, which includes Standard accounts. Live-mode accounts where + * your platform is liable for negative account balances, which includes Custom and + * Express accounts, can be deleted when all balances are zero. + * + * If you want to delete your own account, use the account information tab in + * your account settings instead. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of accounts connected to your platform via Connect. If you’re not a platform, the list is empty. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/accounts', \Stripe\Collection::class, $params, $opts); + } + + /** + * Updates a connected account by setting the + * values of the parameters passed. Any parameters not provided are left unchanged. + * + * For accounts where controller.requirement_collection + * is application, which includes Custom accounts, you can update any + * information on the account. + * + * For accounts where controller.requirement_collection + * is stripe, which includes Standard and Express accounts, you can + * update all information until you create an Account + * Link or Account Session to start Connect + * onboarding, after which some properties can no longer be updated. + * + * To update your own account, use the Dashboard. Refer to our + * Connect documentation to learn + * more about updating accounts. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + use ApiOperations\Retrieve { retrieve as protected _retrieve; } diff --git a/lib/AccountLink.php b/lib/AccountLink.php index 2671cbe2aa..19604fe847 100644 --- a/lib/AccountLink.php +++ b/lib/AccountLink.php @@ -19,5 +19,22 @@ class AccountLink extends ApiResource { const OBJECT_NAME = 'account_link'; - use ApiOperations\Create; + /** + * Creates an AccountLink object that includes a single-use Stripe URL that the + * platform can redirect their user to in order to take them through the Connect + * Onboarding flow. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/AccountNotice.php b/lib/AccountNotice.php index dfbf608555..be009c2758 100644 --- a/lib/AccountNotice.php +++ b/lib/AccountNotice.php @@ -24,8 +24,6 @@ class AccountNotice extends ApiResource { const OBJECT_NAME = 'account_notice'; - use ApiOperations\All; - use ApiOperations\Retrieve; use ApiOperations\Update; const REASON_ISSUING_ACCOUNT_CLOSED_FOR_INACTIVITY = 'issuing.account_closed_for_inactivity'; @@ -38,4 +36,50 @@ class AccountNotice extends ApiResource const REASON_ISSUING_DISPUTE_LOST = 'issuing.dispute_lost'; const REASON_ISSUING_DISPUTE_SUBMITTED = 'issuing.dispute_submitted'; const REASON_ISSUING_DISPUTE_WON = 'issuing.dispute_won'; + + /** + * Retrieves a list of AccountNotice objects. The objects are sorted + * in descending order by creation date, with the most-recently-created object + * appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/account_notices', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an AccountNotice object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an AccountNotice object. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/AccountSession.php b/lib/AccountSession.php index a5c1fb2ef4..5b575119e2 100644 --- a/lib/AccountSession.php +++ b/lib/AccountSession.php @@ -24,5 +24,21 @@ class AccountSession extends ApiResource { const OBJECT_NAME = 'account_session'; - use ApiOperations\Create; + /** + * Creates a AccountSession object that includes a single-use token that the + * platform can use on their front-end to grant client-side API access. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/ApplePayDomain.php b/lib/ApplePayDomain.php index 5f9489d47d..e22589e3af 100644 --- a/lib/ApplePayDomain.php +++ b/lib/ApplePayDomain.php @@ -15,10 +15,64 @@ class ApplePayDomain extends ApiResource { const OBJECT_NAME = 'apple_pay_domain'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; + /** + * Create an apple pay domain. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Delete an apple pay domain. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * List apple pay domains. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/apple_pay/domains', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve an apple pay domain. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } /** * @return string The class URL for this resource. It needs to be special diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index 468bcfd705..f031a7bbe7 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -25,9 +25,35 @@ class ApplicationFee extends ApiResource { const OBJECT_NAME = 'application_fee'; - use ApiOperations\All; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; + + /** + * Returns a list of application fees you’ve previously collected. The application + * fees are returned in sorted order, with the most recent fees appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/application_fees', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an application fee that your account has collected. The + * same information is returned when refunding the application fee. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } const PATH_REFUNDS = '/refunds'; diff --git a/lib/Apps/Secret.php b/lib/Apps/Secret.php index d5577897c8..1faa9c9b7d 100644 --- a/lib/Apps/Secret.php +++ b/lib/Apps/Secret.php @@ -29,8 +29,33 @@ class Secret extends \Stripe\ApiResource { const OBJECT_NAME = 'apps.secret'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; + /** + * Create or replace a secret in the secret store. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * List all secrets stored on the given scope. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/apps/secrets', \Stripe\Collection::class, $params, $opts); + } /** * @param null|array $params diff --git a/lib/Balance.php b/lib/Balance.php index d813cd8086..947c7829dd 100644 --- a/lib/Balance.php +++ b/lib/Balance.php @@ -29,5 +29,20 @@ class Balance extends SingletonApiResource { const OBJECT_NAME = 'balance'; - use ApiOperations\SingletonRetrieve; + /** + * Retrieves the current account balance, based on the authentication that was used + * to make the request. For a sample request, see Accounting + * for negative balances. + * + * @param null|mixed $opts + */ + public static function retrieve($opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static(null, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/BalanceTransaction.php b/lib/BalanceTransaction.php index 9dcba0f084..51551424fa 100644 --- a/lib/BalanceTransaction.php +++ b/lib/BalanceTransaction.php @@ -30,9 +30,6 @@ class BalanceTransaction extends ApiResource { const OBJECT_NAME = 'balance_transaction'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const TYPE_ADJUSTMENT = 'adjustment'; const TYPE_ADVANCE = 'advance'; const TYPE_ADVANCE_FUNDING = 'advance_funding'; @@ -73,4 +70,38 @@ class BalanceTransaction extends ApiResource const TYPE_TRANSFER_CANCEL = 'transfer_cancel'; const TYPE_TRANSFER_FAILURE = 'transfer_failure'; const TYPE_TRANSFER_REFUND = 'transfer_refund'; + + /** + * Returns a list of transactions that have contributed to the Stripe account + * balance (e.g., charges, transfers, and so forth). The transactions are returned + * in sorted order, with the most recent transactions appearing first. + * + * Note that this endpoint was previously called “Balance history” and used the + * path /v1/balance/history. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/balance_transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the balance transaction with the given ID. + * + * Note that this endpoint previously used the path + * /v1/balance/history/:id. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/BankAccount.php b/lib/BankAccount.php index 1d1adff892..02b7b9a484 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -38,8 +38,21 @@ class BankAccount extends ApiResource { const OBJECT_NAME = 'bank_account'; - use ApiOperations\Delete; - use ApiOperations\Update; + /** + * Delete a specified external account for a given account. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } /** * Possible string representations of the bank verification status. @@ -112,6 +125,29 @@ public static function update($_id, $_params = null, $_options = null) throw new Exception\BadMethodCallException($msg); } + /** + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return static the saved resource + * + * @deprecated The `save` method is deprecated and will be removed in a + * future major version of the library. Use the static method `update` + * on the resource instead. + */ + public function save($opts = null) + { + $params = $this->serializeParameters(); + if (\count($params) > 0) { + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Billing/Meter.php b/lib/Billing/Meter.php index 88c67a2c82..e2703007b8 100644 --- a/lib/Billing/Meter.php +++ b/lib/Billing/Meter.php @@ -25,10 +25,7 @@ class Meter extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; use \Stripe\ApiOperations\NestedResource; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const EVENT_TIME_WINDOW_DAY = 'day'; @@ -37,6 +34,67 @@ class Meter extends \Stripe\ApiResource const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; + /** + * Creates a billing meter. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieve a list of billing meters. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/billing/meters', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a billing meter given an ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a billing meter. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Billing/MeterEvent.php b/lib/Billing/MeterEvent.php index 2d9f3f4daa..8606c6bea0 100644 --- a/lib/Billing/MeterEvent.php +++ b/lib/Billing/MeterEvent.php @@ -20,5 +20,20 @@ class MeterEvent extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter_event'; - use \Stripe\ApiOperations\Create; + /** + * Creates a billing meter event. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Billing/MeterEventAdjustment.php b/lib/Billing/MeterEventAdjustment.php index f603887fe4..2920825e98 100644 --- a/lib/Billing/MeterEventAdjustment.php +++ b/lib/Billing/MeterEventAdjustment.php @@ -18,8 +18,23 @@ class MeterEventAdjustment extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter_event_adjustment'; - use \Stripe\ApiOperations\Create; - const STATUS_COMPLETE = 'complete'; const STATUS_PENDING = 'pending'; + + /** + * Creates a billing meter event adjustment. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/BillingPortal/Configuration.php b/lib/BillingPortal/Configuration.php index bc730eb9bc..78e6739a3f 100644 --- a/lib/BillingPortal/Configuration.php +++ b/lib/BillingPortal/Configuration.php @@ -25,8 +25,69 @@ 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; + + /** + * Creates a configuration that describes the functionality and behavior of a + * PortalSession. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of configurations that describe the functionality of the customer + * portal. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/billing_portal/configurations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a configuration that describes the functionality of the customer + * portal. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a configuration that describes the functionality of the customer portal. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/BillingPortal/Session.php b/lib/BillingPortal/Session.php index 1ca3fb8f02..bb8c77fdbc 100644 --- a/lib/BillingPortal/Session.php +++ b/lib/BillingPortal/Session.php @@ -36,5 +36,20 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'billing_portal.session'; - use \Stripe\ApiOperations\Create; + /** + * Creates a session of the customer portal. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Capability.php b/lib/Capability.php index 7f03c98e57..23bdba470e 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -83,4 +83,27 @@ public static function update($_id, $_params = null, $_options = null) throw new Exception\BadMethodCallException($msg); } + + /** + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return static the saved resource + * + * @deprecated The `save` method is deprecated and will be removed in a + * future major version of the library. Use the static method `update` + * on the resource instead. + */ + public function save($opts = null) + { + $params = $this->serializeParameters(); + if (\count($params) > 0) { + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Capital/FinancingOffer.php b/lib/Capital/FinancingOffer.php index c6dfa00839..10ca8da882 100644 --- a/lib/Capital/FinancingOffer.php +++ b/lib/Capital/FinancingOffer.php @@ -29,9 +29,6 @@ class FinancingOffer extends \Stripe\ApiResource { const OBJECT_NAME = 'capital.financing_offer'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FINANCING_TYPE_CASH_ADVANCE = 'cash_advance'; const FINANCING_TYPE_FLEX_LOAN = 'flex_loan'; @@ -52,6 +49,33 @@ class FinancingOffer extends \Stripe\ApiResource const TYPE_CASH_ADVANCE = 'cash_advance'; const TYPE_FLEX_LOAN = 'flex_loan'; + /** + * Retrieves the financing offers available for Connected accounts that belong to + * your platform. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/capital/financing_offers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Get the details of the financing offer. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Capital/FinancingSummary.php b/lib/Capital/FinancingSummary.php index b49b175631..02fa02ada9 100644 --- a/lib/Capital/FinancingSummary.php +++ b/lib/Capital/FinancingSummary.php @@ -17,9 +17,22 @@ class FinancingSummary extends \Stripe\SingletonApiResource { const OBJECT_NAME = 'capital.financing_summary'; - use \Stripe\ApiOperations\SingletonRetrieve; - const STATUS_ACCEPTED = 'accepted'; const STATUS_DELIVERED = 'delivered'; const STATUS_NONE = 'none'; + + /** + * Retrieve the financing state for the account that was authenticated in the + * request. + * + * @param null|mixed $opts + */ + public static function retrieve($opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static(null, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Capital/FinancingTransaction.php b/lib/Capital/FinancingTransaction.php index a9da7bd210..d1ab5b6607 100644 --- a/lib/Capital/FinancingTransaction.php +++ b/lib/Capital/FinancingTransaction.php @@ -22,10 +22,34 @@ class FinancingTransaction extends \Stripe\ApiResource { const OBJECT_NAME = 'capital.financing_transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const TYPE_PAYMENT = 'payment'; const TYPE_PAYOUT = 'payout'; const TYPE_REVERSAL = 'reversal'; + + /** + * Returns a list of financing transactions. The transactions are returned in + * sorted order, with the most recent transactions appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/capital/financing_transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a financing transaction for a financing offer. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Card.php b/lib/Card.php index 47721b37a6..9670da4240 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -45,8 +45,21 @@ class Card extends ApiResource { const OBJECT_NAME = 'card'; - use ApiOperations\Delete; - use ApiOperations\Update; + /** + * Delete a specified external account for a given account. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } /** * Possible string representations of the CVC check status. @@ -135,4 +148,27 @@ public static function update($_id, $_params = null, $_options = null) throw new Exception\BadMethodCallException($msg); } + + /** + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return static the saved resource + * + * @deprecated The `save` method is deprecated and will be removed in a + * future major version of the library. Use the static method `update` + * on the resource instead. + */ + public function save($opts = null) + { + $params = $this->serializeParameters(); + if (\count($params) > 0) { + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Charge.php b/lib/Charge.php index 52a4c9a942..792f7af4ae 100644 --- a/lib/Charge.php +++ b/lib/Charge.php @@ -63,10 +63,7 @@ class Charge extends ApiResource { const OBJECT_NAME = 'charge'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -74,6 +71,75 @@ class Charge extends ApiResource const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * This method is no longer recommended—use the Payment Intents API to initiate a new + * payment instead. Confirmation of the PaymentIntent creates the + * Charge object used to request payment. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of charges you’ve previously created. The charges are returned in + * sorted order, with the most recent charges appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/charges', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a charge that has previously been created. Supply the + * unique charge ID that was returned from your previous request, and Stripe will + * return the corresponding charge information. The same information is returned + * when creating or refunding the charge. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified charge by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * Possible string representations of decline codes. * These strings are applicable to the decline_code property of the \Stripe\Exception\CardException exception. diff --git a/lib/Checkout/Session.php b/lib/Checkout/Session.php index 539cadd4e5..1030864016 100644 --- a/lib/Checkout/Session.php +++ b/lib/Checkout/Session.php @@ -80,10 +80,6 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'checkout.session'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const BILLING_ADDRESS_COLLECTION_AUTO = 'auto'; const BILLING_ADDRESS_COLLECTION_REQUIRED = 'required'; @@ -117,6 +113,49 @@ class Session extends \Stripe\ApiResource const UI_MODE_EMBEDDED = 'embedded'; const UI_MODE_HOSTED = 'hosted'; + /** + * Creates a Session object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of Checkout Sessions. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/checkout/sessions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Session object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Climate/Order.php b/lib/Climate/Order.php index 72763a9f0f..b5d3d1dac9 100644 --- a/lib/Climate/Order.php +++ b/lib/Climate/Order.php @@ -35,9 +35,6 @@ class Order extends \Stripe\ApiResource { const OBJECT_NAME = 'climate.order'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const CANCELLATION_REASON_EXPIRED = 'expired'; @@ -50,6 +47,70 @@ class Order extends \Stripe\ApiResource const STATUS_DELIVERED = 'delivered'; const STATUS_OPEN = 'open'; + /** + * Creates a Climate order object for a given Climate product. The order will be + * processed immediately after creation and payment will be deducted your Stripe + * balance. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Lists all Climate order objects. The orders are returned sorted by creation + * date, with the most recently created orders appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/climate/orders', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Climate order object with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified order by setting the values of the parameters passed. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Climate/Product.php b/lib/Climate/Product.php index 2c33a294c4..987ae51df2 100644 --- a/lib/Climate/Product.php +++ b/lib/Climate/Product.php @@ -22,6 +22,29 @@ class Product extends \Stripe\ApiResource { const OBJECT_NAME = 'climate.product'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Lists all available Climate product objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/climate/products', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Climate product with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Climate/Supplier.php b/lib/Climate/Supplier.php index b329438682..a38cfeb88d 100644 --- a/lib/Climate/Supplier.php +++ b/lib/Climate/Supplier.php @@ -19,10 +19,33 @@ class Supplier extends \Stripe\ApiResource { const OBJECT_NAME = 'climate.supplier'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const REMOVAL_PATHWAY_BIOMASS_CARBON_REMOVAL_AND_STORAGE = 'biomass_carbon_removal_and_storage'; const REMOVAL_PATHWAY_DIRECT_AIR_CAPTURE = 'direct_air_capture'; const REMOVAL_PATHWAY_ENHANCED_WEATHERING = 'enhanced_weathering'; + + /** + * Lists all available Climate supplier objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/climate/suppliers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Climate supplier object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/ConfirmationToken.php b/lib/ConfirmationToken.php index 8fbd8eb167..1c733ec5b4 100644 --- a/lib/ConfirmationToken.php +++ b/lib/ConfirmationToken.php @@ -32,8 +32,21 @@ class ConfirmationToken extends ApiResource { const OBJECT_NAME = 'confirmation_token'; - use ApiOperations\Retrieve; - const SETUP_FUTURE_USAGE_OFF_SESSION = 'off_session'; const SETUP_FUTURE_USAGE_ON_SESSION = 'on_session'; + + /** + * Retrieves an existing ConfirmationToken object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/CountrySpec.php b/lib/CountrySpec.php index 260e54892c..be1ae660c9 100644 --- a/lib/CountrySpec.php +++ b/lib/CountrySpec.php @@ -25,6 +25,29 @@ class CountrySpec extends ApiResource { const OBJECT_NAME = 'country_spec'; - use ApiOperations\All; - use ApiOperations\Retrieve; + /** + * Lists all Country Spec objects available in the API. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/country_specs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns a Country Spec for a given Country code. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Coupon.php b/lib/Coupon.php index 720b33a09e..654598e841 100644 --- a/lib/Coupon.php +++ b/lib/Coupon.php @@ -31,14 +31,105 @@ class Coupon extends ApiResource { const OBJECT_NAME = 'coupon'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; const DURATION_FOREVER = 'forever'; const DURATION_ONCE = 'once'; const DURATION_REPEATING = 'repeating'; const DURATION_VARIABLE = 'variable'; + + /** + * You can create coupons easily via the coupon management page of the + * Stripe dashboard. Coupon creation is also accessible via the API if you need to + * create coupons on the fly. + * + * A coupon has either a percent_off or an amount_off and + * currency. If you set an amount_off, that amount will + * be subtracted from any invoice’s subtotal. For example, an invoice with a + * subtotal of 100 will have a final total of + * 0 if a coupon with an amount_off of + * 200 is applied to it and an invoice with a subtotal of + * 300 will have a final total of 100 if + * a coupon with an amount_off of 200 is applied to + * it. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * You can delete coupons via the coupon management page of the + * Stripe dashboard. However, deleting a coupon does not affect any customers who + * have already applied the coupon; it means that new customers can’t redeem the + * coupon. You can also delete coupons via the API. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your coupons. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/coupons', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the coupon with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the metadata of a coupon. Other coupon details (currency, duration, + * amount_off) are, by design, not editable. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/CreditNote.php b/lib/CreditNote.php index 9ab135a3db..5bf8cf33cb 100644 --- a/lib/CreditNote.php +++ b/lib/CreditNote.php @@ -47,10 +47,7 @@ class CreditNote extends ApiResource { const OBJECT_NAME = 'credit_note'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; const REASON_DUPLICATE = 'duplicate'; @@ -64,6 +61,86 @@ class CreditNote extends ApiResource const TYPE_POST_PAYMENT = 'post_payment'; const TYPE_PRE_PAYMENT = 'pre_payment'; + /** + * Issue a credit note to adjust the amount of a finalized invoice. For a + * status=open invoice, a credit note reduces its + * amount_due. For a status=paid invoice, a credit note + * does not affect its amount_due. Instead, it can result in any + * combination of the following:. + * + * + * + * For post-payment credit notes the sum of the refund, credit and outside of + * Stripe amounts must equal the credit note total. + * + * You may issue multiple credit notes for an invoice. Each credit note will + * increment the invoice’s pre_payment_credit_notes_amount or + * post_payment_credit_notes_amount depending on its + * status at the time of credit note creation. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of credit notes. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/credit_notes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the credit note object with the given identifier. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing credit note. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Customer.php b/lib/Customer.php index f4a5c9f83f..9291b9d1b3 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -42,11 +42,7 @@ class Customer extends ApiResource { const OBJECT_NAME = 'customer'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -54,6 +50,97 @@ class Customer extends ApiResource const TAX_EXEMPT_NONE = 'none'; const TAX_EXEMPT_REVERSE = 'reverse'; + /** + * Creates a new customer object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Permanently deletes a customer. It cannot be undone. Also immediately cancels + * any active subscriptions on the customer. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your customers. The customers are returned sorted by creation + * date, with the most recent customers appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/customers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Customer object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified customer by setting the values of the parameters passed. + * Any parameters not provided will be left unchanged. For example, if you pass the + * source parameter, that becomes the customer’s active source + * (e.g., a card) to be used for all charges in the future. When you update a + * customer to a new valid card source by passing the source + * parameter: for each of the customer’s current subscriptions, if the subscription + * bills automatically and is in the past_due state, then the latest + * open invoice for the subscription with automatic collection enabled will be + * retried. This retry will not count as an automatic retry, and will not affect + * the next regularly scheduled payment for the invoice. Changing the + * default_source for a customer will not trigger this behavior. + * + * This request accepts mostly the same arguments as the customer creation call. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + public static function getSavedNestedResources() { static $savedNestedResources = null; diff --git a/lib/CustomerSession.php b/lib/CustomerSession.php index 3d0038989c..f36dcfa1c8 100644 --- a/lib/CustomerSession.php +++ b/lib/CustomerSession.php @@ -20,5 +20,22 @@ class CustomerSession extends ApiResource { const OBJECT_NAME = 'customer_session'; - use ApiOperations\Create; + /** + * Creates a customer session object that includes a single-use client secret that + * you can use on your front-end to grant client-side API access for certain + * customer resources. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Dispute.php b/lib/Dispute.php index 7f1eb7fae0..0db22eb55b 100644 --- a/lib/Dispute.php +++ b/lib/Dispute.php @@ -34,8 +34,6 @@ class Dispute extends ApiResource { const OBJECT_NAME = 'dispute'; - use ApiOperations\All; - use ApiOperations\Retrieve; use ApiOperations\Update; const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process'; @@ -61,6 +59,58 @@ class Dispute extends ApiResource const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review'; const STATUS_WON = 'won'; + /** + * Returns a list of your disputes. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/disputes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the dispute with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * When you get a dispute, contacting your customer is always the best first step. + * If that doesn’t work, you can submit evidence to help us resolve the dispute in + * your favor. You can do this in your dashboard, but if you prefer, + * you can use the API to submit evidence programmatically. + * + * Depending on your dispute type, different evidence fields will give you a better + * chance of winning your dispute. To figure out which evidence fields to provide, + * see our guide to dispute types. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Entitlements/ActiveEntitlement.php b/lib/Entitlements/ActiveEntitlement.php index 6ada49d222..0139672370 100644 --- a/lib/Entitlements/ActiveEntitlement.php +++ b/lib/Entitlements/ActiveEntitlement.php @@ -17,6 +17,29 @@ class ActiveEntitlement extends \Stripe\ApiResource { const OBJECT_NAME = 'entitlements.active_entitlement'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Retrieve a list of active entitlements for a customer. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/entitlements/active_entitlements', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve an active entitlement. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Entitlements/Feature.php b/lib/Entitlements/Feature.php index f7e7aa92bb..64ffb73da8 100644 --- a/lib/Entitlements/Feature.php +++ b/lib/Entitlements/Feature.php @@ -20,8 +20,66 @@ class Feature extends \Stripe\ApiResource { const OBJECT_NAME = 'entitlements.feature'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a feature. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieve a list of features. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/entitlements/features', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a feature. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update a feature’s metadata or permanently deactivate it. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/EphemeralKey.php b/lib/EphemeralKey.php index 45055e8ca3..4f2d43f22f 100644 --- a/lib/EphemeralKey.php +++ b/lib/EphemeralKey.php @@ -16,12 +16,26 @@ class EphemeralKey extends ApiResource { const OBJECT_NAME = 'ephemeral_key'; + /** + * Invalidates a short-lived API key for a given resource. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + use ApiOperations\Create { create as protected _create; } - use ApiOperations\Delete; - /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Event.php b/lib/Event.php index 88c977c3bb..e82dae194e 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -55,9 +55,6 @@ class Event extends ApiResource { const OBJECT_NAME = 'event'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized'; const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized'; const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created'; @@ -575,4 +572,35 @@ class Event extends ApiResource const TYPE_TREASURY_RECEIVED_CREDIT_FAILED = 'treasury.received_credit.failed'; const TYPE_TREASURY_RECEIVED_CREDIT_SUCCEEDED = 'treasury.received_credit.succeeded'; const TYPE_TREASURY_RECEIVED_DEBIT_CREATED = 'treasury.received_debit.created'; + + /** + * List events, going back up to 30 days. Each event data is rendered according to + * Stripe API version at its creation time, specified in event object + * api_version attribute (not according to your current Stripe API + * version or Stripe-Version header). + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/events', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an event. Supply the unique identifier of the event, + * which you might have received in a webhook. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/ExchangeRate.php b/lib/ExchangeRate.php index d8c621f288..babed598d6 100644 --- a/lib/ExchangeRate.php +++ b/lib/ExchangeRate.php @@ -40,6 +40,31 @@ class ExchangeRate extends ApiResource { const OBJECT_NAME = 'exchange_rate'; - use ApiOperations\All; - use ApiOperations\Retrieve; + /** + * Returns a list of objects that contain the rates at which foreign currencies are + * converted to one another. Only shows the currencies for which Stripe supports. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/exchange_rates', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the exchange rates from the given currency to every supported + * currency. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/File.php b/lib/File.php index b64c77a5c5..f39f75d713 100644 --- a/lib/File.php +++ b/lib/File.php @@ -29,9 +29,6 @@ class File extends ApiResource { const OBJECT_NAME = 'file'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const PURPOSE_ACCOUNT_REQUIREMENT = 'account_requirement'; const PURPOSE_ADDITIONAL_VERIFICATION = 'additional_verification'; const PURPOSE_BUSINESS_ICON = 'business_icon'; @@ -48,6 +45,36 @@ class File extends ApiResource const PURPOSE_TAX_DOCUMENT_USER_UPLOAD = 'tax_document_user_upload'; const PURPOSE_TERMINAL_READER_SPLASHSCREEN = 'terminal_reader_splashscreen'; + /** + * Returns a list of the files that your account has access to. Stripe sorts and + * returns the files by their creation dates, placing the most recently created + * files at the top. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/files', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing file object. After you supply a unique file + * ID, Stripe returns the corresponding file object. Learn how to access file contents. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + // This resource can have two different object names. In latter API // versions, only `file` is used, but since stripe-php may be used with // any API version, we need to support deserializing the older diff --git a/lib/FileLink.php b/lib/FileLink.php index cab855eb6c..431aebd2b1 100644 --- a/lib/FileLink.php +++ b/lib/FileLink.php @@ -23,8 +23,66 @@ class FileLink extends ApiResource { const OBJECT_NAME = 'file_link'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Creates a new file link object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of file links. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/file_links', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the file link with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing file link object. Expired links can no longer be updated. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/FinancialConnections/Account.php b/lib/FinancialConnections/Account.php index b06417e368..068d0abf48 100644 --- a/lib/FinancialConnections/Account.php +++ b/lib/FinancialConnections/Account.php @@ -32,9 +32,7 @@ class Account extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.account'; - use \Stripe\ApiOperations\All; use \Stripe\ApiOperations\NestedResource; - use \Stripe\ApiOperations\Retrieve; const CATEGORY_CASH = 'cash'; const CATEGORY_CREDIT = 'credit'; @@ -52,6 +50,32 @@ class Account extends \Stripe\ApiResource const SUBCATEGORY_OTHER = 'other'; const SUBCATEGORY_SAVINGS = 'savings'; + /** + * Returns a list of Financial Connections Account objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/financial_connections/accounts', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an Financial Connections Account. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/FinancialConnections/Session.php b/lib/FinancialConnections/Session.php index 91fa0033a2..e867d4ca4e 100644 --- a/lib/FinancialConnections/Session.php +++ b/lib/FinancialConnections/Session.php @@ -26,11 +26,42 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.session'; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELLED = 'cancelled'; const STATUS_FAILED = 'failed'; const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * To launch the Financial Connections authorization flow, create a + * Session. The session’s client_secret can be used to + * launch the flow using Stripe.js. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieves the details of a Financial Connections Session. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/FinancialConnections/Transaction.php b/lib/FinancialConnections/Transaction.php index be27ae58a4..8fe5855342 100644 --- a/lib/FinancialConnections/Transaction.php +++ b/lib/FinancialConnections/Transaction.php @@ -24,10 +24,33 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const STATUS_PENDING = 'pending'; const STATUS_POSTED = 'posted'; const STATUS_VOID = 'void'; + + /** + * Returns a list of Financial Connections Transaction objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/financial_connections/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Financial Connections Transaction. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Forwarding/Request.php b/lib/Forwarding/Request.php index 0af5eb74ee..a6178ff0e5 100644 --- a/lib/Forwarding/Request.php +++ b/lib/Forwarding/Request.php @@ -37,7 +37,46 @@ class Request extends \Stripe\ApiResource { const OBJECT_NAME = 'forwarding.request'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; + /** + * Creates a ForwardingRequest object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Lists all ForwardingRequest objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/forwarding/requests', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ForwardingRequest object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/GiftCards/Card.php b/lib/GiftCards/Card.php index 64e05ab992..6108c10900 100644 --- a/lib/GiftCards/Card.php +++ b/lib/GiftCards/Card.php @@ -24,11 +24,69 @@ class Card extends \Stripe\ApiResource { const OBJECT_NAME = 'gift_cards.card'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + /** + * Creates a new gift card object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * List gift cards for an account. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/gift_cards/cards', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a gift card by id. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update a gift card. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/GiftCards/Transaction.php b/lib/GiftCards/Transaction.php index 6a67cdf2be..71bad1b019 100644 --- a/lib/GiftCards/Transaction.php +++ b/lib/GiftCards/Transaction.php @@ -29,9 +29,6 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'gift_cards.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -39,6 +36,67 @@ class Transaction extends \Stripe\ApiResource const STATUS_HELD = 'held'; const STATUS_INVALID = 'invalid'; + /** + * Create a gift card transaction. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * List gift card transactions for a gift card. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/gift_cards/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the gift card transaction. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update a gift card transaction. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Identity/VerificationReport.php b/lib/Identity/VerificationReport.php index 27ae08dbee..fbcbbc9d66 100644 --- a/lib/Identity/VerificationReport.php +++ b/lib/Identity/VerificationReport.php @@ -36,10 +36,33 @@ class VerificationReport extends \Stripe\ApiResource { const OBJECT_NAME = 'identity.verification_report'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const TYPE_DOCUMENT = 'document'; const TYPE_ID_NUMBER = 'id_number'; const TYPE_VERIFICATION_FLOW = 'verification_flow'; + + /** + * List all verification reports. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/identity/verification_reports', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an existing VerificationReport. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Identity/VerificationSession.php b/lib/Identity/VerificationSession.php index 3760a24fcb..71ff5f0181 100644 --- a/lib/Identity/VerificationSession.php +++ b/lib/Identity/VerificationSession.php @@ -39,9 +39,6 @@ class VerificationSession extends \Stripe\ApiResource { const OBJECT_NAME = 'identity.verification_session'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -53,6 +50,84 @@ class VerificationSession extends \Stripe\ApiResource const TYPE_ID_NUMBER = 'id_number'; const TYPE_VERIFICATION_FLOW = 'verification_flow'; + /** + * Creates a VerificationSession object. + * + * After the VerificationSession is created, display a verification modal using the + * session client_secret or send your users to the session’s + * url. + * + * If your API key is in test mode, verification checks won’t actually process, + * though everything else will occur as if in live mode. + * + * Related guide: Verify your + * users’ identity documents + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of VerificationSessions. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/identity/verification_sessions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a VerificationSession that was previously created. + * + * When the session status is requires_input, you can use this method + * to retrieve a valid client_secret or url to allow + * re-submission. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a VerificationSession object. + * + * When the session status is requires_input, you can use this method + * to update the verification check and options. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Invoice.php b/lib/Invoice.php index 152622757a..15447881b3 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -129,11 +129,7 @@ class Invoice extends ApiResource { const OBJECT_NAME = 'invoice'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -160,6 +156,98 @@ class Invoice extends ApiResource const STATUS_UNCOLLECTIBLE = 'uncollectible'; const STATUS_VOID = 'void'; + /** + * This endpoint creates a draft invoice for a given customer. The invoice remains + * a draft until you finalize the invoice, which + * allows you to pay or send + * the invoice to your customers. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to + * delete invoices that are no longer in a draft state will fail; once an invoice + * has been finalized or if an invoice is for a subscription, it must be voided. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * You can list all invoices, or list the invoices for a specific customer. The + * invoices are returned sorted by creation date, with the most recently created + * invoices appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/invoices', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the invoice with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Draft invoices are fully editable. Once an invoice is finalized, monetary values, + * as well as collection_method, become uneditable. + * + * If you would like to stop the Stripe Billing engine from automatically + * finalizing, reattempting payments on, sending reminders for, or automatically reconciling + * invoices, pass auto_advance=false. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically'; const BILLING_SEND_INVOICE = 'send_invoice'; diff --git a/lib/InvoiceItem.php b/lib/InvoiceItem.php index a47d08e736..196106c3ed 100644 --- a/lib/InvoiceItem.php +++ b/lib/InvoiceItem.php @@ -46,9 +46,89 @@ class InvoiceItem extends ApiResource { const OBJECT_NAME = 'invoiceitem'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Creates an item to be added to a draft invoice (up to 250 items per invoice). If + * no invoice is specified, the item will be on the next invoice created for the + * customer specified. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes an invoice item, removing it from an invoice. Deleting invoice items is + * only possible when they’re not attached to invoices, or if it’s attached to a + * draft invoice. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your invoice items. Invoice items are returned sorted by + * creation date, with the most recently created invoice items appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/invoiceitems', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the invoice item with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the amount or description of an invoice item on an upcoming invoice. + * Updating an invoice item is only possible before the invoice it’s attached to is + * closed. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/InvoiceLineItem.php b/lib/InvoiceLineItem.php index 1ff5db5941..51a58efc44 100644 --- a/lib/InvoiceLineItem.php +++ b/lib/InvoiceLineItem.php @@ -38,4 +38,27 @@ class InvoiceLineItem extends ApiResource const OBJECT_NAME = 'line_item'; use ApiOperations\Update; + + /** + * Updates an invoice’s line item. Some fields, such as tax_amounts, + * only live on the invoice line item, so they can only be updated through this + * endpoint. Other fields, such as amount, live on both the invoice + * item and the invoice line item, so updates on this endpoint will propagate to + * the invoice item as well. Updating an invoice’s line item is only possible + * before the invoice is finalized. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Issuing/Authorization.php b/lib/Issuing/Authorization.php index 7fa73ffb32..db8cf71d22 100644 --- a/lib/Issuing/Authorization.php +++ b/lib/Issuing/Authorization.php @@ -41,8 +41,6 @@ class Authorization extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.authorization'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const AUTHORIZATION_METHOD_CHIP = 'chip'; @@ -55,6 +53,54 @@ class Authorization extends \Stripe\ApiResource const STATUS_PENDING = 'pending'; const STATUS_REVERSED = 'reversed'; + /** + * Returns a list of Issuing Authorization objects. The objects are + * sorted in descending order by creation date, with the most recently created + * object appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/authorizations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Authorization object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Authorization object by setting the + * values of the parameters passed. Any parameters not provided will be left + * unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Issuing/Card.php b/lib/Issuing/Card.php index d18a07539a..55fbb0c87c 100644 --- a/lib/Issuing/Card.php +++ b/lib/Issuing/Card.php @@ -36,9 +36,6 @@ class Card extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.card'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const CANCELLATION_REASON_DESIGN_REJECTED = 'design_rejected'; @@ -56,4 +53,68 @@ class Card extends \Stripe\ApiResource const TYPE_PHYSICAL = 'physical'; const TYPE_VIRTUAL = 'virtual'; + + /** + * Creates an Issuing Card object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of Issuing Card objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/cards', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Card object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Card object by setting the values of + * the parameters passed. Any parameters not provided will be left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Issuing/Cardholder.php b/lib/Issuing/Cardholder.php index b98e74d429..0cea7ad0d8 100644 --- a/lib/Issuing/Cardholder.php +++ b/lib/Issuing/Cardholder.php @@ -30,9 +30,6 @@ class Cardholder extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.cardholder'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_ACTIVE = 'active'; @@ -41,4 +38,69 @@ class Cardholder extends \Stripe\ApiResource const TYPE_COMPANY = 'company'; const TYPE_INDIVIDUAL = 'individual'; + + /** + * Creates a new Issuing Cardholder object that can be issued cards. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of Issuing Cardholder objects. The objects are + * sorted in descending order by creation date, with the most recently created + * object appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/cardholders', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Cardholder object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Cardholder object by setting the + * values of the parameters passed. Any parameters not provided will be left + * unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Issuing/CreditUnderwritingRecord.php b/lib/Issuing/CreditUnderwritingRecord.php index da121aa9c5..11f3dc5322 100644 --- a/lib/Issuing/CreditUnderwritingRecord.php +++ b/lib/Issuing/CreditUnderwritingRecord.php @@ -26,12 +26,37 @@ class CreditUnderwritingRecord extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.credit_underwriting_record'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const CREATED_FROM_APPLICATION = 'application'; const CREATED_FROM_PROACTIVE_REVIEW = 'proactive_review'; + /** + * Retrieves a list of CreditUnderwritingRecord objects. The objects + * are sorted in descending order by creation date, with the most-recently-created + * object appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/credit_underwriting_records', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a CreditUnderwritingRecord object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Issuing/Dispute.php b/lib/Issuing/Dispute.php index bc37efe274..afc464d8c8 100644 --- a/lib/Issuing/Dispute.php +++ b/lib/Issuing/Dispute.php @@ -27,9 +27,6 @@ class Dispute extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.dispute'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const LOSS_REASON_CARDHOLDER_AUTHENTICATION_ISSUER_LIABILITY = 'cardholder_authentication_issuer_liability'; @@ -59,6 +56,76 @@ class Dispute extends \Stripe\ApiResource const STATUS_UNSUBMITTED = 'unsubmitted'; const STATUS_WON = 'won'; + /** + * Creates an Issuing Dispute object. Individual pieces of evidence + * within the evidence object are optional at this point. Stripe only + * validates that required evidence is present during submission. Refer to Dispute + * reasons and evidence for more details about evidence requirements. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of Issuing Dispute objects. The objects are sorted + * in descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/disputes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Dispute object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Dispute object by setting the values + * of the parameters passed. Any parameters not provided will be left unchanged. + * Properties on the evidence object can be unset by passing in an + * empty string. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Issuing/PersonalizationDesign.php b/lib/Issuing/PersonalizationDesign.php index 74af892aa5..b49c4f84c8 100644 --- a/lib/Issuing/PersonalizationDesign.php +++ b/lib/Issuing/PersonalizationDesign.php @@ -25,13 +25,73 @@ class PersonalizationDesign extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.personalization_design'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; const STATUS_REJECTED = 'rejected'; const STATUS_REVIEW = 'review'; + + /** + * Creates a personalization design object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of personalization design objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/personalization_designs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a personalization design object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a card personalization object. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Issuing/PhysicalBundle.php b/lib/Issuing/PhysicalBundle.php index 3a978cba1c..d1fb0de72b 100644 --- a/lib/Issuing/PhysicalBundle.php +++ b/lib/Issuing/PhysicalBundle.php @@ -19,13 +19,37 @@ class PhysicalBundle extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.physical_bundle'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; const STATUS_REVIEW = 'review'; const TYPE_CUSTOM = 'custom'; const TYPE_STANDARD = 'standard'; + + /** + * Returns a list of physical bundle objects. The objects are sorted in descending + * order by creation date, with the most recently created object appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/physical_bundles', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a physical bundle object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Issuing/Token.php b/lib/Issuing/Token.php index d475cc5c78..a7aeefca24 100644 --- a/lib/Issuing/Token.php +++ b/lib/Issuing/Token.php @@ -24,8 +24,6 @@ class Token extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.token'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const NETWORK_MASTERCARD = 'mastercard'; @@ -39,4 +37,49 @@ class Token extends \Stripe\ApiResource const WALLET_PROVIDER_APPLE_PAY = 'apple_pay'; const WALLET_PROVIDER_GOOGLE_PAY = 'google_pay'; const WALLET_PROVIDER_SAMSUNG_PAY = 'samsung_pay'; + + /** + * Lists all Issuing Token objects for a given card. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/tokens', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Token object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Attempts to update the specified Issuing Token object to the status + * specified. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Issuing/Transaction.php b/lib/Issuing/Transaction.php index 50825c480e..c7f07c0c35 100644 --- a/lib/Issuing/Transaction.php +++ b/lib/Issuing/Transaction.php @@ -38,8 +38,6 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const TYPE_CAPTURE = 'capture'; @@ -48,4 +46,52 @@ class Transaction extends \Stripe\ApiResource const WALLET_APPLE_PAY = 'apple_pay'; const WALLET_GOOGLE_PAY = 'google_pay'; const WALLET_SAMSUNG_PAY = 'samsung_pay'; + + /** + * Returns a list of Issuing Transaction objects. The objects are + * sorted in descending order by creation date, with the most recently created + * object appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Transaction object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Transaction object by setting the + * values of the parameters passed. Any parameters not provided will be left + * unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Mandate.php b/lib/Mandate.php index 838aa47e96..fbd9658a53 100644 --- a/lib/Mandate.php +++ b/lib/Mandate.php @@ -23,12 +23,25 @@ class Mandate extends ApiResource { const OBJECT_NAME = 'mandate'; - use ApiOperations\Retrieve; - const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; const STATUS_PENDING = 'pending'; const TYPE_MULTI_USE = 'multi_use'; const TYPE_SINGLE_USE = 'single_use'; + + /** + * Retrieves a Mandate object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Margin.php b/lib/Margin.php index b3b57b86ad..27ad27326c 100644 --- a/lib/Margin.php +++ b/lib/Margin.php @@ -22,8 +22,72 @@ class Margin extends ApiResource { const OBJECT_NAME = 'margin'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Create a margin object to be used with invoices, invoice items, and invoice line + * items for a customer to represent a partner discount.A margin has a + * percent_off which is the percent that will be taken off the + * subtotal after all items and other discounts and promotions) of any invoices for + * a customer. Calculation of prorations do not include any partner margins applied + * on the original invoice item. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieve a list of your margins. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/billing/margins', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a margin object with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update the specified margin object. Certain fields of the margin object are not + * editable. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Order.php b/lib/Order.php index 12aa35596a..a55525eb3e 100644 --- a/lib/Order.php +++ b/lib/Order.php @@ -41,9 +41,6 @@ class Order extends ApiResource { const OBJECT_NAME = 'order'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -52,6 +49,71 @@ class Order extends ApiResource const STATUS_PROCESSING = 'processing'; const STATUS_SUBMITTED = 'submitted'; + /** + * Creates a new open order object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your orders. The orders are returned sorted by creation date, + * with the most recently created orders appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/orders', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing order. Supply the unique order ID from + * either an order creation request or the order list, and Stripe will return the + * corresponding order information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specific order by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/PaymentIntent.php b/lib/PaymentIntent.php index acb88b4b59..980f23ba1f 100644 --- a/lib/PaymentIntent.php +++ b/lib/PaymentIntent.php @@ -64,9 +64,6 @@ class PaymentIntent extends ApiResource { const OBJECT_NAME = 'payment_intent'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -99,6 +96,90 @@ class PaymentIntent extends ApiResource const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Creates a PaymentIntent object. + * + * After the PaymentIntent is created, attach a payment method and confirm to continue the payment. + * Learn more about the available payment + * flows with the Payment Intents API. + * + * When you use confirm=true during creation, it’s equivalent to + * creating and confirming the PaymentIntent in the same call. You can use any + * parameters available in the confirm + * API when you supply confirm=true. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of PaymentIntents. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_intents', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a PaymentIntent that has previously been created. + * + * You can retrieve a PaymentIntent client-side using a publishable key when the + * client_secret is in the query string. + * + * If you retrieve a PaymentIntent with a publishable key, it only returns a subset + * of properties. Refer to the payment intent + * object reference for more details. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates properties on a PaymentIntent object without confirming. + * + * Depending on which properties you update, you might need to confirm the + * PaymentIntent again. For example, updating the payment_method + * always requires you to confirm the PaymentIntent again. If you prefer to update + * and confirm at the same time, we recommend updating properties through the confirm API instead. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/PaymentLink.php b/lib/PaymentLink.php index 2c162773a8..005f16887b 100644 --- a/lib/PaymentLink.php +++ b/lib/PaymentLink.php @@ -49,9 +49,6 @@ class PaymentLink extends ApiResource { const OBJECT_NAME = 'payment_link'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const BILLING_ADDRESS_COLLECTION_AUTO = 'auto'; @@ -68,6 +65,67 @@ class PaymentLink extends ApiResource const SUBMIT_TYPE_DONATE = 'donate'; const SUBMIT_TYPE_PAY = 'pay'; + /** + * Creates a payment link. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your payment links. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_links', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a payment link. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a payment link. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param string $id * @param null|array $params diff --git a/lib/PaymentMethod.php b/lib/PaymentMethod.php index bd757e30e0..c69e573850 100644 --- a/lib/PaymentMethod.php +++ b/lib/PaymentMethod.php @@ -67,9 +67,6 @@ class PaymentMethod extends ApiResource { const OBJECT_NAME = 'payment_method'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const ALLOW_REDISPLAY_ALWAYS = 'always'; @@ -118,6 +115,82 @@ class PaymentMethod extends ApiResource const TYPE_WECHAT_PAY = 'wechat_pay'; const TYPE_ZIP = 'zip'; + /** + * Creates a PaymentMethod object. Read the Stripe.js + * reference to learn how to create PaymentMethods via Stripe.js. + * + * Instead of creating a PaymentMethod directly, we recommend using the PaymentIntents API to accept a + * payment immediately or the SetupIntent API to collect payment + * method details ahead of a future payment. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of PaymentMethods for Treasury flows. If you want to list the + * PaymentMethods attached to a Customer for payments, you should use the List a Customer’s + * PaymentMethods API instead. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_methods', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a + * payment method attached to a Customer, you should use Retrieve a Customer’s + * PaymentMethods. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a PaymentMethod object. A PaymentMethod must be attached a customer to + * be updated. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/PaymentMethodConfiguration.php b/lib/PaymentMethodConfiguration.php index 05add8cc39..472916e7e2 100644 --- a/lib/PaymentMethodConfiguration.php +++ b/lib/PaymentMethodConfiguration.php @@ -72,8 +72,66 @@ class PaymentMethodConfiguration extends ApiResource { const OBJECT_NAME = 'payment_method_configuration'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Creates a payment method configuration. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * List payment method configurations. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_method_configurations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve payment method configuration. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update payment method configuration. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/PaymentMethodDomain.php b/lib/PaymentMethodDomain.php index 15920b7c98..be206e1a7c 100644 --- a/lib/PaymentMethodDomain.php +++ b/lib/PaymentMethodDomain.php @@ -25,11 +25,69 @@ class PaymentMethodDomain extends ApiResource { const OBJECT_NAME = 'payment_method_domain'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + /** + * Creates a payment method domain. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Lists the details of existing payment method domains. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_method_domains', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing payment method domain. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing payment method domain. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Payout.php b/lib/Payout.php index 2404e1a339..7abc62dca1 100644 --- a/lib/Payout.php +++ b/lib/Payout.php @@ -44,9 +44,6 @@ class Payout extends ApiResource { const OBJECT_NAME = 'payout'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const METHOD_INSTANT = 'instant'; @@ -65,6 +62,83 @@ class Payout extends ApiResource const TYPE_BANK_ACCOUNT = 'bank_account'; const TYPE_CARD = 'card'; + /** + * To send funds to your own bank account, create a new payout object. Your Stripe balance must cover the payout amount. If it doesn’t, + * you receive an “Insufficient Funds” error. + * + * If your API key is in test mode, money won’t actually be sent, though every + * other action occurs as if you’re in live mode. + * + * If you create a manual payout on a Stripe account that uses multiple payment + * source types, you need to specify the source type balance that the payout draws + * from. The balance object details available and + * pending amounts by source type. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of existing payouts sent to third-party bank accounts or payouts + * that Stripe sent to you. The payouts return in sorted order, with the most + * recently created payouts appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payouts', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing payout. Supply the unique payout ID from + * either a payout creation request or the payout list. Stripe returns the + * corresponding payout information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified payout by setting the values of the parameters you pass. + * We don’t change parameters that you don’t provide. This request only accepts the + * metadata as arguments. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + const FAILURE_ACCOUNT_CLOSED = 'account_closed'; const FAILURE_ACCOUNT_FROZEN = 'account_frozen'; const FAILURE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted'; diff --git a/lib/Person.php b/lib/Person.php index 209efc1d21..c8491a595a 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -114,4 +114,27 @@ public static function update($_id, $_params = null, $_options = null) throw new Exception\BadMethodCallException($msg); } + + /** + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return static the saved resource + * + * @deprecated The `save` method is deprecated and will be removed in a + * future major version of the library. Use the static method `update` + * on the resource instead. + */ + public function save($opts = null) + { + $params = $this->serializeParameters(); + if (\count($params) > 0) { + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Plan.php b/lib/Plan.php index 348cfcbaa5..61dc703a02 100644 --- a/lib/Plan.php +++ b/lib/Plan.php @@ -40,10 +40,6 @@ class Plan extends ApiResource { const OBJECT_NAME = 'plan'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; const AGGREGATE_USAGE_LAST_DURING_PERIOD = 'last_during_period'; @@ -64,4 +60,86 @@ class Plan extends ApiResource const USAGE_TYPE_LICENSED = 'licensed'; const USAGE_TYPE_METERED = 'metered'; + + /** + * You can now model subscriptions more flexibly using the Prices + * API. It replaces the Plans API and is backwards compatible to simplify your + * migration. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deleting plans means new subscribers can’t be added. Existing subscribers aren’t + * affected. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your plans. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/plans', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the plan with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified plan by setting the values of the parameters passed. Any + * parameters not provided are left unchanged. By design, you cannot change a + * plan’s ID, amount, currency, or billing cycle. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Price.php b/lib/Price.php index 33c5e36bf2..46f21fcf69 100644 --- a/lib/Price.php +++ b/lib/Price.php @@ -39,9 +39,6 @@ class Price extends ApiResource { const OBJECT_NAME = 'price'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -58,6 +55,71 @@ class Price extends ApiResource const TYPE_ONE_TIME = 'one_time'; const TYPE_RECURRING = 'recurring'; + /** + * Creates a new price for an existing product. The price can be recurring or + * one-time. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your active prices, excluding inline prices. + * For the list of inactive prices, set active to false. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/prices', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the price with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified price by setting the values of the parameters passed. Any + * parameters not provided are left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Product.php b/lib/Product.php index e7f069023d..79b6b593ef 100644 --- a/lib/Product.php +++ b/lib/Product.php @@ -39,17 +39,96 @@ class Product extends ApiResource { const OBJECT_NAME = 'product'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; const TYPE_GOOD = 'good'; const TYPE_SERVICE = 'service'; + /** + * Creates a new product object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Delete a product. Deleting a product is only possible if it has no prices + * associated with it. Additionally, deleting a product with type=good + * is only possible if it has no SKUs associated with it. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your products. The products are returned sorted by creation + * date, with the most recently created products appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/products', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing product. Supply the unique product ID from + * either a product creation request or the product list, and Stripe will return + * the corresponding product information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specific product by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/PromotionCode.php b/lib/PromotionCode.php index 56d395944d..a6c8564d7c 100644 --- a/lib/PromotionCode.php +++ b/lib/PromotionCode.php @@ -26,8 +26,71 @@ class PromotionCode extends ApiResource { const OBJECT_NAME = 'promotion_code'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * A promotion code points to a coupon. You can optionally restrict the code to a + * specific customer, redemption limit, and expiration date. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your promotion codes. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/promotion_codes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the promotion code with the given ID. In order to retrieve a promotion + * code by the customer-facing code use list with the desired + * code. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified promotion code by setting the values of the parameters + * passed. Most fields are, by design, not editable. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Quote.php b/lib/Quote.php index 0df8e22865..3976f26b71 100644 --- a/lib/Quote.php +++ b/lib/Quote.php @@ -53,10 +53,7 @@ class Quote extends ApiResource { const OBJECT_NAME = 'quote'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically'; @@ -69,6 +66,70 @@ class Quote extends ApiResource const STATUS_OPEN = 'open'; const STATUS_STALE = 'stale'; + /** + * A quote models prices and services for a customer. Default options for + * header, description, footer, and + * expires_at can be set in the dashboard via the quote template. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your quotes. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/quotes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the quote with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * A quote models prices and services for a customer. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/QuotePhase.php b/lib/QuotePhase.php index 8176a6e9a7..1b679cba0d 100644 --- a/lib/QuotePhase.php +++ b/lib/QuotePhase.php @@ -29,9 +29,6 @@ class QuotePhase extends ApiResource { const OBJECT_NAME = 'quote_phase'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically'; const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice'; @@ -39,6 +36,32 @@ class QuotePhase extends ApiResource const PRORATION_BEHAVIOR_CREATE_PRORATIONS = 'create_prorations'; const PRORATION_BEHAVIOR_NONE = 'none'; + /** + * Returns a list of quote phases. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/quote_phases', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the quote phase with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param string $id * @param null|array $params diff --git a/lib/Radar/EarlyFraudWarning.php b/lib/Radar/EarlyFraudWarning.php index f728ee9e6b..0043453a20 100644 --- a/lib/Radar/EarlyFraudWarning.php +++ b/lib/Radar/EarlyFraudWarning.php @@ -23,9 +23,6 @@ class EarlyFraudWarning extends \Stripe\ApiResource { const OBJECT_NAME = 'radar.early_fraud_warning'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FRAUD_TYPE_CARD_NEVER_RECEIVED = 'card_never_received'; const FRAUD_TYPE_FRAUDULENT_CARD_APPLICATION = 'fraudulent_card_application'; const FRAUD_TYPE_MADE_WITH_COUNTERFEIT_CARD = 'made_with_counterfeit_card'; @@ -33,4 +30,34 @@ class EarlyFraudWarning extends \Stripe\ApiResource const FRAUD_TYPE_MADE_WITH_STOLEN_CARD = 'made_with_stolen_card'; const FRAUD_TYPE_MISC = 'misc'; const FRAUD_TYPE_UNAUTHORIZED_USE_OF_CARD = 'unauthorized_use_of_card'; + + /** + * Returns a list of early fraud warnings. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/radar/early_fraud_warnings', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an early fraud warning that has previously been + * created. + * + * Please refer to the early fraud + * warning object reference for more details. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Radar/ValueList.php b/lib/Radar/ValueList.php index f3adb80104..c8b84eb4eb 100644 --- a/lib/Radar/ValueList.php +++ b/lib/Radar/ValueList.php @@ -24,10 +24,6 @@ class ValueList extends \Stripe\ApiResource { const OBJECT_NAME = 'radar.value_list'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const ITEM_TYPE_CARD_BIN = 'card_bin'; @@ -40,4 +36,88 @@ class ValueList extends \Stripe\ApiResource const ITEM_TYPE_SEPA_DEBIT_FINGERPRINT = 'sepa_debit_fingerprint'; const ITEM_TYPE_STRING = 'string'; const ITEM_TYPE_US_BANK_ACCOUNT_FINGERPRINT = 'us_bank_account_fingerprint'; + + /** + * Creates a new ValueList object, which can then be referenced in + * rules. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes a ValueList object, also deleting any items contained + * within the value list. To be deleted, a value list must not be referenced in any + * rules. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of ValueList objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/radar/value_lists', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ValueList object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a ValueList object by setting the values of the parameters + * passed. Any parameters not provided will be left unchanged. Note that + * item_type is immutable. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Radar/ValueListItem.php b/lib/Radar/ValueListItem.php index f95018bddf..33f55b2df1 100644 --- a/lib/Radar/ValueListItem.php +++ b/lib/Radar/ValueListItem.php @@ -21,8 +21,66 @@ class ValueListItem extends \Stripe\ApiResource { const OBJECT_NAME = 'radar.value_list_item'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; + /** + * Creates a new ValueListItem object, which is added to the specified + * parent value list. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes a ValueListItem object, removing it from its parent value + * list. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of ValueListItem objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/radar/value_list_items', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ValueListItem object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Refund.php b/lib/Refund.php index 7ed0b37e18..ce3a3e710f 100644 --- a/lib/Refund.php +++ b/lib/Refund.php @@ -36,9 +36,6 @@ class Refund extends ApiResource { const OBJECT_NAME = 'refund'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const FAILURE_REASON_EXPIRED_OR_CANCELED_CARD = 'expired_or_canceled_card'; @@ -56,6 +53,84 @@ class Refund extends ApiResource const STATUS_REQUIRES_ACTION = 'requires_action'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * When you create a new refund, you must specify a Charge or a PaymentIntent + * object on which to create it. + * + * Creating a new refund will refund a charge that has previously been created but + * not yet refunded. Funds will be refunded to the credit or debit card that was + * originally charged. + * + * You can optionally refund only part of a charge. You can do so multiple times, + * until the entire charge has been refunded. + * + * Once entirely refunded, a charge can’t be refunded again. This method will raise + * an error when called on an already-refunded charge, or when trying to refund + * more money than is left on a charge. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of all refunds you created. We return the refunds in sorted + * order, with the most recent refunds appearing first The 10 most recent refunds + * are always available by default on the Charge object. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/refunds', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing refund. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the refund that you specify by setting the values of the passed + * parameters. Any parameters that you don’t provide remain unchanged. + * + * This request only accepts metadata as an argument. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Reporting/ReportRun.php b/lib/Reporting/ReportRun.php index c7b1766ba2..7eaf485c24 100644 --- a/lib/Reporting/ReportRun.php +++ b/lib/Reporting/ReportRun.php @@ -29,7 +29,47 @@ class ReportRun extends \Stripe\ApiResource { const OBJECT_NAME = 'reporting.report_run'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; + /** + * Creates a new object and begin running the report. (Certain report types require + * a live-mode API key.). + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of Report Runs, with the most recent appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/reporting/report_runs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing Report Run. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Reporting/ReportType.php b/lib/Reporting/ReportType.php index 1d98e1606b..41aceb76c2 100644 --- a/lib/Reporting/ReportType.php +++ b/lib/Reporting/ReportType.php @@ -28,6 +28,30 @@ class ReportType extends \Stripe\ApiResource { const OBJECT_NAME = 'reporting.report_type'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Returns a full list of Report Types. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/reporting/report_types', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Report Type. (Certain report types require a live-mode API key.). + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Review.php b/lib/Review.php index cb49431ab7..108ddc4391 100644 --- a/lib/Review.php +++ b/lib/Review.php @@ -29,9 +29,6 @@ class Review extends ApiResource { const OBJECT_NAME = 'review'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const CLOSED_REASON_APPROVED = 'approved'; const CLOSED_REASON_DISPUTED = 'disputed'; const CLOSED_REASON_REDACTED = 'redacted'; @@ -41,6 +38,34 @@ class Review extends ApiResource const OPENED_REASON_MANUAL = 'manual'; const OPENED_REASON_RULE = 'rule'; + /** + * Returns a list of Review objects that have open set to + * true. The objects are sorted in descending order by creation date, + * with the most recently created object appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/reviews', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Review object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * Possible string representations of the current, the opening or the closure reason of the review. * Not all of these enumeration apply to all of the ´reason´ fields. Please consult the Review object to diff --git a/lib/SetupAttempt.php b/lib/SetupAttempt.php index e755171dc4..9cb53353de 100644 --- a/lib/SetupAttempt.php +++ b/lib/SetupAttempt.php @@ -30,5 +30,14 @@ class SetupAttempt extends ApiResource { const OBJECT_NAME = 'setup_attempt'; - use ApiOperations\All; + /** + * Returns a list of SetupAttempts that associate with a provided SetupIntent. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/setup_attempts', \Stripe\Collection::class, $params, $opts); + } } diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index d8d62a2ac8..c6399fec91 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -57,9 +57,6 @@ class SetupIntent extends ApiResource { const OBJECT_NAME = 'setup_intent'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const CANCELLATION_REASON_ABANDONED = 'abandoned'; @@ -73,6 +70,78 @@ class SetupIntent extends ApiResource const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Creates a SetupIntent object. + * + * After you create the SetupIntent, attach a payment method and confirm it to collect any required + * permissions to charge the payment method later. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of SetupIntents. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/setup_intents', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a SetupIntent that has previously been created. + * + * Client-side retrieval using a publishable key is allowed when the + * client_secret is provided in the query string. + * + * When retrieved with a publishable key, only a subset of properties will be + * returned. Please refer to the SetupIntent + * object reference for more details. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a SetupIntent object. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/ShippingRate.php b/lib/ShippingRate.php index c1ac21de21..b4dd9f4f89 100644 --- a/lib/ShippingRate.php +++ b/lib/ShippingRate.php @@ -25,9 +25,6 @@ class ShippingRate extends ApiResource { const OBJECT_NAME = 'shipping_rate'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const TAX_BEHAVIOR_EXCLUSIVE = 'exclusive'; @@ -35,4 +32,65 @@ class ShippingRate extends ApiResource const TAX_BEHAVIOR_UNSPECIFIED = 'unspecified'; const TYPE_FIXED_AMOUNT = 'fixed_amount'; + + /** + * Creates a new shipping rate object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your shipping rates. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/shipping_rates', \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns the shipping rate object with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing shipping rate object. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Sigma/ScheduledQueryRun.php b/lib/Sigma/ScheduledQueryRun.php index 8a139bcc20..de07f7a1f4 100644 --- a/lib/Sigma/ScheduledQueryRun.php +++ b/lib/Sigma/ScheduledQueryRun.php @@ -26,8 +26,31 @@ class ScheduledQueryRun extends \Stripe\ApiResource { const OBJECT_NAME = 'scheduled_query_run'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Returns a list of scheduled query runs. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/sigma/scheduled_query_runs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an scheduled query run. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } public static function classUrl() { diff --git a/lib/Source.php b/lib/Source.php index cf4a7fa055..d10b186560 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -60,8 +60,6 @@ class Source extends ApiResource { const OBJECT_NAME = 'source'; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const FLOW_CODE_VERIFICATION = 'code_verification'; @@ -99,6 +97,64 @@ class Source extends ApiResource const USAGE_REUSABLE = 'reusable'; const USAGE_SINGLE_USE = 'single_use'; + /** + * Creates a new source object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieves an existing source object. Supply the unique source ID from a source + * creation request and Stripe will return the corresponding up-to-date source + * object information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified source by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * This request accepts the metadata and owner as + * arguments. It is also possible to update type specific information for selected + * payment methods. Please refer to our payment method + * guides for more detail. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + use ApiOperations\NestedResource; /** diff --git a/lib/Subscription.php b/lib/Subscription.php index a382e221d5..c0480fce6f 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -60,9 +60,6 @@ class Subscription extends ApiResource { const OBJECT_NAME = 'subscription'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -78,6 +75,125 @@ class Subscription extends ApiResource const STATUS_TRIALING = 'trialing'; const STATUS_UNPAID = 'unpaid'; + /** + * Creates a new subscription on an existing customer. Each customer can have up to + * 500 active or scheduled subscriptions. + * + * When you create a subscription with + * collection_method=charge_automatically, the first invoice is + * finalized as part of the request. The payment_behavior parameter + * determines the exact behavior of the initial payment. + * + * To start subscriptions where the first invoice always begins in a + * draft status, use subscription + * schedules instead. Schedules provide the flexibility to model more complex + * billing configurations that change over time. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * By default, returns a list of subscriptions that have not been canceled. In + * order to list canceled subscriptions, specify status=canceled. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/subscriptions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the subscription with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing subscription to match the specified parameters. When + * changing prices or quantities, we optionally prorate the price we charge next + * month to make up for any price changes. To preview how the proration is + * calculated, use the upcoming invoice + * endpoint. + * + * By default, we prorate subscription changes. For example, if a customer signs up + * on May 1 for a 100 price, they’ll be billed + * 100 immediately. If on May 15 they switch to a + * 200 price, then on June 1 they’ll be billed + * 250 (200 for a renewal of her + * subscription, plus a 50 prorating adjustment for half of + * the previous month’s 100 difference). Similarly, a + * downgrade generates a credit that is applied to the next invoice. We also + * prorate when you make quantity changes. + * + * Switching prices does not normally change the billing date or generate an + * immediate charge unless: + * + * + * + * In these cases, we apply a credit for the unused time on the previous price, + * immediately charge the customer using the new price, and reset the billing date. + * + * If you want to charge for an upgrade immediately, pass + * proration_behavior as always_invoice to create + * prorations, automatically invoice the customer for those proration adjustments, + * and attempt to collect payment. If you pass create_prorations, the + * prorations are created but not automatically invoiced. If you want to bill the + * customer for the prorations before the subscription’s renewal date, you need to + * manually invoice the customer. + * + * If you don’t want to prorate, set the proration_behavior option to + * none. With this option, the customer is billed + * 100 on May 1 and 200 on June 1. + * Similarly, if you set proration_behavior to none when + * switching between different billing intervals (for example, from monthly to + * yearly), we don’t generate any credits for the old subscription’s unused time. + * We still reset the billing date and bill immediately for the new subscription. + * + * Updating the quantity on a subscription many times in an hour may result in rate limiting. If you need to bill for a frequently + * changing quantity, consider integrating usage-based billing instead. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + use ApiOperations\Delete { delete as protected _delete; } diff --git a/lib/SubscriptionItem.php b/lib/SubscriptionItem.php index 567ce40db8..f8855ca81f 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -25,13 +25,88 @@ class SubscriptionItem extends ApiResource { const OBJECT_NAME = 'subscription_item'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; + /** + * Adds a new item to an existing subscription. No existing items will be changed + * or replaced. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes an item from the subscription. Removing a subscription item from a + * subscription will not cancel the subscription. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your subscription items for a given subscription. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/subscription_items', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the subscription item with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the plan or quantity of an item on a current subscription. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + const PATH_USAGE_RECORDS = '/usage_records'; /** diff --git a/lib/SubscriptionSchedule.php b/lib/SubscriptionSchedule.php index 15573387ae..831c17c76f 100644 --- a/lib/SubscriptionSchedule.php +++ b/lib/SubscriptionSchedule.php @@ -34,9 +34,6 @@ class SubscriptionSchedule extends ApiResource { const OBJECT_NAME = 'subscription_schedule'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const BILLING_BEHAVIOR_PRORATE_ON_NEXT_PHASE = 'prorate_on_next_phase'; @@ -53,6 +50,70 @@ class SubscriptionSchedule extends ApiResource const STATUS_NOT_STARTED = 'not_started'; const STATUS_RELEASED = 'released'; + /** + * Creates a new subscription schedule object. Each customer can have up to 500 + * active or scheduled subscriptions. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieves the list of your subscription schedules. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/subscription_schedules', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing subscription schedule. You only need to + * supply the unique subscription schedule identifier that was returned upon + * subscription schedule creation. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing subscription schedule. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Tax/Calculation.php b/lib/Tax/Calculation.php index 35b54bd730..f9ab7b093b 100644 --- a/lib/Tax/Calculation.php +++ b/lib/Tax/Calculation.php @@ -29,7 +29,22 @@ class Calculation extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.calculation'; - use \Stripe\ApiOperations\Create; + /** + * Calculates tax based on input and returns a Tax Calculation object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } /** * @param string $id diff --git a/lib/Tax/Form.php b/lib/Tax/Form.php index 8828030d37..06b4aa390f 100644 --- a/lib/Tax/Form.php +++ b/lib/Tax/Form.php @@ -25,13 +25,39 @@ class Form extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.form'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const TYPE_US_1099_K = 'us_1099_k'; const TYPE_US_1099_MISC = 'us_1099_misc'; const TYPE_US_1099_NEC = 'us_1099_nec'; + /** + * Returns a list of tax forms which were previously created. The tax forms are + * returned in sorted order, with the oldest tax forms appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax/forms', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a tax form that has previously been created. Supply the + * unique tax form ID that was returned from your previous request, and Stripe will + * return the corresponding tax form information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param callable $readBodyChunkCallable * @param null|array $params diff --git a/lib/Tax/Registration.php b/lib/Tax/Registration.php index 6f0285f81f..9f658db64e 100644 --- a/lib/Tax/Registration.php +++ b/lib/Tax/Registration.php @@ -25,12 +25,73 @@ class Registration extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.registration'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_ACTIVE = 'active'; const STATUS_EXPIRED = 'expired'; const STATUS_SCHEDULED = 'scheduled'; + + /** + * Creates a new Tax Registration object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of Tax Registration objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax/registrations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns a Tax Registration object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing Tax Registration object. + * + * A registration cannot be deleted after it has been created. If you wish to end a + * registration you may do so by setting expires_at. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Tax/Settings.php b/lib/Tax/Settings.php index fe9638fa43..ebdfeeec7e 100644 --- a/lib/Tax/Settings.php +++ b/lib/Tax/Settings.php @@ -20,11 +20,23 @@ class Settings extends \Stripe\SingletonApiResource { const OBJECT_NAME = 'tax.settings'; - use \Stripe\ApiOperations\SingletonRetrieve; - const STATUS_ACTIVE = 'active'; const STATUS_PENDING = 'pending'; + /** + * Retrieves Tax Settings for a merchant. + * + * @param null|mixed $opts + */ + public static function retrieve($opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static(null, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts @@ -44,4 +56,27 @@ public static function update($params = null, $opts = null) return $obj; } + + /** + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return static the saved resource + * + * @deprecated The `save` method is deprecated and will be removed in a + * future major version of the library. Use the static method `update` + * on the resource instead. + */ + public function save($opts = null) + { + $params = $this->serializeParameters(); + if (\count($params) > 0) { + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Tax/Transaction.php b/lib/Tax/Transaction.php index 7dcc373b69..6d51f89970 100644 --- a/lib/Tax/Transaction.php +++ b/lib/Tax/Transaction.php @@ -29,11 +29,24 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.transaction'; - use \Stripe\ApiOperations\Retrieve; - const TYPE_REVERSAL = 'reversal'; const TYPE_TRANSACTION = 'transaction'; + /** + * Retrieves a Tax Transaction object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/TaxCode.php b/lib/TaxCode.php index 9c41ce5d23..6fe774f807 100644 --- a/lib/TaxCode.php +++ b/lib/TaxCode.php @@ -16,6 +16,31 @@ class TaxCode extends ApiResource { const OBJECT_NAME = 'tax_code'; - use ApiOperations\All; - use ApiOperations\Retrieve; + /** + * A list of all tax codes + * available to add to Products in order to allow specific tax calculations. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax_codes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing tax code. Supply the unique tax code ID and + * Stripe will return the corresponding tax code information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/TaxId.php b/lib/TaxId.php index 3f039ae012..307a863229 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -25,11 +25,6 @@ class TaxId extends ApiResource { const OBJECT_NAME = 'tax_id'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; - const TYPE_AD_NRT = 'ad_nrt'; const TYPE_AE_TRN = 'ae_trn'; const TYPE_AR_CUIT = 'ar_cuit'; @@ -103,6 +98,65 @@ class TaxId extends ApiResource const TYPE_VN_TIN = 'vn_tin'; const TYPE_ZA_VAT = 'za_vat'; + /** + * Creates a new account or customer tax_id object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes an existing account or customer tax_id object. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of tax IDs. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax_ids', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an account or customer tax_id object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + const VERIFICATION_STATUS_PENDING = 'pending'; const VERIFICATION_STATUS_UNAVAILABLE = 'unavailable'; const VERIFICATION_STATUS_UNVERIFIED = 'unverified'; diff --git a/lib/TaxRate.php b/lib/TaxRate.php index f0a8889432..016b8a934b 100644 --- a/lib/TaxRate.php +++ b/lib/TaxRate.php @@ -30,9 +30,6 @@ class TaxRate extends ApiResource { const OBJECT_NAME = 'tax_rate'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const JURISDICTION_LEVEL_CITY = 'city'; @@ -54,4 +51,66 @@ class TaxRate extends ApiResource const TAX_TYPE_RST = 'rst'; const TAX_TYPE_SALES_TAX = 'sales_tax'; const TAX_TYPE_VAT = 'vat'; + + /** + * Creates a new tax rate. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of your tax rates. Tax rates are returned sorted by creation + * date, with the most recently created tax rates appearing first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax_rates', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a tax rate with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing tax rate. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Terminal/Configuration.php b/lib/Terminal/Configuration.php index d30ac67122..8f8d2465b1 100644 --- a/lib/Terminal/Configuration.php +++ b/lib/Terminal/Configuration.php @@ -22,9 +22,82 @@ class Configuration extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.configuration'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a new Configuration object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes a Configuration object. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of Configuration objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/terminal/configurations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Configuration object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a new Configuration object. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Terminal/ConnectionToken.php b/lib/Terminal/ConnectionToken.php index 72751f071c..80758e5ab1 100644 --- a/lib/Terminal/ConnectionToken.php +++ b/lib/Terminal/ConnectionToken.php @@ -17,5 +17,22 @@ class ConnectionToken extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.connection_token'; - use \Stripe\ApiOperations\Create; + /** + * To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived + * connection token from Stripe, proxied through your server. On your backend, add + * an endpoint that creates and returns a connection token. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Terminal/Location.php b/lib/Terminal/Location.php index 88634b4312..7836f578bc 100644 --- a/lib/Terminal/Location.php +++ b/lib/Terminal/Location.php @@ -21,9 +21,85 @@ class Location extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.location'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a new Location object. For further details, including which + * address fields are required in each country, see the Manage locations guide. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes a Location object. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of Location objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/terminal/locations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Location object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a Location object by setting the values of the parameters + * passed. Any parameters not provided will be left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } } diff --git a/lib/Terminal/Reader.php b/lib/Terminal/Reader.php index a448668e69..0add9361d5 100644 --- a/lib/Terminal/Reader.php +++ b/lib/Terminal/Reader.php @@ -26,10 +26,6 @@ class Reader extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.reader'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const DEVICE_TYPE_BBPOS_CHIPPER2X = 'bbpos_chipper2x'; @@ -43,6 +39,84 @@ class Reader extends \Stripe\ApiResource const STATUS_OFFLINE = 'offline'; const STATUS_ONLINE = 'online'; + /** + * Creates a new Reader object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes a Reader object. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of Reader objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/terminal/readers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Reader object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a Reader object by setting the values of the parameters + * passed. Any parameters not provided will be left unchanged. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/TestHelpers/TestClock.php b/lib/TestHelpers/TestClock.php index badc48f85c..39de3270f7 100644 --- a/lib/TestHelpers/TestClock.php +++ b/lib/TestHelpers/TestClock.php @@ -22,15 +22,69 @@ class TestClock extends \Stripe\ApiResource { const OBJECT_NAME = 'test_helpers.test_clock'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; - const STATUS_ADVANCING = 'advancing'; const STATUS_INTERNAL_FAILURE = 'internal_failure'; const STATUS_READY = 'ready'; + /** + * Creates a new test clock that can be attached to new customers and quotes. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Deletes a test clock. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your test clocks. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/test_helpers/test_clocks', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a test clock. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Token.php b/lib/Token.php index 4b12fda350..8922922016 100644 --- a/lib/Token.php +++ b/lib/Token.php @@ -40,11 +40,45 @@ class Token extends ApiResource { const OBJECT_NAME = 'token'; - use ApiOperations\Create; - use ApiOperations\Retrieve; - const TYPE_ACCOUNT = 'account'; const TYPE_BANK_ACCOUNT = 'bank_account'; const TYPE_CARD = 'card'; const TYPE_PII = 'pii'; + + /** + * Creates a single-use token that represents a bank account’s details. You can use + * this token with any API method in place of a bank account dictionary. You can + * only use this token once. To do so, attach it to a connected + * account where controller.requirement_collection + * is application, which includes Custom accounts. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Retrieves the token with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Topup.php b/lib/Topup.php index 32ad57fadc..566ba25601 100644 --- a/lib/Topup.php +++ b/lib/Topup.php @@ -32,9 +32,6 @@ class Topup extends ApiResource { const OBJECT_NAME = 'topup'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -43,6 +40,70 @@ class Topup extends ApiResource const STATUS_REVERSED = 'reversed'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Top up the balance of an account. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of top-ups. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/topups', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a top-up that has previously been created. Supply the + * unique top-up ID that was returned from your previous request, and Stripe will + * return the corresponding top-up information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the metadata of a top-up. Other top-up details are not editable by + * design. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Transfer.php b/lib/Transfer.php index cf0206238f..a750522087 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -38,16 +38,83 @@ class Transfer extends ApiResource { const OBJECT_NAME = 'transfer'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account'; const SOURCE_TYPE_CARD = 'card'; const SOURCE_TYPE_FPX = 'fpx'; + /** + * To send funds from your Stripe account to a connected account, you create a new + * transfer object. Your Stripe balance must be able to + * cover the transfer amount, or you’ll receive an “Insufficient Funds” error. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of existing transfers sent to connected accounts. The transfers + * are returned in sorted order, with the most recently created transfers appearing + * first. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/transfers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing transfer. Supply the unique transfer ID + * from either a transfer creation request or the transfer list, and Stripe will + * return the corresponding transfer information. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified transfer by setting the values of the parameters passed. + * Any parameters not provided will be left unchanged. + * + * This request accepts only metadata as an argument. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + const PATH_REVERSALS = '/reversals'; /** diff --git a/lib/Treasury/CreditReversal.php b/lib/Treasury/CreditReversal.php index 1866517586..2dcf7062b2 100644 --- a/lib/Treasury/CreditReversal.php +++ b/lib/Treasury/CreditReversal.php @@ -26,14 +26,55 @@ class CreditReversal extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.credit_reversal'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const NETWORK_ACH = 'ach'; const NETWORK_STRIPE = 'stripe'; const STATUS_CANCELED = 'canceled'; const STATUS_POSTED = 'posted'; const STATUS_PROCESSING = 'processing'; + + /** + * Reverses a ReceivedCredit and creates a CreditReversal object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of CreditReversals. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/credit_reversals', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing CreditReversal by passing the unique + * CreditReversal ID from either the CreditReversal creation request or + * CreditReversal list. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Treasury/DebitReversal.php b/lib/Treasury/DebitReversal.php index b9100f2cd6..a6b3818c98 100644 --- a/lib/Treasury/DebitReversal.php +++ b/lib/Treasury/DebitReversal.php @@ -27,14 +27,53 @@ class DebitReversal extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.debit_reversal'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const NETWORK_ACH = 'ach'; const NETWORK_CARD = 'card'; const STATUS_FAILED = 'failed'; const STATUS_PROCESSING = 'processing'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Reverses a ReceivedDebit and creates a DebitReversal object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of DebitReversals. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/debit_reversals', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a DebitReversal object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Treasury/FinancialAccount.php b/lib/Treasury/FinancialAccount.php index e7ae8982c6..efdc5fac6d 100644 --- a/lib/Treasury/FinancialAccount.php +++ b/lib/Treasury/FinancialAccount.php @@ -29,14 +29,73 @@ class FinancialAccount extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.financial_account'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_CLOSED = 'closed'; const STATUS_OPEN = 'open'; + /** + * Creates a new FinancialAccount. For now, each connected account can only have + * one FinancialAccount. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of FinancialAccounts. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/financial_accounts', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a FinancialAccount. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the details of a FinancialAccount. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/InboundTransfer.php b/lib/Treasury/InboundTransfer.php index bf1ceaffbb..03398d2b59 100644 --- a/lib/Treasury/InboundTransfer.php +++ b/lib/Treasury/InboundTransfer.php @@ -32,15 +32,54 @@ class InboundTransfer extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.inbound_transfer'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELED = 'canceled'; const STATUS_FAILED = 'failed'; const STATUS_PROCESSING = 'processing'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Creates an InboundTransfer. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of InboundTransfers sent from the specified FinancialAccount. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/inbound_transfers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing InboundTransfer. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/OutboundPayment.php b/lib/Treasury/OutboundPayment.php index 48f82f18c1..395235f87e 100644 --- a/lib/Treasury/OutboundPayment.php +++ b/lib/Treasury/OutboundPayment.php @@ -36,16 +36,57 @@ class OutboundPayment extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.outbound_payment'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELED = 'canceled'; const STATUS_FAILED = 'failed'; const STATUS_POSTED = 'posted'; const STATUS_PROCESSING = 'processing'; const STATUS_RETURNED = 'returned'; + /** + * Creates an OutboundPayment. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of OutboundPayments sent from the specified FinancialAccount. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/outbound_payments', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing OutboundPayment by passing the unique + * OutboundPayment ID from either the OutboundPayment creation request or + * OutboundPayment list. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/OutboundTransfer.php b/lib/Treasury/OutboundTransfer.php index 136dcfb478..d3fda59056 100644 --- a/lib/Treasury/OutboundTransfer.php +++ b/lib/Treasury/OutboundTransfer.php @@ -35,16 +35,57 @@ class OutboundTransfer extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.outbound_transfer'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELED = 'canceled'; const STATUS_FAILED = 'failed'; const STATUS_POSTED = 'posted'; const STATUS_PROCESSING = 'processing'; const STATUS_RETURNED = 'returned'; + /** + * Creates an OutboundTransfer. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * Returns a list of OutboundTransfers sent from the specified FinancialAccount. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/outbound_transfers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing OutboundTransfer by passing the unique + * OutboundTransfer ID from either the OutboundTransfer creation request or + * OutboundTransfer list. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/ReceivedCredit.php b/lib/Treasury/ReceivedCredit.php index b0731b3256..8d17e45ab9 100644 --- a/lib/Treasury/ReceivedCredit.php +++ b/lib/Treasury/ReceivedCredit.php @@ -29,9 +29,6 @@ class ReceivedCredit extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.received_credit'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FAILURE_CODE_ACCOUNT_CLOSED = 'account_closed'; const FAILURE_CODE_ACCOUNT_FROZEN = 'account_frozen'; const FAILURE_CODE_OTHER = 'other'; @@ -43,4 +40,31 @@ class ReceivedCredit extends \Stripe\ApiResource const STATUS_FAILED = 'failed'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Returns a list of ReceivedCredits. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/received_credits', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedCredit by passing the unique + * ReceivedCredit ID from the ReceivedCredit list. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Treasury/ReceivedDebit.php b/lib/Treasury/ReceivedDebit.php index b825019e2f..f78c5a887a 100644 --- a/lib/Treasury/ReceivedDebit.php +++ b/lib/Treasury/ReceivedDebit.php @@ -29,9 +29,6 @@ class ReceivedDebit extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.received_debit'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FAILURE_CODE_ACCOUNT_CLOSED = 'account_closed'; const FAILURE_CODE_ACCOUNT_FROZEN = 'account_frozen'; const FAILURE_CODE_INSUFFICIENT_FUNDS = 'insufficient_funds'; @@ -43,4 +40,31 @@ class ReceivedDebit extends \Stripe\ApiResource const STATUS_FAILED = 'failed'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Returns a list of ReceivedDebits. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/received_debits', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedDebit by passing the unique + * ReceivedDebit ID from the ReceivedDebit list. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Treasury/Transaction.php b/lib/Treasury/Transaction.php index 1705e03da5..8c1c080ff8 100644 --- a/lib/Treasury/Transaction.php +++ b/lib/Treasury/Transaction.php @@ -27,9 +27,6 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FLOW_TYPE_CREDIT_REVERSAL = 'credit_reversal'; const FLOW_TYPE_DEBIT_REVERSAL = 'debit_reversal'; const FLOW_TYPE_INBOUND_TRANSFER = 'inbound_transfer'; @@ -43,4 +40,30 @@ class Transaction extends \Stripe\ApiResource const STATUS_OPEN = 'open'; const STATUS_POSTED = 'posted'; const STATUS_VOID = 'void'; + + /** + * Retrieves a list of Transaction objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing Transaction. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Treasury/TransactionEntry.php b/lib/Treasury/TransactionEntry.php index 6243682999..79ebd445ea 100644 --- a/lib/Treasury/TransactionEntry.php +++ b/lib/Treasury/TransactionEntry.php @@ -25,9 +25,6 @@ class TransactionEntry extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.transaction_entry'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FLOW_TYPE_CREDIT_REVERSAL = 'credit_reversal'; const FLOW_TYPE_DEBIT_REVERSAL = 'debit_reversal'; const FLOW_TYPE_INBOUND_TRANSFER = 'inbound_transfer'; @@ -58,4 +55,30 @@ class TransactionEntry extends \Stripe\ApiResource const TYPE_OUTBOUND_TRANSFER_RETURN = 'outbound_transfer_return'; const TYPE_RECEIVED_CREDIT = 'received_credit'; const TYPE_RECEIVED_DEBIT = 'received_debit'; + + /** + * Retrieves a list of TransactionEntry objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/transaction_entries', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a TransactionEntry object. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/WebhookEndpoint.php b/lib/WebhookEndpoint.php index 1200bb1202..cc1983c5d3 100644 --- a/lib/WebhookEndpoint.php +++ b/lib/WebhookEndpoint.php @@ -30,9 +30,93 @@ class WebhookEndpoint extends ApiResource { const OBJECT_NAME = 'webhook_endpoint'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * A webhook endpoint must have a url and a list of + * enabled_events. You may optionally specify the Boolean + * connect parameter. If set to true, then a Connect webhook endpoint + * that notifies the specified url about events from all connected + * accounts is created; otherwise an account webhook endpoint that notifies the + * specified url only about events from your account is created. You + * can also create webhook endpoints in the webhooks settings + * section of the Dashboard. + * + * @param null|mixed $params + * @param null|mixed $options + */ + public static function create($params = null, $options = null) + { + self::_validateParams($params); + $url = static::classUrl(); + list($response, $opts) = static::_staticRequest('post', $url, $params, $options); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * You can also delete webhook endpoints via the webhook endpoint + * management page of the Stripe dashboard. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public function delete($params = null, $opts = null) + { + self::_validateParams($params); + $url = $this->instanceUrl(); + list($response, $opts) = $this->_request('delete', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * Returns a list of your webhook endpoints. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/webhook_endpoints', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the webhook endpoint with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the webhook endpoint. You may edit the url, the list of + * enabled_events, and the status of your endpoint. + * + * @param mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function update($id, $params = null, $opts = null) + { + self::_validateParams($params); + $url = static::resourceUrl($id); + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } }