NEW Update Stripe library to 6.34.3

This commit is contained in:
Laurent Destailleur 2019-05-03 02:22:27 +02:00
parent 10d853cdb3
commit eab49d4300
166 changed files with 3851 additions and 5981 deletions

View File

@ -150,7 +150,7 @@ function showOnlinePaymentUrl($type, $ref)
* @param string $localorexternal 0=Url for browser, 1=Url for external access
* @return string Url string
*/
function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_free_tag', $localorexternal = 0)
function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0)
{
global $conf, $dolibarr_main_url_root;

View File

@ -1,4 +0,0 @@
service_name: travis-ci
src_dir: .
coverage_clover: clover.xml
json_path: coveralls-upload.json

View File

@ -1,40 +0,0 @@
sudo: false
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm
env:
global:
- STRIPE_MOCK_VERSION=0.8.0
matrix:
- AUTOLOAD=1
- AUTOLOAD=0
cache:
directories:
- $HOME/.composer/cache/files
- stripe-mock
before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
- |
if [ ! -d "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" ]; then
mkdir -p stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/
curl -L "https://github.com/stripe/stripe-mock/releases/download/v${STRIPE_MOCK_VERSION}/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -o "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz"
tar -zxf "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}_linux_amd64.tar.gz" -C "stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/"
fi
- |
stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/stripe-mock > /dev/null &
STRIPE_MOCK_PID=$!
script: ./build.php ${AUTOLOAD}
after_script: ./vendor/bin/coveralls -v

View File

@ -1,5 +1,221 @@
# Changelog
## 6.34.3 - 2019-05-01
* [#644](https://github.com/stripe/stripe-php/pull/644) Update return type to `static` to improve static analysis
* [#645](https://github.com/stripe/stripe-php/pull/645) Fix constant for `payment_intent.payment_failed`
## 6.34.2 - 2019-04-26
* [#642](https://github.com/stripe/stripe-php/pull/642) Fix an issue where existing idempotency keys would be overwritten when using automatic retries
## 6.34.1 - 2019-04-25
* [#640](https://github.com/stripe/stripe-php/pull/640) Add missing phpdocs
## 6.34.0 - 2019-04-24
* [#626](https://github.com/stripe/stripe-php/pull/626) Add support for the `TaxRate` resource and APIs
* [#639](https://github.com/stripe/stripe-php/pull/639) Fix multiple phpdoc issues
## 6.33.0 - 2019-04-22
* [#630](https://github.com/stripe/stripe-php/pull/630) Add support for the `TaxId` resource and APIs
## 6.32.1 - 2019-04-19
* [#636](https://github.com/stripe/stripe-php/pull/636) Correct type of `$personId` in PHPDoc
## 6.32.0 - 2019-04-18
* [#621](https://github.com/stripe/stripe-php/pull/621) Add support for `CreditNote`
## 6.31.5 - 2019-04-12
* [#628](https://github.com/stripe/stripe-php/pull/628) Add constants for `person.*` event types
* [#628](https://github.com/stripe/stripe-php/pull/628) Add missing constants for `Account` and `Person`
## 6.31.4 - 2019-04-05
* [#624](https://github.com/stripe/stripe-php/pull/624) Fix encoding of nested parameters in multipart requests
## 6.31.3 - 2019-04-02
* [#623](https://github.com/stripe/stripe-php/pull/623) Only use HTTP/2 with curl >= 7.60.0
## 6.31.2 - 2019-03-25
* [#619](https://github.com/stripe/stripe-php/pull/619) Fix PHPDoc return types for list methods for nested resources
## 6.31.1 - 2019-03-22
* [#612](https://github.com/stripe/stripe-php/pull/612) Add a lot of constants
* [#614](https://github.com/stripe/stripe-php/pull/614) Add missing subscription status constants
## 6.31.0 - 2019-03-18
* [#600](https://github.com/stripe/stripe-php/pull/600) Add support for the `PaymentMethod` resource and APIs
* [#606](https://github.com/stripe/stripe-php/pull/606) Add support for retrieving a Checkout `Session`
* [#611](https://github.com/stripe/stripe-php/pull/611) Add support for deleting a Terminal `Location` and `Reader`
## 6.30.5 - 2019-03-11
* [#607](https://github.com/stripe/stripe-php/pull/607) Correctly handle case where a metadata key is called `metadata`
## 6.30.4 - 2019-02-27
* [#602](https://github.com/stripe/stripe-php/pull/602) Add `subscription_schedule` to `Subscription` for PHPDoc.
## 6.30.3 - 2019-02-26
* [#603](https://github.com/stripe/stripe-php/pull/603) Improve PHPDoc on the `Source` object to cover all types of Sources currently supported.
## 6.30.2 - 2019-02-25
* [#601](https://github.com/stripe/stripe-php/pull/601) Fix PHPDoc across multiple resources and add support for new events.
## 6.30.1 - 2019-02-16
* [#599](https://github.com/stripe/stripe-php/pull/599) Fix PHPDoc for `SubscriptionSchedule` and `SubscriptionScheduleRevision`
## 6.30.0 - 2019-02-12
* [#590](https://github.com/stripe/stripe-php/pull/590) Add support for `SubscriptionSchedule` and `SubscriptionScheduleRevision`
## 6.29.3 - 2019-01-31
* [#592](https://github.com/stripe/stripe-php/pull/592) Some more PHPDoc fixes
## 6.29.2 - 2019-01-31
* [#591](https://github.com/stripe/stripe-php/pull/591) Fix PHPDoc for nested resources
## 6.29.1 - 2019-01-25
* [#566](https://github.com/stripe/stripe-php/pull/566) Fix dangling message contents
* [#586](https://github.com/stripe/stripe-php/pull/586) Don't overwrite `CURLOPT_HTTP_VERSION` option
## 6.29.0 - 2019-01-23
* [#579](https://github.com/stripe/stripe-php/pull/579) Rename `CheckoutSession` to `Session` and move it under the `Checkout` namespace. This is a breaking change, but we've reached out to affected merchants and all new merchants would use the new approach.
## 6.28.1 - 2019-01-21
* [#580](https://github.com/stripe/stripe-php/pull/580) Properly serialize `individual` on `Account` objects
## 6.28.0 - 2019-01-03
* [#576](https://github.com/stripe/stripe-php/pull/576) Add support for iterating directly over `Collection` instances
## 6.27.0 - 2018-12-21
* [#571](https://github.com/stripe/stripe-php/pull/571) Add support for the `CheckoutSession` resource
## 6.26.0 - 2018-12-11
* [#568](https://github.com/stripe/stripe-php/pull/568) Enable persistent connections
## 6.25.0 - 2018-12-10
* [#567](https://github.com/stripe/stripe-php/pull/567) Add support for account links
## 6.24.0 - 2018-11-28
* [#562](https://github.com/stripe/stripe-php/pull/562) Add support for the Review resource
* [#564](https://github.com/stripe/stripe-php/pull/564) Add event name constants for subscription schedule aborted/expiring
## 6.23.0 - 2018-11-27
* [#542](https://github.com/stripe/stripe-php/pull/542) Add support for `ValueList` and `ValueListItem` for Radar
## 6.22.1 - 2018-11-20
* [#561](https://github.com/stripe/stripe-php/pull/561) Add cast and some docs to telemetry introduced in 6.22.0/#549
## 6.22.0 - 2018-11-15
* [#549](https://github.com/stripe/stripe-php/pull/549) Add support for client telemetry
## 6.21.1 - 2018-11-12
* [#548](https://github.com/stripe/stripe-php/pull/548) Don't mutate `Exception` class properties from `OAuthBase` error
## 6.21.0 - 2018-11-08
* [#537](https://github.com/stripe/stripe-php/pull/537) Add new API endpoints for the `Invoice` resource.
## 6.20.1 - 2018-11-07
* [#546](https://github.com/stripe/stripe-php/pull/546) Drop files from the Composer package that aren't needed in the release
## 6.20.0 - 2018-10-30
* [#536](https://github.com/stripe/stripe-php/pull/536) Add support for the `Person` resource
* [#541](https://github.com/stripe/stripe-php/pull/541) Add support for the `WebhookEndpoint` resource
## 6.19.5 - 2018-10-17
* [#539](https://github.com/stripe/stripe-php/pull/539) Fix methods on `\Stripe\PaymentIntent` to properly pass arguments to the API.
## 6.19.4 - 2018-10-11
* [#534](https://github.com/stripe/stripe-php/pull/534) Fix PSR-4 autoloading for `\Stripe\FileUpload` class alias
## 6.19.3 - 2018-10-09
* [#530](https://github.com/stripe/stripe-php/pull/530) Add constants for `flow` (`FLOW_*`), `status` (`STATUS_*`) and `usage` (`USAGE_*`) on `\Stripe\Source`
## 6.19.2 - 2018-10-08
* [#531](https://github.com/stripe/stripe-php/pull/531) Store HTTP response headers in case-insensitive array
## 6.19.1 - 2018-09-25
* [#526](https://github.com/stripe/stripe-php/pull/526) Ignore null values in request parameters
## 6.19.0 - 2018-09-24
* [#523](https://github.com/stripe/stripe-php/pull/523) Add support for Stripe Terminal
## 6.18.0 - 2018-09-24
* [#520](https://github.com/stripe/stripe-php/pull/520) Rename `\Stripe\FileUpload` to `\Stripe\File`
## 6.17.2 - 2018-09-18
* [#522](https://github.com/stripe/stripe-php/pull/522) Fix warning when adding a new additional owner to an existing array
## 6.17.1 - 2018-09-14
* [#517](https://github.com/stripe/stripe-php/pull/517) Integer-index encode all sequential arrays
## 6.17.0 - 2018-09-05
* [#514](https://github.com/stripe/stripe-php/pull/514) Add support for reporting resources
## 6.16.0 - 2018-08-23
* [#509](https://github.com/stripe/stripe-php/pull/509) Add support for usage record summaries
## 6.15.0 - 2018-08-03
* [#504](https://github.com/stripe/stripe-php/pull/504) Add cancel support for topups
## 6.14.0 - 2018-08-02
* [#505](https://github.com/stripe/stripe-php/pull/505) Add support for file links
## 6.13.0 - 2018-07-31
* [#502](https://github.com/stripe/stripe-php/pull/502) Add `isDeleted()` method to `\Stripe\StripeObject`
## 6.12.0 - 2018-07-28
* [#501](https://github.com/stripe/stripe-php/pull/501) Add support for scheduled query runs (`\Stripe\Sigma\ScheduledQueryRun`) for Sigma
## 6.11.0 - 2018-07-26
* [#500](https://github.com/stripe/stripe-php/pull/500) Add support for Stripe Issuing
## 6.10.4 - 2018-07-19
* [#498](https://github.com/stripe/stripe-php/pull/498) Internal improvements to the `\Stripe\ApiResource.classUrl()` method
## 6.10.3 - 2018-07-16
* [#497](https://github.com/stripe/stripe-php/pull/497) Use HTTP/2 only for HTTPS requests
## 6.10.2 - 2018-07-11
* [#494](https://github.com/stripe/stripe-php/pull/494) Enable HTTP/2 support
## 6.10.1 - 2018-07-10
* [#493](https://github.com/stripe/stripe-php/pull/493) Add PHPDoc for `auto_advance` on `\Stripe\Invoice`
## 6.10.0 - 2018-06-28
* [#488](https://github.com/stripe/stripe-php/pull/488) Add support for `$appPartnerId` to `Stripe::setAppInfo()`
## 6.9.0 - 2018-06-28
* [#487](https://github.com/stripe/stripe-php/pull/487) Add support for payment intents
## 6.8.2 - 2018-06-24
* [#486](https://github.com/stripe/stripe-php/pull/486) Make `Account.deauthorize()` return the `StripeObject` from the API
## 6.8.1 - 2018-06-13
* [#472](https://github.com/stripe/stripe-php/pull/472) Added phpDoc for `ApiRequestor` and others, especially regarding thrown errors
## 6.8.0 - 2018-06-13
* [#481](https://github.com/stripe/stripe-php/pull/481) Add new `\Stripe\Discount` and `\Stripe\OrderItem` classes, add more PHPDoc describing object attributes
## 6.7.4 - 2018-05-29
* [#480](https://github.com/stripe/stripe-php/pull/480) PHPDoc changes for API version 2018-05-21 and the addition of the new `CHARGE_EXPIRED` event type
## 6.7.3 - 2018-05-28
* [#479](https://github.com/stripe/stripe-php/pull/479) Fix unnecessary traits on `\Stripe\InvoiceLineItem`
## 6.7.2 - 2018-05-28
* [#471](https://github.com/stripe/stripe-php/pull/471) Add `OBJECT_NAME` constant to all API resource classes, add `\Stripe\InvoiceLineItem` class
## 6.7.1 - 2018-05-13
* [#468](https://github.com/stripe/stripe-php/pull/468) Update fields in PHP docs for accuracy
## 6.7.0 - 2018-05-09
* [#466](https://github.com/stripe/stripe-php/pull/466) Add support for issuer fraud records
## 6.6.0 - 2018-04-11
* [#460](https://github.com/stripe/stripe-php/pull/460) Add support for flexible billing primitives
## 6.5.0 - 2018-04-05
* [#461](https://github.com/stripe/stripe-php/pull/461) Don't zero keys on non-`metadata` subobjects
## 6.4.2 - 2018-03-17
* [#458](https://github.com/stripe/stripe-php/pull/458) Add PHPDoc for `account` on `\Stripe\Event`
## 6.4.1 - 2018-03-02
* [#455](https://github.com/stripe/stripe-php/pull/455) Fix namespaces in PHPDoc
* [#456](https://github.com/stripe/stripe-php/pull/456) Fix namespaces for some exceptions

View File

@ -1,6 +1,6 @@
The MIT License
Copyright (c) 2010-2015 Stripe
Copyright (c) 2010-2019 Stripe, Inc. (https://stripe.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -62,7 +62,7 @@ Please see https://stripe.com/docs/api for up-to-date documentation.
### PHP 5.3
If you are using PHP 5.3, you can download v5.8.0 ([zip](https://github.com/stripe/stripe-php/archive/v5.8.0.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.8.0.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
If you are using PHP 5.3, you can download v5.9.2 ([zip](https://github.com/stripe/stripe-php/archive/v5.9.2.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v5.9.2.tar.gz)) from our [releases page](https://github.com/stripe/stripe-php/releases). This version will continue to work with new versions of the Stripe API for all common uses.
### PHP 5.2
@ -181,9 +181,15 @@ retries are safe.
## Development
Get [Composer][composer]. For example, on Mac OS:
```bash
brew install composer
```
Install dependencies:
``` bash
```bash
composer install
```
@ -191,8 +197,10 @@ The test suite depends on [stripe-mock], so make sure to fetch and run it from a
background terminal ([stripe-mock's README][stripe-mock] also contains
instructions for installing via Homebrew and other methods):
go get -u github.com/stripe/stripe-mock
stripe-mock
```bash
go get -u github.com/stripe/stripe-mock
stripe-mock
```
Install dependencies as mentioned above (which will resolve [PHPUnit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite:
@ -226,6 +234,7 @@ The method should be called once, before any request is sent to the API. The sec
See the "SSL / TLS compatibility issues" paragraph above for full context. If you want to ensure that your plugin can be used on all systems, you should add a configuration option to let your users choose between different values for `CURLOPT_SSLVERSION`: none (default), `CURL_SSLVERSION_TLSv1` and `CURL_SSLVERSION_TLSv1_2`.
[composer]: https://getcomposer.org/
[connect]: https://stripe.com/connect
[curl]: http://curl.haxx.se/docs/caextract.html
[psr3]: http://www.php-fig.org/psr/psr-3/

View File

@ -1 +1 @@
6.4.1
6.34.3

View File

@ -13,7 +13,7 @@ if (!$autoload) {
file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
}
passthru('composer install', $returnStatus);
passthru('composer update', $returnStatus);
if ($returnStatus !== 0) {
exit(1);
}

View File

@ -22,8 +22,9 @@
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~0.6.1",
"squizlabs/php_codesniffer": "~2.0"
"php-coveralls/php-coveralls": "1.*",
"squizlabs/php_codesniffer": "~2.0",
"symfony/process": "~2.8"
},
"autoload": {
"psr-4": { "Stripe\\" : "lib/" }

View File

@ -5,6 +5,7 @@ require(dirname(__FILE__) . '/lib/Stripe.php');
// Utilities
require(dirname(__FILE__) . '/lib/Util/AutoPagingIterator.php');
require(dirname(__FILE__) . '/lib/Util/CaseInsensitiveArray.php');
require(dirname(__FILE__) . '/lib/Util/LoggerInterface.php');
require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');
require(dirname(__FILE__) . '/lib/Util/RandomGenerator.php');
@ -48,6 +49,7 @@ require(dirname(__FILE__) . '/lib/ApiOperations/Update.php');
// Plumbing
require(dirname(__FILE__) . '/lib/ApiResponse.php');
require(dirname(__FILE__) . '/lib/RequestTelemetry.php');
require(dirname(__FILE__) . '/lib/StripeObject.php');
require(dirname(__FILE__) . '/lib/ApiRequestor.php');
require(dirname(__FILE__) . '/lib/ApiResource.php');
@ -55,6 +57,7 @@ require(dirname(__FILE__) . '/lib/SingletonApiResource.php');
// Stripe API Resources
require(dirname(__FILE__) . '/lib/Account.php');
require(dirname(__FILE__) . '/lib/AccountLink.php');
require(dirname(__FILE__) . '/lib/AlipayAccount.php');
require(dirname(__FILE__) . '/lib/ApplePayDomain.php');
require(dirname(__FILE__) . '/lib/ApplicationFee.php');
@ -66,40 +69,73 @@ require(dirname(__FILE__) . '/lib/BitcoinReceiver.php');
require(dirname(__FILE__) . '/lib/BitcoinTransaction.php');
require(dirname(__FILE__) . '/lib/Card.php');
require(dirname(__FILE__) . '/lib/Charge.php');
require(dirname(__FILE__) . '/lib/Checkout/Session.php');
require(dirname(__FILE__) . '/lib/Collection.php');
require(dirname(__FILE__) . '/lib/CountrySpec.php');
require(dirname(__FILE__) . '/lib/Coupon.php');
require(dirname(__FILE__) . '/lib/CreditNote.php');
require(dirname(__FILE__) . '/lib/Customer.php');
require(dirname(__FILE__) . '/lib/Discount.php');
require(dirname(__FILE__) . '/lib/Dispute.php');
require(dirname(__FILE__) . '/lib/EphemeralKey.php');
require(dirname(__FILE__) . '/lib/Event.php');
require(dirname(__FILE__) . '/lib/ExchangeRate.php');
require(dirname(__FILE__) . '/lib/File.php');
require(dirname(__FILE__) . '/lib/FileLink.php');
require(dirname(__FILE__) . '/lib/FileUpload.php');
require(dirname(__FILE__) . '/lib/Invoice.php');
require(dirname(__FILE__) . '/lib/InvoiceItem.php');
require(dirname(__FILE__) . '/lib/InvoiceLineItem.php');
require(dirname(__FILE__) . '/lib/IssuerFraudRecord.php');
require(dirname(__FILE__) . '/lib/Issuing/Authorization.php');
require(dirname(__FILE__) . '/lib/Issuing/Card.php');
require(dirname(__FILE__) . '/lib/Issuing/CardDetails.php');
require(dirname(__FILE__) . '/lib/Issuing/Cardholder.php');
require(dirname(__FILE__) . '/lib/Issuing/Dispute.php');
require(dirname(__FILE__) . '/lib/Issuing/Transaction.php');
require(dirname(__FILE__) . '/lib/LoginLink.php');
require(dirname(__FILE__) . '/lib/Order.php');
require(dirname(__FILE__) . '/lib/OrderItem.php');
require(dirname(__FILE__) . '/lib/OrderReturn.php');
require(dirname(__FILE__) . '/lib/PaymentIntent.php');
require(dirname(__FILE__) . '/lib/PaymentMethod.php');
require(dirname(__FILE__) . '/lib/Payout.php');
require(dirname(__FILE__) . '/lib/Person.php');
require(dirname(__FILE__) . '/lib/Plan.php');
require(dirname(__FILE__) . '/lib/Product.php');
require(dirname(__FILE__) . '/lib/Radar/ValueList.php');
require(dirname(__FILE__) . '/lib/Radar/ValueListItem.php');
require(dirname(__FILE__) . '/lib/Recipient.php');
require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
require(dirname(__FILE__) . '/lib/Refund.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportRun.php');
require(dirname(__FILE__) . '/lib/Reporting/ReportType.php');
require(dirname(__FILE__) . '/lib/Review.php');
require(dirname(__FILE__) . '/lib/SKU.php');
require(dirname(__FILE__) . '/lib/Sigma/ScheduledQueryRun.php');
require(dirname(__FILE__) . '/lib/Source.php');
require(dirname(__FILE__) . '/lib/SourceTransaction.php');
require(dirname(__FILE__) . '/lib/Subscription.php');
require(dirname(__FILE__) . '/lib/SubscriptionItem.php');
require(dirname(__FILE__) . '/lib/SubscriptionSchedule.php');
require(dirname(__FILE__) . '/lib/SubscriptionScheduleRevision.php');
require(dirname(__FILE__) . '/lib/TaxId.php');
require(dirname(__FILE__) . '/lib/TaxRate.php');
require(dirname(__FILE__) . '/lib/Terminal/ConnectionToken.php');
require(dirname(__FILE__) . '/lib/Terminal/Location.php');
require(dirname(__FILE__) . '/lib/Terminal/Reader.php');
require(dirname(__FILE__) . '/lib/ThreeDSecure.php');
require(dirname(__FILE__) . '/lib/Token.php');
require(dirname(__FILE__) . '/lib/Topup.php');
require(dirname(__FILE__) . '/lib/Transfer.php');
require(dirname(__FILE__) . '/lib/TransferReversal.php');
require(dirname(__FILE__) . '/lib/UsageRecord.php');
require(dirname(__FILE__) . '/lib/UsageRecordSummary.php');
// OAuth
require(dirname(__FILE__) . '/lib/OAuth.php');
// Webhooks
require(dirname(__FILE__) . '/lib/Webhook.php');
require(dirname(__FILE__) . '/lib/WebhookEndpoint.php');
require(dirname(__FILE__) . '/lib/WebhookSignature.php');

View File

@ -7,37 +7,32 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property string $business_logo
* @property string $business_name
* @property string $business_primary_color
* @property string $business_url
* @property mixed $business_profile
* @property string $business_type
* @property mixed $capabilities
* @property bool $charges_enabled
* @property mixed $company
* @property string $country
* @property int $created
* @property bool $debit_negative_balances
* @property mixed $decline_charge_on
* @property string $default_currency
* @property bool $details_submitted
* @property string $display_name
* @property string $email
* @property mixed $external_accounts
* @property mixed $legal_entity
* @property Collection $external_accounts
* @property mixed $individual
* @property StripeObject $metadata
* @property mixed $payout_schedule
* @property string $payout_statement_descriptor
* @property bool $payouts_enabled
* @property string $product_description
* @property string $statement_descriptor
* @property string $support_email
* @property string $support_phone
* @property string $timezone
* @property mixed $requirements
* @property mixed $settings
* @property mixed $tos_acceptance
* @property mixed $verification
* @property string $type
*
* @package Stripe
*/
class Account extends ApiResource
{
const OBJECT_NAME = "account";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
@ -47,6 +42,37 @@ class Account extends ApiResource
}
use ApiOperations\Update;
/**
* Possible string representations of an account's business type.
* @link https://stripe.com/docs/api/accounts/object#account_object-business_type
*/
const BUSINESS_TYPE_COMPANY = 'company';
const BUSINESS_TYPE_INDIVIDUAL = 'individual';
/**
* Possible string representations of an account's capabilities.
* @link https://stripe.com/docs/api/accounts/object#account_object-capabilities
*/
const CAPABILITY_CARD_PAYMENTS = 'card_payments';
const CAPABILITY_LEGACY_PAYMENTS = 'legacy_payments';
const CAPABILITY_PLATFORM_PAYMENTS = 'platform_payments';
/**
* Possible string representations of an account's capability status.
* @link https://stripe.com/docs/api/accounts/object#account_object-capabilities
*/
const CAPABILITY_STATUS_ACTIVE = 'active';
const CAPABILITY_STATUS_INACTIVE = 'inactive';
const CAPABILITY_STATUS_PENDING = 'pending';
/**
* Possible string representations of an account's type.
* @link https://stripe.com/docs/api/accounts/object#account_object-type
*/
const TYPE_CUSTOM = 'custom';
const TYPE_EXPRESS = 'express';
const TYPE_STANDARD = 'standard';
public static function getSavedNestedResources()
{
static $savedNestedResources = null;
@ -61,6 +87,7 @@ class Account extends ApiResource
const PATH_EXTERNAL_ACCOUNTS = '/external_accounts';
const PATH_LOGIN_LINKS = '/login_links';
const PATH_PERSONS = '/persons';
public function instanceUrl()
{
@ -101,6 +128,21 @@ class Account extends ApiResource
return $this;
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Collection The list of persons.
*/
public function persons($params = null, $options = null)
{
$url = $this->instanceUrl() . '/persons';
list($response, $opts) = $this->_request('get', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param array|null $clientId
* @param array|string|null $opts
@ -113,11 +155,11 @@ class Account extends ApiResource
'client_id' => $clientId,
'stripe_user_id' => $this->id,
];
OAuth::deauthorize($params, $opts);
return OAuth::deauthorize($params, $opts);
}
/**
* @param array|null $id The ID of the account on which to create the external account.
* @param string|null $id The ID of the account on which to create the external account.
* @param array|null $params
* @param array|string|null $opts
*
@ -129,7 +171,7 @@ class Account extends ApiResource
}
/**
* @param array|null $id The ID of the account to which the external account belongs.
* @param string|null $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to retrieve.
* @param array|null $params
* @param array|string|null $opts
@ -142,7 +184,7 @@ class Account extends ApiResource
}
/**
* @param array|null $id The ID of the account to which the external account belongs.
* @param string|null $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to update.
* @param array|null $params
* @param array|string|null $opts
@ -155,7 +197,7 @@ class Account extends ApiResource
}
/**
* @param array|null $id The ID of the account to which the external account belongs.
* @param string|null $id The ID of the account to which the external account belongs.
* @param array|null $externalAccountId The ID of the external account to delete.
* @param array|null $params
* @param array|string|null $opts
@ -168,11 +210,11 @@ class Account extends ApiResource
}
/**
* @param array|null $id The ID of the account on which to retrieve the external accounts.
* @param string|null $id The ID of the account on which to retrieve the external accounts.
* @param array|null $params
* @param array|string|null $opts
*
* @return BankAccount|Card
* @return Collection The list of external accounts (BankAccount or Card).
*/
public static function allExternalAccounts($id, $params = null, $opts = null)
{
@ -180,7 +222,7 @@ class Account extends ApiResource
}
/**
* @param array|null $id The ID of the account on which to create the login link.
* @param string|null $id The ID of the account on which to create the login link.
* @param array|null $params
* @param array|string|null $opts
*
@ -191,6 +233,69 @@ class Account extends ApiResource
return self::_createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $opts);
}
/**
* @param string|null $id The ID of the account on which to create the person.
* @param array|null $params
* @param array|string|null $opts
*
* @return Person
*/
public static function createPerson($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_PERSONS, $params, $opts);
}
/**
* @param string|null $id The ID of the account to which the person belongs.
* @param string|null $personId The ID of the person to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return Person
*/
public static function retrievePerson($id, $personId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
}
/**
* @param string|null $id The ID of the account to which the person belongs.
* @param string|null $personId The ID of the person to update.
* @param array|null $params
* @param array|string|null $opts
*
* @return Person
*/
public static function updatePerson($id, $personId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
}
/**
* @param string|null $id The ID of the account to which the person belongs.
* @param string|null $personId The ID of the person to delete.
* @param array|null $params
* @param array|string|null $opts
*
* @return Person
*/
public static function deletePerson($id, $personId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_PERSONS, $personId, $params, $opts);
}
/**
* @param string|null $id The ID of the account on which to retrieve the persons.
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection The list of persons.
*/
public static function allPersons($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_PERSONS, $params, $opts);
}
public function serializeParameters($force = false)
{
$update = parent::serializeParameters($force);
@ -203,6 +308,12 @@ class Account extends ApiResource
$update['legal_entity'] = $entityUpdate;
}
}
if (isset($this->_values['individual'])) {
$individual = $this['individual'];
if (($individual instanceof Person) && !isset($update['individual'])) {
$update['individual'] = $individual->serializeParameters($force);
}
}
return $update;
}
@ -224,7 +335,9 @@ class Account extends ApiResource
$update = ($v instanceof StripeObject) ? $v->serializeParameters() : $v;
if ($update !== []) {
if (!$originalValue || ($update != $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
if (!$originalValue ||
!array_key_exists($i, $originalValue) ||
($update != $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
$updateArr[$i] = $update;
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Stripe;
/**
* Class AccountLink
*
* @property string $object
* @property int $created
* @property int $expires_at
* @property string $url
*
* @package Stripe
*/
class AccountLink extends ApiResource
{
const OBJECT_NAME = "account_link";
use ApiOperations\Create;
}

View File

@ -12,6 +12,9 @@ namespace Stripe;
*/
class AlipayAccount extends ApiResource
{
const OBJECT_NAME = "alipay_account";
use ApiOperations\Delete;
use ApiOperations\Update;

View File

@ -25,7 +25,7 @@ trait All
if (!is_a($obj, 'Stripe\\Collection')) {
$class = get_class($obj);
$message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
throw new Error\Api($message);
throw new \Stripe\Error\Api($message);
}
$obj->setLastResponse($response);
$obj->setRequestParams($params);

View File

@ -60,6 +60,7 @@ trait NestedResource
/**
* @param string $id
* @param string $nestedPath
* @param string|null $nestedId
* @param array|null $params
* @param array|string|null $options
*
@ -74,6 +75,7 @@ trait NestedResource
/**
* @param string $id
* @param string $nestedPath
* @param string|null $nestedId
* @param array|null $params
* @param array|string|null $options
*
@ -88,6 +90,7 @@ trait NestedResource
/**
* @param string $id
* @param string $nestedPath
* @param string|null $nestedId
* @param array|null $params
* @param array|string|null $options
*

View File

@ -52,7 +52,8 @@ trait Request
protected static function _staticRequest($method, $url, $params, $options)
{
$opts = \Stripe\Util\RequestOptions::parse($options);
$requestor = new \Stripe\ApiRequestor($opts->apiKey, static::baseUrl());
$baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
$requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
$opts->discardNonPersistentHeaders();
return [$response, $opts];

View File

@ -15,7 +15,7 @@ trait Retrieve
* or an options array containing an `id` key.
* @param array|string|null $opts
*
* @return \Stripe\StripeObject
* @return static
*/
public static function retrieve($id, $opts = null)
{

View File

@ -9,12 +9,32 @@ namespace Stripe;
*/
class ApiRequestor
{
/**
* @var string|null
*/
private $_apiKey;
/**
* @var string
*/
private $_apiBase;
/**
* @var HttpClient\ClientInterface
*/
private static $_httpClient;
/**
* @var RequestTelemetry
*/
private static $requestTelemetry;
/**
* ApiRequestor constructor.
*
* @param string|null $apiKey
* @param string|null $apiBase
*/
public function __construct($apiKey = null, $apiBase = null)
{
$this->_apiKey = $apiKey;
@ -24,6 +44,37 @@ class ApiRequestor
$this->_apiBase = $apiBase;
}
/**
* Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers
* @static
*
* @param RequestTelemetry $requestTelemetry
* @return string
*/
private static function _telemetryJson($requestTelemetry)
{
$payload = array(
'last_request_metrics' => array(
'request_id' => $requestTelemetry->requestId,
'request_duration_ms' => $requestTelemetry->requestDuration,
));
$result = json_encode($payload);
if ($result != false) {
return $result;
} else {
Stripe::getLogger()->error("Serializing telemetry payload failed!");
return "{}";
}
}
/**
* @static
*
* @param ApiResource|bool|array|mixed $d
*
* @return ApiResource|array|string|mixed
*/
private static function _encodeObjects($d)
{
if ($d instanceof ApiResource) {
@ -44,13 +95,27 @@ class ApiRequestor
}
/**
* @param string $method
* @param string $url
* @param string $method
* @param string $url
* @param array|null $params
* @param array|null $headers
*
* @return array An array whose first element is an API response and second
* element is the API key used to make the request.
* @throws Error\Api
* @throws Error\Authentication
* @throws Error\Card
* @throws Error\InvalidRequest
* @throws Error\OAuth\InvalidClient
* @throws Error\OAuth\InvalidGrant
* @throws Error\OAuth\InvalidRequest
* @throws Error\OAuth\InvalidScope
* @throws Error\OAuth\UnsupportedGrantType
* @throws Error\OAuth\UnsupportedResponseType
* @throws Error\Permission
* @throws Error\RateLimit
* @throws Error\Idempotency
* @throws Error\ApiConnection
*/
public function request($method, $url, $params = null, $headers = null)
{
@ -70,13 +135,22 @@ class ApiRequestor
* @param array $resp
*
* @throws Error\InvalidRequest if the error is caused by the user.
* @throws Error\Idempotency if the error is caused by an idempotency key.
* @throws Error\Authentication if the error is caused by a lack of
* permissions.
* @throws Error\Permission if the error is caused by insufficient
* permissions.
* @throws Error\Card if the error is the error code is 402 (payment
* required)
* @throws Error\InvalidRequest if the error is caused by the user.
* @throws Error\Idempotency if the error is caused by an idempotency key.
* @throws Error\OAuth\InvalidClient
* @throws Error\OAuth\InvalidGrant
* @throws Error\OAuth\InvalidRequest
* @throws Error\OAuth\InvalidScope
* @throws Error\OAuth\UnsupportedGrantType
* @throws Error\OAuth\UnsupportedResponseType
* @throws Error\Permission if the error is caused by insufficient
* permissions.
* @throws Error\RateLimit if the error is caused by too many requests
* hitting the API.
* @throws Error\Api otherwise.
@ -102,6 +176,17 @@ class ApiRequestor
throw $error;
}
/**
* @static
*
* @param string $rbody
* @param int $rcode
* @param array $rheaders
* @param array $resp
* @param array $errorData
*
* @return Error\RateLimit|Error\Idempotency|Error\InvalidRequest|Error\Authentication|Error\Card|Error\Permission|Error\Api
*/
private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData)
{
$msg = isset($errorData['message']) ? $errorData['message'] : null;
@ -136,6 +221,17 @@ class ApiRequestor
}
}
/**
* @static
*
* @param string|bool $rbody
* @param int $rcode
* @param array $rheaders
* @param array $resp
* @param string $errorCode
*
* @return null|Error\OAuth\InvalidClient|Error\OAuth\InvalidGrant|Error\OAuth\InvalidRequest|Error\OAuth\InvalidScope|Error\OAuth\UnsupportedGrantType|Error\OAuth\UnsupportedResponseType
*/
private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode)
{
$description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode;
@ -158,6 +254,13 @@ class ApiRequestor
return null;
}
/**
* @static
*
* @param null|array $appInfo
*
* @return null|string
*/
private static function _formatAppInfo($appInfo)
{
if ($appInfo !== null) {
@ -174,6 +277,14 @@ class ApiRequestor
}
}
/**
* @static
*
* @param string $apiKey
* @param null $clientInfo
*
* @return array
*/
private static function _defaultHeaders($apiKey, $clientInfo = null)
{
$uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION;
@ -205,6 +316,17 @@ class ApiRequestor
return $defaultHeaders;
}
/**
* @param string $method
* @param string $url
* @param array $params
* @param array $headers
*
* @return array
* @throws Error\Api
* @throws Error\ApiConnection
* @throws Error\Authentication
*/
private function _requestRaw($method, $url, $params, $headers)
{
$myApiKey = $this->_apiKey;
@ -239,6 +361,10 @@ class ApiRequestor
$defaultHeaders['Stripe-Account'] = Stripe::$accountId;
}
if (Stripe::$enableTelemetry && self::$requestTelemetry != null) {
$defaultHeaders["X-Stripe-Client-Telemetry"] = self::_telemetryJson(self::$requestTelemetry);
}
$hasFile = false;
$hasCurlFile = class_exists('\CURLFile', false);
foreach ($params as $k => $v) {
@ -263,6 +389,8 @@ class ApiRequestor
$rawHeaders[] = $header . ': ' . $value;
}
$requestStartMs = Util\Util::currentTimeMillis();
list($rbody, $rcode, $rheaders) = $this->httpClient()->request(
$method,
$absUrl,
@ -270,9 +398,24 @@ class ApiRequestor
$params,
$hasFile
);
if (array_key_exists('request-id', $rheaders)) {
self::$requestTelemetry = new RequestTelemetry(
$rheaders['request-id'],
Util\Util::currentTimeMillis() - $requestStartMs
);
}
return [$rbody, $rcode, $rheaders, $myApiKey];
}
/**
* @param resource $resource
* @param bool $hasCurlFile
*
* @return \CURLFile|string
* @throws Error\Api
*/
private function _processResourceParam($resource, $hasCurlFile)
{
if (get_resource_type($resource) !== 'stream') {
@ -296,6 +439,26 @@ class ApiRequestor
}
}
/**
* @param string $rbody
* @param int $rcode
* @param array $rheaders
*
* @return mixed
* @throws Error\Api
* @throws Error\Authentication
* @throws Error\Card
* @throws Error\InvalidRequest
* @throws Error\OAuth\InvalidClient
* @throws Error\OAuth\InvalidGrant
* @throws Error\OAuth\InvalidRequest
* @throws Error\OAuth\InvalidScope
* @throws Error\OAuth\UnsupportedGrantType
* @throws Error\OAuth\UnsupportedResponseType
* @throws Error\Permission
* @throws Error\RateLimit
* @throws Error\Idempotency
*/
private function _interpretResponse($rbody, $rcode, $rheaders)
{
$resp = json_decode($rbody, true);
@ -312,11 +475,29 @@ class ApiRequestor
return $resp;
}
/**
* @static
*
* @param HttpClient\ClientInterface $client
*/
public static function setHttpClient($client)
{
self::$_httpClient = $client;
}
/**
* @static
*
* Resets any stateful telemetry data
*/
public static function resetTelemetry()
{
self::$requestTelemetry = null;
}
/**
* @return HttpClient\ClientInterface
*/
private function httpClient()
{
if (!self::$_httpClient) {

View File

@ -66,30 +66,6 @@ abstract class ApiResource extends StripeObject
return $this;
}
/**
* @return string The name of the class, with namespacing and underscores
* stripped.
*/
public static function className()
{
$class = get_called_class();
// Useful for namespaces: Foo\Charge
if ($postfixNamespaces = strrchr($class, '\\')) {
$class = substr($postfixNamespaces, 1);
}
// Useful for underscored 'namespaces': Foo_Charge
if ($postfixFakeNamespaces = strrchr($class, '')) {
$class = $postfixFakeNamespaces;
}
if (substr($class, 0, strlen('Stripe')) == 'Stripe') {
$class = substr($class, strlen('Stripe'));
}
$class = str_replace('_', '', $class);
$name = urlencode($class);
$name = strtolower($name);
return $name;
}
/**
* @return string The base URL for the given class.
*/
@ -103,7 +79,9 @@ abstract class ApiResource extends StripeObject
*/
public static function classUrl()
{
$base = static::className();
// Replace dots with slashes for namespaced resources, e.g. if the object's name is
// "foo.bar", then its URL will be "/v1/foo/bars".
$base = str_replace('.', '/', static::OBJECT_NAME);
return "/v1/${base}s";
}

View File

@ -9,6 +9,9 @@ namespace Stripe;
*/
class ApplePayDomain extends ApiResource
{
const OBJECT_NAME = "apple_pay_domain";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;

View File

@ -24,23 +24,15 @@ namespace Stripe;
*/
class ApplicationFee extends ApiResource
{
const OBJECT_NAME = "application_fee";
use ApiOperations\All;
use ApiOperations\NestedResource;
use ApiOperations\Retrieve;
const PATH_REFUNDS = '/refunds';
/**
* This is a special case because the application fee endpoint has an
* underscore in it. The parent `className` function strips underscores.
*
* @return string The name of the class.
*/
public static function className()
{
return 'application_fee';
}
/**
* @param array|null $params
* @param array|string|null $opts
@ -55,7 +47,7 @@ class ApplicationFee extends ApiResource
}
/**
* @param array|null $id The ID of the application fee on which to create the refund.
* @param string|null $id The ID of the application fee on which to create the refund.
* @param array|null $params
* @param array|string|null $opts
*
@ -67,7 +59,7 @@ class ApplicationFee extends ApiResource
}
/**
* @param array|null $id The ID of the application fee to which the refund belongs.
* @param string|null $id The ID of the application fee to which the refund belongs.
* @param array|null $refundId The ID of the refund to retrieve.
* @param array|null $params
* @param array|string|null $opts
@ -80,7 +72,7 @@ class ApplicationFee extends ApiResource
}
/**
* @param array|null $id The ID of the application fee to which the refund belongs.
* @param string|null $id The ID of the application fee to which the refund belongs.
* @param array|null $refundId The ID of the refund to update.
* @param array|null $params
* @param array|string|null $opts
@ -93,11 +85,11 @@ class ApplicationFee extends ApiResource
}
/**
* @param array|null $id The ID of the application fee on which to retrieve the refunds.
* @param string|null $id The ID of the application fee on which to retrieve the refunds.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApplicationFeeRefund
* @return Collection The list of refunds.
*/
public static function allRefunds($id, $params = null, $opts = null)
{

View File

@ -18,6 +18,9 @@ namespace Stripe;
*/
class ApplicationFeeRefund extends ApiResource
{
const OBJECT_NAME = "fee_refund";
use ApiOperations\Update {
save as protected _save;
}

View File

@ -7,6 +7,7 @@ namespace Stripe;
*
* @property string $object
* @property array $available
* @property array $connect_reserved
* @property bool $livemode
* @property array $pending
*
@ -14,6 +15,9 @@ namespace Stripe;
*/
class Balance extends SingletonApiResource
{
const OBJECT_NAME = "balance";
/**
* @param array|string|null $opts
*

View File

@ -24,6 +24,9 @@ namespace Stripe;
*/
class BalanceTransaction extends ApiResource
{
const OBJECT_NAME = "balance_transaction";
use ApiOperations\All;
use ApiOperations\Retrieve;

View File

@ -25,6 +25,9 @@ namespace Stripe;
*/
class BankAccount extends ApiResource
{
const OBJECT_NAME = "bank_account";
use ApiOperations\Delete;
use ApiOperations\Update;

View File

@ -12,6 +12,9 @@ namespace Stripe;
*/
class BitcoinReceiver extends ApiResource
{
const OBJECT_NAME = "bitcoin_receiver";
use ApiOperations\All;
use ApiOperations\Retrieve;

View File

@ -10,4 +10,5 @@ namespace Stripe;
class BitcoinTransaction extends ApiResource
{
const OBJECT_NAME = "bitcoin_transaction";
}

View File

@ -7,6 +7,7 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property string $account
* @property string $address_city
* @property string $address_country
* @property string $address_line1
@ -15,10 +16,13 @@ namespace Stripe;
* @property string $address_state
* @property string $address_zip
* @property string $address_zip_check
* @property string[] $available_payout_methods
* @property string $brand
* @property string $country
* @property string $currency
* @property string $customer
* @property string $cvc_check
* @property bool $default_for_currency
* @property string $dynamic_last4
* @property int $exp_month
* @property int $exp_year
@ -27,15 +31,44 @@ namespace Stripe;
* @property string $last4
* @property StripeObject $metadata
* @property string $name
* @property string $recipient
* @property string $tokenization_method
*
* @package Stripe
*/
class Card extends ApiResource
{
const OBJECT_NAME = "card";
use ApiOperations\Delete;
use ApiOperations\Update;
/**
* Possible string representations of the CVC check status.
* @link https://stripe.com/docs/api/cards/object#card_object-cvc_check
*/
const CVC_CHECK_FAIL = 'fail';
const CVC_CHECK_PASS = 'pass';
const CVC_CHECK_UNAVAILABLE = 'unavailable';
const CVC_CHECK_UNCHECKED = 'unchecked';
/**
* Possible string representations of the funding of the card.
* @link https://stripe.com/docs/api/cards/object#card_object-funding
*/
const FUNDING_CREDIT = 'credit';
const FUNDING_DEBIT = 'debit';
const FUNDING_PREPAID = 'prepaid';
const FUNDING_UNKNOWN = 'unknown';
/**
* Possible string representations of the tokenization method when using Apple Pay or Google Pay.
* @link https://stripe.com/docs/api/cards/object#card_object-tokenization_method
*/
const TOKENIZATION_METHOD_APPLE_PAY = 'apple_pay';
const TOKENIZATION_METHOD_GOOGLE_PAY = 'google_pay';
/**
* @return string The instance URL for this resource. It needs to be special
* cased because cards are nested resources that may belong to different
@ -74,7 +107,7 @@ class Card extends ApiResource
{
$msg = "Cards cannot be accessed without a customer, recipient or account ID. " .
"Retrieve a card using \$customer->sources->retrieve('card_id'), " .
"\$recipient->cards->retrieve('card_id'), or";
"\$recipient->cards->retrieve('card_id'), or " .
"\$account->external_accounts->retrieve('card_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
@ -90,7 +123,7 @@ class Card extends ApiResource
{
$msg = "Cards cannot be accessed without a customer, recipient or account ID. " .
"Call save() on \$customer->sources->retrieve('card_id'), " .
"\$recipient->cards->retrieve('card_id'), or";
"\$recipient->cards->retrieve('card_id'), or " .
"\$account->external_accounts->retrieve('card_id') instead.";
throw new Error\InvalidRequest($msg, null);
}

View File

@ -29,8 +29,10 @@ namespace Stripe;
* @property string $order
* @property mixed $outcome
* @property bool $paid
* @property string $payment_intent
* @property string $receipt_email
* @property string $receipt_number
* @property string $receipt_url
* @property bool $refunded
* @property Collection $refunds
* @property string $review
@ -40,17 +42,77 @@ namespace Stripe;
* @property string $statement_descriptor
* @property string $status
* @property string $transfer
* @property mixed $transfer_data
* @property string $transfer_group
*
* @package Stripe
*/
class Charge extends ApiResource
{
const OBJECT_NAME = "charge";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of decline codes.
* These strings are applicable to the decline_code property of the \Stripe\Error\Card exception.
* @link https://stripe.com/docs/declines/codes
*/
const DECLINED_APPROVE_WITH_ID = 'approve_with_id';
const DECLINED_CALL_ISSUER = 'call_issuer';
const DECLINED_CARD_NOT_SUPPORTED = 'card_not_supported';
const DECLINED_CARD_VELOCITY_EXCEEDED = 'card_velocity_exceeded';
const DECLINED_CURRENCY_NOT_SUPPORTED = 'currency_not_supported';
const DECLINED_DO_NOT_HONOR = 'do_not_honor';
const DECLINED_DO_NOT_TRY_AGAIN = 'do_not_try_again';
const DECLINED_DUPLICATED_TRANSACTION = 'duplicate_transaction';
const DECLINED_EXPIRED_CARD = 'expired_card';
const DECLINED_FRAUDULENT = 'fraudulent';
const DECLINED_GENERIC_DECLINE = 'generic_decline';
const DECLINED_INCORRECT_NUMBER = 'incorrect_number';
const DECLINED_INCORRECT_CVC = 'incorrect_cvc';
const DECLINED_INCORRECT_PIN = 'incorrect_pin';
const DECLINED_INCORRECT_ZIP = 'incorrect_zip';
const DECLINED_INSUFFICIENT_FUNDS = 'insufficient_funds';
const DECLINED_INVALID_ACCOUNT = 'invalid_account';
const DECLINED_INVALID_AMOUNT = 'invalid_amount';
const DECLINED_INVALID_CVC = 'invalid_cvc';
const DECLINED_INVALID_EXPIRY_YEAR = 'invalid_expiry_year';
const DECLINED_INVALID_NUMBER = 'invalid_number';
const DECLINED_INVALID_PIN = 'invalid_pin';
const DECLINED_ISSUER_NOT_AVAILABLE = 'issuer_not_available';
const DECLINED_LOST_CARD = 'lost_card';
const DECLINED_NEW_ACCOUNT_INFORMATION_AVAILABLE = 'new_account_information_available';
const DECLINED_NO_ACTION_TAKEN = 'no_action_taken';
const DECLINED_NOT_PERMITTED = 'not_permitted';
const DECLINED_PICKUP_CARD = 'pickup_card';
const DECLINED_PIN_TRY_EXCEEDED = 'pin_try_exceeded';
const DECLINED_PROCESSING_ERROR = 'processing_error';
const DECLINED_REENTER_TRANSACTION = 'reenter_transaction';
const DECLINED_RESTRICTED_CARD = 'restricted_card';
const DECLINED_REVOCATION_OF_ALL_AUTHORIZATIONS = 'revocation_of_all_authorizations';
const DECLINED_REVOCATION_OF_AUTHORIZATION = 'revocation_of_authorization';
const DECLINED_SECURITY_VIOLATION = 'security_violation';
const DECLINED_SERVICE_NOT_ALLOWED = 'service_not_allowed';
const DECLINED_STOLEN_CARD = 'stolen_card';
const DECLINED_STOP_PAYMENT_ORDER = 'stop_payment_order';
const DECLINED_TESTMODE_DECLINE = 'testmode_decline';
const DECLINED_TRANSACTION_NOT_ALLOWED = 'transaction_not_allowed';
const DECLINED_TRY_AGAIN_LATER = 'try_again_later';
const DECLINED_WITHDRAWAL_COUNT_LIMIT_EXCEEDED = 'withdrawal_count_limit_exceeded';
/**
* Possible string representations of the status of the charge.
* @link https://stripe.com/docs/api/charges/object#charge_object-status
*/
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_SUCCEEDED = 'succeeded';
/**
* @param array|null $params
* @param array|string|null $options

View File

@ -0,0 +1,30 @@
<?php
namespace Stripe\Checkout;
/**
* Class Session
*
* @property string $id
* @property string $object
* @property string $cancel_url
* @property string $client_reference_id
* @property string $customer
* @property string $customer_email
* @property mixed $display_items
* @property bool $livemode
* @property string $payment_intent
* @property string[] $payment_method_types
* @property string $subscription
* @property string $success_url
*
* @package Stripe
*/
class Session extends \Stripe\ApiResource
{
const OBJECT_NAME = "checkout.session";
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;
}

View File

@ -12,8 +12,11 @@ namespace Stripe;
*
* @package Stripe
*/
class Collection extends StripeObject
class Collection extends StripeObject implements \IteratorAggregate
{
const OBJECT_NAME = "list";
use ApiOperations\Request;
protected $_requestParams = [];
@ -65,6 +68,15 @@ class Collection extends StripeObject
return Util\Util::convertToStripeObject($response, $opts);
}
/**
* @return \ArrayIterator An iterator that can be used to iterate
* across objects in the current page.
*/
public function getIterator()
{
return new \ArrayIterator($this->data);
}
/**
* @return Util\AutoPagingIterator An iterator that can be used to iterate
* across all objects across all pages. As page boundaries are

View File

@ -11,23 +11,16 @@ namespace Stripe;
* @property mixed $supported_bank_account_currencies
* @property string[] $supported_payment_currencies
* @property string[] $supported_payment_methods
* @property string[] $supported_transfer_countries
* @property mixed $verification_fields
*
* @package Stripe
*/
class CountrySpec extends ApiResource
{
const OBJECT_NAME = "country_spec";
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* This is a special case because the country specs endpoint has an
* underscore in it. The parent `className` function strips underscores.
*
* @return string The name of the class.
*/
public static function className()
{
return 'country_spec';
}
}

View File

@ -15,7 +15,8 @@ namespace Stripe;
* @property bool $livemode
* @property int $max_redemptions
* @property StripeObject $metadata
* @property int $percent_off
* @property string $name
* @property float $percent_off
* @property int $redeem_by
* @property int $times_redeemed
* @property bool $valid
@ -24,6 +25,9 @@ namespace Stripe;
*/
class Coupon extends ApiResource
{
const OBJECT_NAME = "coupon";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;

View File

@ -0,0 +1,73 @@
<?php
namespace Stripe;
/**
* Class CreditNote
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $created
* @property string $currency
* @property string $customer
* @property string $invoice
* @property bool $livemode
* @property string $memo
* @property StripeObject $metadata
* @property string $number
* @property string $pdf
* @property string $reason
* @property string $refund
* @property string $status
* @property string $type
*
* @package Stripe
*/
class CreditNote extends ApiResource
{
const OBJECT_NAME = "credit_note";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of the credit note reason.
* @link https://stripe.com/docs/api/credit_notes/object#credit_note_object-reason
*/
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_ORDER_CHANGE = 'order_change';
const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory';
/**
* Possible string representations of the credit note status.
* @link https://stripe.com/docs/api/credit_notes/object#credit_note_object-status
*/
const STATUS_ISSUED = 'issued';
const STATUS_VOID = 'void';
/**
* Possible string representations of the credit note type.
* @link https://stripe.com/docs/api/credit_notes/object#credit_note_object-status
*/
const TYPE_POST_PAYMENT = 'post_payment';
const TYPE_PRE_PAYMENT = 'pre_payment';
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return CreditNote The voided credit note.
*/
public function voidCreditNote($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/void';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -8,24 +8,33 @@ namespace Stripe;
* @property string $id
* @property string $object
* @property int $account_balance
* @property string $business_vat_id
* @property mixed $address
* @property string $created
* @property string $currency
* @property string $default_source
* @property bool $delinquent
* @property string $description
* @property mixed $discount
* @property Discount $discount
* @property string $email
* @property string $invoice_prefix
* @property mixed $invoice_settings
* @property bool $livemode
* @property StripeObject $metadata
* @property string $name
* @property string $phone
* @property string[] preferred_locales
* @property mixed $shipping
* @property Collection $sources
* @property Collection $subscriptions
* @property Collection $tax_ids
*
* @package Stripe
*/
class Customer extends ApiResource
{
const OBJECT_NAME = "customer";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
@ -33,6 +42,14 @@ class Customer extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of the customer's type of tax exemption.
* @link https://stripe.com/docs/api/customers/object#customer_object-tax_exempt
*/
const TAX_EXEMPT_NONE = 'none';
const TAX_EXEMPT_EXEMPT = 'exempt';
const TAX_EXEMPT_REVERSE = 'reverse';
public static function getSavedNestedResources()
{
static $savedNestedResources = null;
@ -45,6 +62,7 @@ class Customer extends ApiResource
}
const PATH_SOURCES = '/sources';
const PATH_TAX_IDS = '/tax_ids';
/**
* @param array|null $params
@ -135,7 +153,7 @@ class Customer extends ApiResource
}
/**
* @param array|null $id The ID of the customer on which to create the source.
* @param string|null $id The ID of the customer on which to create the source.
* @param array|null $params
* @param array|string|null $opts
*
@ -147,8 +165,8 @@ class Customer extends ApiResource
}
/**
* @param array|null $id The ID of the customer to which the source belongs.
* @param array|null $sourceId The ID of the source to retrieve.
* @param string|null $id The ID of the customer to which the source belongs.
* @param string|null $sourceId The ID of the source to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
@ -160,8 +178,8 @@ class Customer extends ApiResource
}
/**
* @param array|null $id The ID of the customer to which the source belongs.
* @param array|null $sourceId The ID of the source to update.
* @param string|null $id The ID of the customer to which the source belongs.
* @param string|null $sourceId The ID of the source to update.
* @param array|null $params
* @param array|string|null $opts
*
@ -173,8 +191,8 @@ class Customer extends ApiResource
}
/**
* @param array|null $id The ID of the customer to which the source belongs.
* @param array|null $sourceId The ID of the source to delete.
* @param string|null $id The ID of the customer to which the source belongs.
* @param string|null $sourceId The ID of the source to delete.
* @param array|null $params
* @param array|string|null $opts
*
@ -186,14 +204,64 @@ class Customer extends ApiResource
}
/**
* @param array|null $id The ID of the customer on which to retrieve the sources.
* @param string|null $id The ID of the customer on which to retrieve the sources.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
* @return Collection The list of sources.
*/
public static function allSources($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_SOURCES, $params, $opts);
}
/**
* @param string|null $id The ID of the customer on which to create the tax id.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function createTaxId($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_TAX_IDS, $params, $opts);
}
/**
* @param string|null $id The ID of the customer to which the tax id belongs.
* @param string|null $taxIdId The ID of the tax id to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function retrieveTaxId($id, $taxIdId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
}
/**
* @param string|null $id The ID of the customer to which the tax id belongs.
* @param string|null $taxIdId The ID of the tax id to delete.
* @param array|null $params
* @param array|string|null $opts
*
* @return ApiResource
*/
public static function deleteTaxId($id, $taxIdId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
}
/**
* @param string|null $id The ID of the customer on which to retrieve the tax ids.
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection The list of tax ids.
*/
public static function allTaxIds($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts);
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Stripe;
/**
* Class Discount
*
* @property string $object
* @property Coupon $coupon
* @property string $customer
* @property int $end
* @property int $start
* @property string $subscription
*
* @package Stripe
*/
class Discount extends StripeObject
{
const OBJECT_NAME = "discount";
}

View File

@ -8,7 +8,7 @@ namespace Stripe;
* @property string $id
* @property string $object
* @property int $amount
* @property mixed $balance_transactions
* @property BalanceTransaction[] $balance_transactions
* @property string $charge
* @property int $created
* @property string $currency
@ -24,6 +24,9 @@ namespace Stripe;
*/
class Dispute extends ApiResource
{
const OBJECT_NAME = "dispute";
use ApiOperations\All;
use ApiOperations\Retrieve;
use ApiOperations\Update;
@ -33,6 +36,7 @@ class Dispute extends ApiResource
* @link https://stripe.com/docs/api#dispute_object
*/
const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process';
const REASON_CHECK_RETURNED = 'check_returned';
const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed';
const REASON_CUSTOMER_INITIATED = 'customer_initiated';
const REASON_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';

View File

@ -17,22 +17,14 @@ namespace Stripe;
*/
class EphemeralKey extends ApiResource
{
const OBJECT_NAME = "ephemeral_key";
use ApiOperations\Create {
create as protected _create;
}
use ApiOperations\Delete;
/**
* This is a special case because the ephemeral key endpoint has an
* underscore in it. The parent `className` function strips underscores.
*
* @return string The name of the class.
*/
public static function className()
{
return 'ephemeral_key';
}
/**
* @param array|null $params
* @param array|string|null $opts

View File

@ -13,11 +13,11 @@ class OAuthBase extends \Stripe\Error\Base
$httpHeaders = null
) {
parent::__construct($description, $httpStatus, $httpBody, $jsonBody, $httpHeaders);
$this->code = $code;
$this->errorCode = $code;
}
public function getErrorCode()
{
return $this->code;
return $this->errorCode;
}
}

View File

@ -7,107 +7,152 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property string $account
* @property string $api_version
* @property int $created
* @property mixed $data
* @property bool $livemode
* @property int $pending_webhooks
* @property mixed $request
* @property int $created
* @property mixed $data
* @property bool $livemode
* @property int $pending_webhooks
* @property mixed $request
* @property string $type
*
* @package Stripe
*/
class Event extends ApiResource
{
/**
const OBJECT_NAME = "event";
/**
* Possible string representations of event types.
* @link https://stripe.com/docs/api#event_types
*/
const ACCOUNT_UPDATED = 'account.updated';
const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized';
const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created';
const ACCOUNT_EXTERNAL_ACCOUNT_DELETED = 'account.external_account.deleted';
const ACCOUNT_EXTERNAL_ACCOUNT_UPDATED = 'account.external_account.updated';
const APPLICATION_FEE_CREATED = 'application_fee.created';
const APPLICATION_FEE_REFUNDED = 'application_fee.refunded';
const APPLICATION_FEE_REFUND_UPDATED = 'application_fee.refund.updated';
const BALANCE_AVAILABLE = 'balance.available';
const CHARGE_CAPTURED = 'charge.captured';
const CHARGE_FAILED = 'charge.failed';
const CHARGE_PENDING = 'charge.pending';
const CHARGE_REFUNDED = 'charge.refunded';
const CHARGE_SUCCEEDED = 'charge.succeeded';
const CHARGE_UPDATED = 'charge.updated';
const CHARGE_DISPUTE_CLOSED = 'charge.dispute.closed';
const CHARGE_DISPUTE_CREATED = 'charge.dispute.created';
const CHARGE_DISPUTE_FUNDS_REINSTATED = 'charge.dispute.funds_reinstated';
const CHARGE_DISPUTE_FUNDS_WITHDRAWN = 'charge.dispute.funds_withdrawn';
const CHARGE_DISPUTE_UPDATED = 'charge.dispute.updated';
const CHARGE_REFUND_UPDATED = 'charge.refund.updated';
const COUPON_CREATED = 'coupon.created';
const COUPON_DELETED = 'coupon.deleted';
const COUPON_UPDATED = 'coupon.updated';
const CUSTOMER_CREATED = 'customer.created';
const CUSTOMER_DELETED = 'customer.deleted';
const CUSTOMER_UPDATED = 'customer.updated';
const CUSTOMER_DISCOUNT_CREATED = 'customer.discount.created';
const CUSTOMER_DISCOUNT_DELETED = 'customer.discount.deleted';
const CUSTOMER_DISCOUNT_UPDATED = 'customer.discount.updated';
const CUSTOMER_SOURCE_CREATED = 'customer.source.created';
const CUSTOMER_SOURCE_DELETED = 'customer.source.deleted';
const CUSTOMER_SOURCE_EXPIRING = 'customer.source.expiring';
const CUSTOMER_SOURCE_UPDATED = 'customer.source.updated';
const CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created';
const CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted';
const CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end';
const CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated';
const FILE_CREATED = 'file.created';
const INVOICE_CREATED = 'invoice.created';
const INVOICE_PAYMENT_FAILED = 'invoice.payment_failed';
const INVOICE_PAYMENT_SUCCEEDED = 'invoice.payment_succeeded';
const INVOICE_SENT = 'invoice.sent';
const INVOICE_UPCOMING = 'invoice.upcoming';
const INVOICE_UPDATED = 'invoice.updated';
const INVOICEITEM_CREATED = 'invoiceitem.created';
const INVOICEITEM_DELETED = 'invoiceitem.deleted';
const INVOICEITEM_UPDATED = 'invoiceitem.updated';
const ORDER_CREATED = 'order.created';
const ORDER_PAYMENT_FAILED = 'order.payment_failed';
const ORDER_PAYMENT_SUCCEEDED = 'order.payment_succeeded';
const ORDER_UPDATED = 'order.updated';
const ORDER_RETURN_CREATED = 'order_return.created';
const PAYOUT_CANCELED = 'payout.canceled';
const PAYOUT_CREATED = 'payout.created';
const PAYOUT_FAILED = 'payout.failed';
const PAYOUT_PAID = 'payout.paid';
const PAYOUT_UPDATED = 'payout.updated';
const PING = 'ping';
const PLAN_CREATED = 'plan.created';
const PLAN_DELETED = 'plan.deleted';
const PLAN_UPDATED = 'plan.updated';
const PRODUCT_CREATED = 'product.created';
const PRODUCT_DELETED = 'product.deleted';
const PRODUCT_UPDATED = 'product.updated';
const RECIPIENT_CREATED = 'recipient.created';
const RECIPIENT_DELETED = 'recipient.deleted';
const RECIPIENT_UPDATED = 'recipient.updated';
const REVIEW_CLOSED = 'review.closed';
const REVIEW_OPENED = 'review.opened';
const SIGMA_SCHEDULED_QUERY_RUN_CREATED = 'sigma.scheduled_query_run.created';
const SKU_CREATED = 'sku.created';
const SKU_DELETED = 'sku.deleted';
const SKU_UPDATED = 'sku.updated';
const SOURCE_CANCELED = 'source.canceled';
const SOURCE_CHARGEABLE = 'source.chargeable';
const SOURCE_FAILED = 'source.failed';
const SOURCE_MANDATE_NOTIFICATION = 'source.mandate_notification';
const SOURCE_TRANSACTION_CREATED = 'source.transaction.created';
const TOPUP_CREATED = 'topup.created';
const TOPUP_FAILED = 'topup.failed';
const TOPUP_SUCCEEDED = 'topup.succeeded';
const TRANSFER_CREATED = 'transfer.created';
const TRANSFER_REVERSED = 'transfer.reversed';
const TRANSFER_UPDATED = 'transfer.updated';
const ACCOUNT_UPDATED = 'account.updated';
const ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized';
const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized';
const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created';
const ACCOUNT_EXTERNAL_ACCOUNT_DELETED = 'account.external_account.deleted';
const ACCOUNT_EXTERNAL_ACCOUNT_UPDATED = 'account.external_account.updated';
const APPLICATION_FEE_CREATED = 'application_fee.created';
const APPLICATION_FEE_REFUNDED = 'application_fee.refunded';
const APPLICATION_FEE_REFUND_UPDATED = 'application_fee.refund.updated';
const BALANCE_AVAILABLE = 'balance.available';
const CHARGE_CAPTURED = 'charge.captured';
const CHARGE_EXPIRED = 'charge.expired';
const CHARGE_FAILED = 'charge.failed';
const CHARGE_PENDING = 'charge.pending';
const CHARGE_REFUNDED = 'charge.refunded';
const CHARGE_SUCCEEDED = 'charge.succeeded';
const CHARGE_UPDATED = 'charge.updated';
const CHARGE_DISPUTE_CLOSED = 'charge.dispute.closed';
const CHARGE_DISPUTE_CREATED = 'charge.dispute.created';
const CHARGE_DISPUTE_FUNDS_REINSTATED = 'charge.dispute.funds_reinstated';
const CHARGE_DISPUTE_FUNDS_WITHDRAWN = 'charge.dispute.funds_withdrawn';
const CHARGE_DISPUTE_UPDATED = 'charge.dispute.updated';
const CHARGE_REFUND_UPDATED = 'charge.refund.updated';
const COUPON_CREATED = 'coupon.created';
const COUPON_DELETED = 'coupon.deleted';
const COUPON_UPDATED = 'coupon.updated';
const CREDIT_NOTE_CREATED = 'credit_note.created';
const CREDIT_NOTE_UPDATED = 'credit_note.updated';
const CREDIT_NOTE_VOIDED = 'credit_note.voided';
const CUSTOMER_CREATED = 'customer.created';
const CUSTOMER_DELETED = 'customer.deleted';
const CUSTOMER_UPDATED = 'customer.updated';
const CUSTOMER_DISCOUNT_CREATED = 'customer.discount.created';
const CUSTOMER_DISCOUNT_DELETED = 'customer.discount.deleted';
const CUSTOMER_DISCOUNT_UPDATED = 'customer.discount.updated';
const CUSTOMER_SOURCE_CREATED = 'customer.source.created';
const CUSTOMER_SOURCE_DELETED = 'customer.source.deleted';
const CUSTOMER_SOURCE_EXPIRING = 'customer.source.expiring';
const CUSTOMER_SOURCE_UPDATED = 'customer.source.updated';
const CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created';
const CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted';
const CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end';
const CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated';
const FILE_CREATED = 'file.created';
const INVOICE_CREATED = 'invoice.created';
const INVOICE_DELETED = 'invoice.deleted';
const INVOICE_FINALIZED = 'invoice.finalized';
const INVOICE_MARKED_UNCOLLECTIBLE = 'invoice.marked_uncollectible';
const INVOICE_PAYMENT_FAILED = 'invoice.payment_failed';
const INVOICE_PAYMENT_SUCCEEDED = 'invoice.payment_succeeded';
const INVOICE_SENT = 'invoice.sent';
const INVOICE_UPCOMING = 'invoice.upcoming';
const INVOICE_UPDATED = 'invoice.updated';
const INVOICE_VOIDED = 'invoice.voided';
const INVOICEITEM_CREATED = 'invoiceitem.created';
const INVOICEITEM_DELETED = 'invoiceitem.deleted';
const INVOICEITEM_UPDATED = 'invoiceitem.updated';
const ISSUER_FRAUD_RECORD_CREATED = 'issuer_fraud_record.created';
const ISSUING_AUTHORIZATION_CREATED = 'issuing_authorization.created';
const ISSUING_AUTHORIZATION_UPDATED = 'issuing_authorization.updated';
const ISSUING_CARD_CREATED = 'issuing_card.created';
const ISSUING_CARD_UPDATED = 'issuing_card.updated';
const ISSUING_CARDHOLDER_CREATED = 'issuing_cardholder.created';
const ISSUING_CARDHOLDER_UPDATED = 'issuing_cardholder.updated';
const ISSUING_TRANSACTION_CREATED = 'issuing_transaction.created';
const ISSUING_TRANSACTION_UPDATED = 'issuing_transaction.updated';
const ORDER_CREATED = 'order.created';
const ORDER_PAYMENT_FAILED = 'order.payment_failed';
const ORDER_PAYMENT_SUCCEEDED = 'order.payment_succeeded';
const ORDER_UPDATED = 'order.updated';
const ORDER_RETURN_CREATED = 'order_return.created';
const PAYMENT_INTENT_AMOUNT_CAPTURABLE_UPDATED = 'payment_intent.amount_capturable_updated';
const PAYMENT_INTENT_CREATED = 'payment_intent.created';
const PAYMENT_INTENT_PAYMENT_FAILED = 'payment_intent.payment_failed';
const PAYMENT_INTENT_SUCCEEDED = 'payment_intent.succeeded';
const PAYOUT_CANCELED = 'payout.canceled';
const PAYOUT_CREATED = 'payout.created';
const PAYOUT_FAILED = 'payout.failed';
const PAYOUT_PAID = 'payout.paid';
const PAYOUT_UPDATED = 'payout.updated';
const PERSON_CREATED = 'person.created';
const PERSON_DELETED = 'person.deleted';
const PERSON_UPDATED = 'person.updated';
const PING = 'ping';
const PLAN_CREATED = 'plan.created';
const PLAN_DELETED = 'plan.deleted';
const PLAN_UPDATED = 'plan.updated';
const PRODUCT_CREATED = 'product.created';
const PRODUCT_DELETED = 'product.deleted';
const PRODUCT_UPDATED = 'product.updated';
const RECIPIENT_CREATED = 'recipient.created';
const RECIPIENT_DELETED = 'recipient.deleted';
const RECIPIENT_UPDATED = 'recipient.updated';
const REPORTING_REPORT_RUN_FAILED = 'reporting.report_run.failed';
const REPORTING_REPORT_RUN_SUCCEEDED = 'reporting.report_run.succeeded';
const REPORTING_REPORT_TYPE_UPDATED = 'reporting.report_type.updated';
const REVIEW_CLOSED = 'review.closed';
const REVIEW_OPENED = 'review.opened';
const SIGMA_SCHEDULED_QUERY_RUN_CREATED = 'sigma.scheduled_query_run.created';
const SKU_CREATED = 'sku.created';
const SKU_DELETED = 'sku.deleted';
const SKU_UPDATED = 'sku.updated';
const SOURCE_CANCELED = 'source.canceled';
const SOURCE_CHARGEABLE = 'source.chargeable';
const SOURCE_FAILED = 'source.failed';
const SOURCE_MANDATE_NOTIFICATION = 'source.mandate_notification';
const SOURCE_REFUND_ATTRIBUTES_REQUIRED = 'source.refund_attributes_required';
const SOURCE_TRANSACTION_CREATED = 'source.transaction.created';
const SOURCE_TRANSACTION_UPDATED = 'source.transaction.updated';
const SUBSCRIPTION_SCHEDULE_ABORTED = 'subscription_schedule.aborted';
const SUBSCRIPTION_SCHEDULE_CANCELED = 'subscription_schedule.canceled';
const SUBSCRIPTION_SCHEDULE_COMPLETED = 'subscription_schedule.completed';
const SUBSCRIPTION_SCHEDULE_CREATED = 'subscription_schedule.created';
const SUBSCRIPTION_SCHEDULE_EXPIRING = 'subscription_schedule.expiring';
const SUBSCRIPTION_SCHEDULE_RELEASED = 'subscription_schedule.released';
const SUBSCRIPTION_SCHEDULE_UPDATED = 'subscription_schedule.updated';
const TAX_RATE_CREATED = 'tax_rate.created';
const TAX_RATE_UPDATED = 'tax_rate.updated';
const TOPUP_CANCELED = 'topup.canceled';
const TOPUP_CREATED = 'topup.created';
const TOPUP_FAILED = 'topup.failed';
const TOPUP_REVERSED = 'topup.reversed';
const TOPUP_SUCCEEDED = 'topup.succeeded';
const TRANSFER_CREATED = 'transfer.created';
const TRANSFER_REVERSED = 'transfer.reversed';
const TRANSFER_UPDATED = 'transfer.updated';
use ApiOperations\All;
use ApiOperations\Retrieve;

View File

@ -9,17 +9,9 @@ namespace Stripe;
*/
class ExchangeRate extends ApiResource
{
const OBJECT_NAME = "exchange_rate";
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* This is a special case because the exchange rates endpoint has an
* underscore in it. The parent `className` function strips underscores.
*
* @return string The name of the class.
*/
public static function className()
{
return 'exchange_rate';
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace Stripe;
/**
* Class File
*
* @property string $id
* @property string $object
* @property int $created
* @property string $filename
* @property Collection $links
* @property string $purpose
* @property int $size
* @property string $title
* @property string $type
* @property string $url
*
* @package Stripe
*/
class File extends ApiResource
{
// 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
// `file_upload` object into the same class.
const OBJECT_NAME = "file";
const OBJECT_NAME_ALT = "file_upload";
use ApiOperations\All;
use ApiOperations\Create {
create as protected _create;
}
use ApiOperations\Retrieve;
public static function classUrl()
{
return '/v1/files';
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\File The created resource.
*/
public static function create($params = null, $options = null)
{
$opts = \Stripe\Util\RequestOptions::parse($options);
if (is_null($opts->apiBase)) {
$opts->apiBase = Stripe::$apiUploadBase;
}
// Manually flatten params, otherwise curl's multipart encoder will
// choke on nested arrays.
// TODO: use array_column() once we drop support for PHP 5.4
$flatParams = [];
foreach (\Stripe\Util\Util::flattenParams($params) as $pair) {
$flatParams[$pair[0]] = $pair[1];
}
return static::_create($flatParams, $opts);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Stripe;
/**
* Class FileLink
*
* @property string $id
* @property string $object
* @property int $created
* @property bool $expired
* @property int $expires_at
* @property string $file
* @property bool $livemode
* @property StripeObject $metadata
* @property string $url
*
* @package Stripe
*/
class FileLink extends ApiResource
{
const OBJECT_NAME = "file_link";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
}

View File

@ -2,31 +2,5 @@
namespace Stripe;
/**
* Class FileUpload
*
* @property string $id
* @property string $object
* @property int $created
* @property string $purpose
* @property int $size
* @property string $type
*
* @package Stripe
*/
class FileUpload extends ApiResource
{
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
public static function baseUrl()
{
return Stripe::$apiUploadBase;
}
public static function className()
{
return 'file';
}
}
// For backwards compatibility, the `File` class is aliased to `FileUpload`.
class_alias('Stripe\\File', 'Stripe\\FileUpload');

View File

@ -11,8 +11,11 @@ interface ClientInterface
* @param array $params KV pairs for parameters. Can be nested for arrays and hashes
* @param boolean $hasFile Whether or not $params references a file (via an @ prefix or
* CurlFile)
* @throws \Stripe\Error\Api & \Stripe\Error\ApiConnection
* @return [$rawBody, $httpStatusCode, $httpHeader]
*
* @throws \Stripe\Error\Api
* @throws \Stripe\Error\ApiConnection
* @return array An array whose first element is raw request body, second
* element is HTTP status code and third array of HTTP headers.
*/
public function request($method, $absUrl, $headers, $params, $hasFile);
}

View File

@ -22,6 +22,10 @@ if (!defined('CURL_SSLVERSION_TLSv1_2')) {
}
// @codingStandardsIgnoreEnd
if (!defined('CURL_HTTP_VERSION_2TLS')) {
define('CURL_HTTP_VERSION_2TLS', 4);
}
class CurlClient implements ClientInterface
{
private static $instance;
@ -38,6 +42,12 @@ class CurlClient implements ClientInterface
protected $userAgentInfo;
protected $enablePersistentConnections = null;
protected $enableHttp2 = null;
protected $curlHandle = null;
/**
* CurlClient constructor.
*
@ -56,6 +66,17 @@ class CurlClient implements ClientInterface
$this->defaultOptions = $defaultOptions;
$this->randomGenerator = $randomGenerator ?: new Util\RandomGenerator();
$this->initUserAgentInfo();
// TODO: curl_reset requires PHP >= 5.5.0. Once we drop support for PHP 5.4, we can simply
// initialize this to true.
$this->enablePersistentConnections = function_exists('curl_reset');
$this->enableHttp2 = $this->canSafelyUseHttp2();
}
public function __destruct()
{
$this->closeCurlHandle();
}
public function initUserAgentInfo()
@ -77,6 +98,38 @@ class CurlClient implements ClientInterface
return $this->userAgentInfo;
}
/**
* @return boolean
*/
public function getEnablePersistentConnections()
{
return $this->enablePersistentConnections;
}
/**
* @param boolean $enable
*/
public function setEnablePersistentConnections($enable)
{
$this->enablePersistentConnections = $enable;
}
/**
* @return boolean
*/
public function getEnableHttp2()
{
return $this->enableHttp2;
}
/**
* @param boolean $enable
*/
public function setEnableHttp2($enable)
{
$this->enableHttp2 = $enable;
}
// USER DEFINED TIMEOUTS
const DEFAULT_TIMEOUT = 80;
@ -123,6 +176,8 @@ class CurlClient implements ClientInterface
$opts = $this->defaultOptions;
}
$params = Util\Util::objectsToIds($params);
if ($method == 'get') {
if ($hasFile) {
throw new Error\Api(
@ -131,16 +186,16 @@ class CurlClient implements ClientInterface
}
$opts[CURLOPT_HTTPGET] = 1;
if (count($params) > 0) {
$encoded = Util\Util::urlEncode($params);
$encoded = Util\Util::encodeParameters($params);
$absUrl = "$absUrl?$encoded";
}
} elseif ($method == 'post') {
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::urlEncode($params);
$opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::encodeParameters($params);
} elseif ($method == 'delete') {
$opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
if (count($params) > 0) {
$encoded = Util\Util::urlEncode($params);
$encoded = Util\Util::encodeParameters($params);
$absUrl = "$absUrl?$encoded";
}
} else {
@ -150,13 +205,13 @@ class CurlClient implements ClientInterface
// It is only safe to retry network failures on POST requests if we
// add an Idempotency-Key header
if (($method == 'post') && (Stripe::$maxNetworkRetries > 0)) {
if (!isset($headers['Idempotency-Key'])) {
if (!$this->hasHeader($headers, "Idempotency-Key")) {
array_push($headers, 'Idempotency-Key: ' . $this->randomGenerator->uuid());
}
}
// Create a callback to capture HTTP headers for the response
$rheaders = [];
$rheaders = new Util\CaseInsensitiveArray();
$headerCallback = function ($curl, $header_line) use (&$rheaders) {
// Ignore the HTTP request line (HTTP/1.1 200 OK)
if (strpos($header_line, ":") === false) {
@ -193,6 +248,11 @@ class CurlClient implements ClientInterface
$opts[CURLOPT_SSL_VERIFYPEER] = false;
}
if (!isset($opts[CURLOPT_HTTP_VERSION]) && $this->getEnableHttp2()) {
// For HTTPS requests, enable HTTP/2, if supported
$opts[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2TLS;
}
list($rbody, $rcode) = $this->executeRequestWithRetries($opts, $absUrl);
return [$rbody, $rcode, $rheaders];
@ -209,17 +269,19 @@ class CurlClient implements ClientInterface
$rcode = 0;
$errno = 0;
$curl = curl_init();
curl_setopt_array($curl, $opts);
$rbody = curl_exec($curl);
$this->resetCurlHandle();
curl_setopt_array($this->curlHandle, $opts);
$rbody = curl_exec($this->curlHandle);
if ($rbody === false) {
$errno = curl_errno($curl);
$message = curl_error($curl);
$errno = curl_errno($this->curlHandle);
$message = curl_error($this->curlHandle);
} else {
$rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$rcode = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
}
if (!$this->getEnablePersistentConnections()) {
$this->closeCurlHandle();
}
curl_close($curl);
if ($this->shouldRetry($errno, $rcode, $numRetries)) {
$numRetries += 1;
@ -331,4 +393,68 @@ class CurlClient implements ClientInterface
return $sleepSeconds;
}
/**
* Initializes the curl handle. If already initialized, the handle is closed first.
*/
private function initCurlHandle()
{
$this->closeCurlHandle();
$this->curlHandle = curl_init();
}
/**
* Closes the curl handle if initialized. Do nothing if already closed.
*/
private function closeCurlHandle()
{
if (!is_null($this->curlHandle)) {
curl_close($this->curlHandle);
$this->curlHandle = null;
}
}
/**
* Resets the curl handle. If the handle is not already initialized, or if persistent
* connections are disabled, the handle is reinitialized instead.
*/
private function resetCurlHandle()
{
if (!is_null($this->curlHandle) && $this->getEnablePersistentConnections()) {
curl_reset($this->curlHandle);
} else {
$this->initCurlHandle();
}
}
/**
* Indicates whether it is safe to use HTTP/2 or not.
*
* @return boolean
*/
private function canSafelyUseHttp2()
{
// Versions of curl older than 7.60.0 don't respect GOAWAY frames
// (cf. https://github.com/curl/curl/issues/2416), which Stripe use.
$curlVersion = curl_version()['version'];
return (version_compare($curlVersion, '7.60.0') >= 0);
}
/**
* Checks if a list of headers contains a specific header name.
*
* @param string[] $headers
* @param string $name
* @return boolean
*/
private function hasHeader($headers, $name)
{
foreach ($headers as $header) {
if (strncasecmp($header, "{$name}: ", strlen($name) + 2) === 0) {
return true;
}
}
return false;
}
}

View File

@ -7,51 +7,161 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property string $account_country
* @property string $account_name
* @property int $amount_due
* @property int $amount_paid
* @property int $amount_remaining
* @property int $application_fee
* @property int $application_fee_amount
* @property int $attempt_count
* @property bool $attempted
* @property bool $auto_advance
* @property string $billing
* @property string $billing_reason
* @property string $charge
* @property bool $closed
* @property int $created
* @property string $currency
* @property array $custom_fields
* @property string $customer
* @property int $date
* @property mixed $customer_address
* @property string $customer_email
* @property string $customer_name
* @property string $customer_phone
* @property mixed $customer_shipping
* @property array $customer_tax_ids
* @property string $default_payment_method
* @property string $default_source
* @property array $default_tax_rates
* @property string $description
* @property mixed $discount
* @property Discount $discount
* @property int $due_date
* @property int $ending_balance
* @property bool $forgiven
* @property string $footer
* @property string $hosted_invoice_url
* @property string $invoice_pdf
* @property Collection $lines
* @property bool $livemode
* @property StripeObject $metadata
* @property int $next_payment_attempt
* @property string $number
* @property bool $paid
* @property string $payment_intent
* @property int $period_end
* @property int $period_start
* @property int $post_payment_credit_notes_amount
* @property int $pre_payment_credit_notes_amount
* @property string $receipt_number
* @property int $starting_balance
* @property string $statement_descriptor
* @property string $status
* @property mixed $status_transitions
* @property string $subscription
* @property int $subscription_proration_date
* @property int $subtotal
* @property int $tax
* @property float $tax_percent
* @property mixed $threshold_reason
* @property int $total
* @property array $total_tax_amounts
* @property int $webhooks_delivered_at
*
* @package Stripe
*/
class Invoice extends ApiResource
{
const OBJECT_NAME = "invoice";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of the invoice status.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-status
*/
const STATUS_DRAFT = 'draft';
const STATUS_OPEN = 'open';
const STATUS_PAID = 'paid';
const STATUS_UNCOLLECTIBLE = 'uncollectible';
const STATUS_VOID = 'void';
/**
* Possible string representations of the billing.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-billing
*/
const BILLING_SEND_INVOICE = 'send_invoice';
const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically';
/**
* Possible string representations of the billing reason.
* @link https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
*/
const BILLING_REASON_SUBSCRIPTION = 'subscription';
const BILLING_REASON_SUBSCRIPTION_CREATE = 'subscription_create';
const BILLING_REASON_SUBSCRIPTION_CYCLE = 'subscription_cycle';
const BILLING_REASON_SUBSCRIPTION_UPDATE = 'subscription_update';
const BILLING_REASON_SUBSCRIPTION_THRESHOLD = 'subscription_threshold';
const BILLING_REASON_MANUAL = 'manual';
const BILLING_REASON_UPCOMING = 'upcoming';
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Invoice The finalized invoice.
*/
public function finalizeInvoice($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/finalize';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Invoice The uncollectible invoice.
*/
public function markUncollectible($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/mark_uncollectible';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Invoice The paid invoice.
*/
public function pay($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/pay';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return Invoice The sent invoice.
*/
public function sendInvoice($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/send';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $opts
@ -68,11 +178,14 @@ class Invoice extends ApiResource
}
/**
* @return Invoice The paid invoice.
* @param array|null $params
* @param array|string|null $opts
*
* @return Invoice The voided invoice.
*/
public function pay($params = null, $opts = null)
public function voidInvoice($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/pay';
$url = $this->instanceUrl() . '/void';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;

View File

@ -22,11 +22,16 @@ namespace Stripe;
* @property int $quantity
* @property string $subscription
* @property string $subscription_item
* @property array $tax_rates
* @property int $unit_amount
*
* @package Stripe
*/
class InvoiceItem extends ApiResource
{
const OBJECT_NAME = "invoiceitem";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;

View File

@ -0,0 +1,32 @@
<?php
namespace Stripe;
/**
* Class InvoiceLineItem
*
* @property string $id
* @property string $object
* @property int $amount
* @property string $currency
* @property string $description
* @property bool $discountable
* @property string $invoice_item
* @property bool $livemode
* @property StripeObject $metadata
* @property mixed $period
* @property Plan $plan
* @property bool $proration
* @property int $quantity
* @property string $subscription
* @property string $subscription_item
* @property array $tax_amounts
* @property array $tax_rates
* @property string $type
*
* @package Stripe
*/
class InvoiceLineItem extends ApiResource
{
const OBJECT_NAME = "line_item";
}

View File

@ -0,0 +1,25 @@
<?php
namespace Stripe;
/**
* Class IssuerFraudRecord
*
* @property string $id
* @property string $object
* @property string $charge
* @property int $created
* @property int $post_date
* @property string $fraud_type
* @property bool $livemode
*
* @package Stripe
*/
class IssuerFraudRecord extends ApiResource
{
const OBJECT_NAME = "issuer_fraud_record";
use ApiOperations\All;
use ApiOperations\Retrieve;
}

View File

@ -0,0 +1,68 @@
<?php
namespace Stripe\Issuing;
/**
* Class Authorization
*
* @property string $id
* @property string $object
* @property bool $approved
* @property string $authorization_method
* @property int $authorized_amount
* @property string $authorized_currency
* @property \Stripe\Collection $balance_transactions
* @property Card $card
* @property Cardholder $cardholder
* @property int $created
* @property int $held_amount
* @property string $held_currency
* @property bool $is_held_amount_controllable
* @property bool $livemode
* @property mixed $merchant_data
* @property \Stripe\StripeObject $metadata
* @property int $pending_authorized_amount
* @property int $pending_held_amount
* @property mixed $request_history
* @property string $status
* @property \Stripe\Collection $transactions
* @property mixed $verification_data
*
* @package Stripe\Issuing
*/
class Authorization extends \Stripe\ApiResource
{
const OBJECT_NAME = "issuing.authorization";
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;
use \Stripe\ApiOperations\Update;
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Authorization The approved authorization.
*/
public function approve($params = null, $options = null)
{
$url = $this->instanceUrl() . '/approve';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Authorization The declined authorization.
*/
public function decline($params = null, $options = null)
{
$url = $this->instanceUrl() . '/decline';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Stripe\Issuing;
/**
* Class Card
*
* @property string $id
* @property string $object
* @property mixed $authorization_controls
* @property mixed $billing
* @property string $brand
* @property Cardholder $cardholder
* @property int $created
* @property string $currency
* @property int $exp_month
* @property int $exp_year
* @property string $last4
* @property bool $livemode
* @property \Stripe\StripeObject $metadata
* @property string $name
* @property mixed $shipping
* @property string $status
* @property string $type
*
* @package Stripe\Issuing
*/
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;
/**
* @param array|null $params
* @param array|string|null $options
*
* @return CardDetails The card details associated with that issuing card.
*/
public function details($params = null, $options = null)
{
$url = $this->instanceUrl() . '/details';
list($response, $opts) = $this->_request('get', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace Stripe\Issuing;
/**
* Class CardDetails
*
* @property string $id
* @property string $object
* @property Card $card
* @property string $cvc
* @property int $exp_month
* @property int $exp_year
* @property string $number
*
* @package Stripe\Issuing
*/
class CardDetails extends \Stripe\ApiResource
{
const OBJECT_NAME = "issuing.card_details";
}

View File

@ -0,0 +1,30 @@
<?php
namespace Stripe\Issuing;
/**
* Class Cardholder
*
* @property string $id
* @property string $object
* @property mixed $billing
* @property int $created
* @property string $email
* @property bool $livemode
* @property \Stripe\StripeObject $metadata
* @property string $name
* @property string $phone_number
* @property string $status
* @property string $type
*
* @package Stripe\Issuing
*/
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;
}

View File

@ -0,0 +1,30 @@
<?php
namespace Stripe\Issuing;
/**
* Class Dispute
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $created
* @property string $currency
* @property mixed $evidence
* @property bool $livemode
* @property \Stripe\StripeObject $metadata
* @property string $reason
* @property string $status
* @property Transaction $transaction
*
* @package Stripe\Issuing
*/
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;
}

View File

@ -0,0 +1,33 @@
<?php
namespace Stripe\Issuing;
/**
* Class Transaction
*
* @property string $id
* @property string $object
* @property int $amount
* @property string $authorization
* @property string $balance_transaction
* @property string $card
* @property string $cardholder
* @property int $created
* @property string $currency
* @property string $dispute
* @property bool $livemode
* @property mixed $merchant_data
* @property \Stripe\StripeObject $metadata
* @property string $type
*
* @package Stripe\Issuing
*/
class Transaction extends \Stripe\ApiResource
{
const OBJECT_NAME = "issuing.transaction";
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;
use \Stripe\ApiOperations\Update;
}

View File

@ -5,9 +5,14 @@ namespace Stripe;
/**
* Class LoginLink
*
* @property string $object
* @property int $created
* @property string $url
*
* @package Stripe
*/
class LoginLink extends ApiResource
{
const OBJECT_NAME = "login_link";
}

View File

@ -22,7 +22,7 @@ abstract class OAuth
if (!array_key_exists('response_type', $params)) {
$params['response_type'] = 'code';
}
$query = Util\Util::urlEncode($params);
$query = Util\Util::encodeParameters($params);
return $base . '/oauth/authorize?' . $query;
}

View File

@ -17,7 +17,7 @@ namespace Stripe;
* @property string $customer
* @property string $email
* @property string $external_coupon_code
* @property mixed $items
* @property OrderItem[] $items
* @property bool $livemode
* @property StripeObject $metadata
* @property Collection $returns
@ -33,6 +33,9 @@ namespace Stripe;
*/
class Order extends ApiResource
{
const OBJECT_NAME = "order";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;

View File

@ -0,0 +1,22 @@
<?php
namespace Stripe;
/**
* Class OrderItem
*
* @property string $object
* @property int $amount
* @property string $currency
* @property string $description
* @property string $parent
* @property int $quantity
* @property string $type
*
* @package Stripe
*/
class OrderItem extends StripeObject
{
const OBJECT_NAME = "order_item";
}

View File

@ -5,21 +5,23 @@ namespace Stripe;
/**
* Class OrderReturn
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $created
* @property string $currency
* @property OrderItem[] $items
* @property bool $livemode
* @property string $order
* @property string $refund
*
* @package Stripe
*/
class OrderReturn extends ApiResource
{
const OBJECT_NAME = "order_return";
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* This is a special case because the order returns endpoint has an
* underscore in it. The parent `className` function strips underscores.
*
* @return string The name of the class.
*/
public static function className()
{
return 'order_return';
}
}

View File

@ -0,0 +1,94 @@
<?php
namespace Stripe;
/**
* Class PaymentIntent
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $amount_capturable
* @property int $amount_received
* @property string $application
* @property int $application_fee_amount
* @property int $canceled_at
* @property string $cancellation_reason
* @property string $capture_method
* @property Collection $charges
* @property string $client_secret
* @property string $confirmation_method
* @property int $created
* @property string $currency
* @property string $customer
* @property string $description
* @property mixed $last_payment_error
* @property bool $livemode
* @property StripeObject $metadata
* @property mixed $next_action
* @property string $on_behalf_of
* @property string $payment_method
* @property string[] $payment_method_types
* @property string $receipt_email
* @property string $review
* @property mixed $shipping
* @property string $source
* @property string $statement_descriptor
* @property string $status
* @property mixed $transfer_data
* @property string $transfer_group
*
* @package Stripe
*/
class PaymentIntent extends ApiResource
{
const OBJECT_NAME = "payment_intent";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* @param array|null $params
* @param array|string|null $options
*
* @return PaymentIntent The canceled payment intent.
*/
public function cancel($params = null, $options = null)
{
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return PaymentIntent The captured payment intent.
*/
public function capture($params = null, $options = null)
{
$url = $this->instanceUrl() . '/capture';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return PaymentIntent The confirmed payment intent.
*/
public function confirm($params = null, $options = null)
{
$url = $this->instanceUrl() . '/confirm';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace Stripe;
/**
* Class PaymentMethod
*
* @property string $id
* @property string $object
* @property mixed $billing_details
* @property mixed $card
* @property mixed $card_present
* @property int $created
* @property string $customer
* @property mixed $ideal
* @property bool $livemode
* @property StripeObject $metadata
* @property mixed $sepa_debit
* @property string $type
*
* @package Stripe
*/
class PaymentMethod extends ApiResource
{
const OBJECT_NAME = "payment_method";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return PaymentMethod The attached payment method.
*/
public function attach($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/attach';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return PaymentMethod The detached payment method.
*/
public function detach($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/detach';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -8,18 +8,19 @@ namespace Stripe;
* @property string $id
* @property string $object
* @property int $amount
* @property int $arrival_date
* @property bool $automatic
* @property string $balance_transaction
* @property string $cancellation_balance_transaction
* @property int $created
* @property string $currency
* @property int $arrival_date
* @property string $description
* @property string $destination
* @property string $failure_balance_transaction
* @property string $failure_code
* @property string $failure_message
* @property bool $livemode
* @property StripeObject $metadata
* @property string $method
* @property string $recipient
* @property string $source_type
* @property string $statement_descriptor
* @property string $status
@ -29,11 +30,56 @@ namespace Stripe;
*/
class Payout extends ApiResource
{
const OBJECT_NAME = "payout";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Types of payout failure codes.
* @link https://stripe.com/docs/api#payout_failures
*/
const FAILURE_ACCOUNT_CLOSED = 'account_closed';
const FAILURE_ACCOUNT_FROZEN = 'account_frozen';
const FAILURE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted';
const FAILURE_BANK_OWNERSHIP_CHANGED = 'bank_ownership_changed';
const FAILURE_COULD_NOT_PROCESS = 'could_not_process';
const FAILURE_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';
const FAILURE_DECLINED = 'declined';
const FAILURE_INCORRECT_ACCOUNT_HOLDER_NAME = 'incorrect_account_holder_name';
const FAILURE_INSUFFICIENT_FUNDS = 'insufficient_funds';
const FAILURE_INVALID_ACCOUNT_NUMBER = 'invalid_account_number';
const FAILURE_INVALID_CURRENCY = 'invalid_currency';
const FAILURE_NO_ACCOUNT = 'no_account';
const FAILURE_UNSUPPORTED_CARD = 'unsupported_card';
/**
* Possible string representations of the payout methods.
* @link https://stripe.com/docs/api/payouts/object#payout_object-method
*/
const METHOD_STANDARD = 'standard';
const METHOD_INSTANT = 'instant';
/**
* Possible string representations of the status of the payout.
* @link https://stripe.com/docs/api/payouts/object#payout_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_IN_TRANSIT = 'in_transit';
const STATUS_FAILED = 'failed';
const STATUS_PAID = 'paid';
const STATUS_PENDING = 'pending';
/**
* Possible string representations of the type of payout.
* @link https://stripe.com/docs/api/payouts/object#payout_object-type
*/
const TYPE_BANK_ACCOUNT = 'bank_account';
const TYPE_CARD = 'card';
/**
* @return Payout The canceled payout.
*/

View File

@ -0,0 +1,108 @@
<?php
namespace Stripe;
/**
* Class Person
*
* @package Stripe
*
* @property string $id
* @property string $object
* @property string $account
* @property mixed $address
* @property mixed $address_kana
* @property mixed $address_kanji
* @property int $created
* @property bool $deleted
* @property mixed $dob
* @property string $email
* @property string $first_name
* @property string $first_name_kana
* @property string $first_name_kanji
* @property string $gender
* @property bool $id_number_provided
* @property string $last_name
* @property string $last_name_kana
* @property string $last_name_kanji
* @property string $maiden_name
* @property StripeObject $metadata
* @property string $phone
* @property mixed $relationship
* @property mixed $requirements
* @property bool $ssn_last_4_provided
* @property mixed $verification
*/
class Person extends ApiResource
{
const OBJECT_NAME = "person";
use ApiOperations\Delete;
use ApiOperations\Update;
/**
* Possible string representations of a person's gender.
* @link https://stripe.com/docs/api/persons/object#person_object-gender
*/
const GENDER_MALE = 'male';
const GENDER_FEMALE = 'female';
/**
* Possible string representations of a person's verification status.
* @link https://stripe.com/docs/api/persons/object#person_object-verification-status
*/
const VERIFICATION_STATUS_PENDING = 'pending';
const VERIFICATION_STATUS_UNVERIFIED = 'unverified';
const VERIFICATION_STATUS_VERIFIED = 'verified';
/**
* @return string The API URL for this Stripe account reversal.
*/
public function instanceUrl()
{
$id = $this['id'];
$account = $this['account'];
if (!$id) {
throw new Error\InvalidRequest(
"Could not determine which URL to request: " .
"class instance has invalid ID: $id",
null
);
}
$id = Util\Util::utf8($id);
$account = Util\Util::utf8($account);
$base = Account::classUrl();
$accountExtn = urlencode($account);
$extn = urlencode($id);
return "$base/$accountExtn/persons/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Persons cannot be accessed without an account ID. " .
"Retrieve a Person using \$account->retrievePerson('person_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param string $_id
* @param array|null $_params
* @param array|string|null $_options
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = "Persons cannot be accessed without an account ID. " .
"Retrieve a Person using \$account->retrievePerson('person_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
}

View File

@ -9,7 +9,10 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property bool $active
* @property string $aggregate_usage
* @property int $amount
* @property string $billing_scheme
* @property int $created
* @property string $currency
* @property string $interval
@ -18,10 +21,17 @@ namespace Stripe;
* @property StripeObject $metadata
* @property string $nickname
* @property string $product
* @property mixed $tiers
* @property string $tiers_mode
* @property mixed $transform_usage
* @property int $trial_period_days
* @property string $usage_type
*/
class Plan extends ApiResource
{
const OBJECT_NAME = "plan";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;

View File

@ -13,15 +13,15 @@ namespace Stripe;
* @property int $created
* @property string[] $deactivate_on
* @property string $description
* @property array $images
* @property string[] $images
* @property bool $livemode
* @property StripeObject $metadata
* @property string $name
* @property mixed $package_dimensions
* @property bool $shippable
* @property Collection $skus
* @property string $statement_descriptor
* @property string $type
* @property string $unit_label
* @property int $updated
* @property string $url
*
@ -29,9 +29,19 @@ namespace Stripe;
*/
class Product extends ApiResource
{
const OBJECT_NAME = "product";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of the type of product.
* @link https://stripe.com/docs/api/service_products/object#service_product_object-type
*/
const TYPE_GOOD = 'good';
const TYPE_SERVICE = 'service';
}

View File

@ -0,0 +1,32 @@
<?php
namespace Stripe\Radar;
/**
* Class ValueList
*
* @property string $id
* @property string $object
* @property string $alias
* @property int $created
* @property string $created_by
* @property string $item_type
* @property Collection $list_items
* @property bool $livemode
* @property StripeObject $metadata
* @property mixed $name
* @property int $updated
* @property string $updated_by
*
* @package Stripe\Radar
*/
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;
}

View File

@ -0,0 +1,26 @@
<?php
namespace Stripe\Radar;
/**
* Class ValueListItem
*
* @property string $id
* @property string $object
* @property int $created
* @property string $created_by
* @property string $list
* @property bool $livemode
* @property string $value
*
* @package Stripe\Radar
*/
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;
}

View File

@ -6,9 +6,27 @@ namespace Stripe;
* Class Recipient
*
* @package Stripe
*
* @property string $id
* @property string $object
* @property mixed $active_account
* @property Collection $cards
* @property int $created
* @property string $default_card
* @property string $description
* @property string $email
* @property bool $livemode
* @property StripeObject $metadata
* @property string $migrated_to
* @property string $name
* @property string $rolled_back_from
* @property string $type
*/
class Recipient extends ApiResource
{
const OBJECT_NAME = "recipient";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;

View File

@ -35,4 +35,5 @@ namespace Stripe;
class RecipientTransfer extends ApiResource
{
const OBJECT_NAME = "recipient_transfer";
}

View File

@ -12,19 +12,50 @@ namespace Stripe;
* @property string $charge
* @property int $created
* @property string $currency
* @property string $description
* @property string $failure_balance_transaction
* @property string failure_reason
* @property string $failure_reason
* @property StripeObject $metadata
* @property mixed $reason
* @property mixed $receipt_number
* @property string $reason
* @property string $receipt_number
* @property string $source_transfer_reversal
* @property string $status
* @property string $transfer_reversal
*
* @package Stripe
*/
class Refund extends ApiResource
{
const OBJECT_NAME = "refund";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of the failure reason.
* @link https://stripe.com/docs/api/refunds/object#refund_object-failure_reason
*/
const FAILURE_REASON = 'expired_or_canceled_card';
const FAILURE_REASON_LOST_OR_STOLEN_CARD = 'lost_or_stolen_card';
const FAILURE_REASON_UNKNOWN = 'unknown';
/**
* Possible string representations of the refund reason.
* @link https://stripe.com/docs/api/refunds/object#refund_object-reason
*/
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_REQUESTED_BY_CUSTOMER = 'requested_by_customer';
/**
* Possible string representations of the refund status.
* @link https://stripe.com/docs/api/refunds/object#refund_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_SUCCEEDED = 'succeeded';
}

View File

@ -0,0 +1,28 @@
<?php
namespace Stripe\Reporting;
/**
* Class ReportRun
*
* @property string $id
* @property string $object
* @property int $created
* @property string $error
* @property bool $livemode
* @property mixed $parameters
* @property string $report_type
* @property mixed $result
* @property string $status
* @property int $succeeded_at
*
* @package Stripe\Reporting
*/
class ReportRun extends \Stripe\ApiResource
{
const OBJECT_NAME = "reporting.report_run";
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;
}

View File

@ -0,0 +1,24 @@
<?php
namespace Stripe\Reporting;
/**
* Class ReportType
*
* @property string $id
* @property string $object
* @property int $data_available_end
* @property int $data_available_start
* @property string $name
* @property int $updated
* @property string $version
*
* @package Stripe\Reporting
*/
class ReportType extends \Stripe\ApiResource
{
const OBJECT_NAME = "reporting.report_type";
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;
}

View File

@ -0,0 +1,27 @@
<?php
namespace Stripe;
/**
* Class RequestTelemetry
*
* Tracks client request telemetry
* @package Stripe
*/
class RequestTelemetry
{
public $requestId;
public $requestDuration;
/**
* Initialize a new telemetry object.
*
* @param string $requestId The request's request ID.
* @param int $requestDuration The request's duration in milliseconds.
*/
public function __construct($requestId, $requestDuration)
{
$this->requestId = $requestId;
$this->requestDuration = $requestDuration;
}
}

View File

@ -0,0 +1,57 @@
<?php
namespace Stripe;
/**
* Class Review
*
* @property string $id
* @property string $object
* @property string $billing_zip
* @property string $charge
* @property string $closed_reason
* @property int $created
* @property string $ip_address
* @property mixed $ip_address_location
* @property bool $livemode
* @property bool $open
* @property string $opened_reason
* @property string $payment_intent
* @property string $reason
* @property mixed $session
*
* @package Stripe
*/
class Review extends ApiResource
{
const OBJECT_NAME = "review";
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* 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
* determine where these are apply.
* @link https://stripe.com/docs/api/radar/reviews/object
*/
const REASON_APPROVED = 'approved';
const REASON_DISPUTED = 'disputed';
const REASON_MANUAL = 'manual';
const REASON_REFUNDED = 'refunded';
const REASON_REFUNDED_AS_FRAUD = 'refunded_as_fraud';
const REASON_RULE = 'rule';
/**
* @param array|string|null $options
*
* @return Review The approved review.
*/
public function approve($params = null, $options = null)
{
$url = $this->instanceUrl() . '/approve';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -24,6 +24,9 @@ namespace Stripe;
*/
class SKU extends ApiResource
{
const OBJECT_NAME = "sku";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;

View File

@ -0,0 +1,33 @@
<?php
namespace Stripe\Sigma;
/**
* Class Authorization
*
* @property string $id
* @property string $object
* @property int $created
* @property int $data_load_time
* @property string $error
* @property \Stripe\FileUpload $file
* @property bool $livemode
* @property int $result_available_until
* @property string $sql
* @property string $status
* @property string $title
*
* @package Stripe\Sigma
*/
class ScheduledQueryRun extends \Stripe\ApiResource
{
const OBJECT_NAME = "scheduled_query_run";
use \Stripe\ApiOperations\All;
use \Stripe\ApiOperations\Retrieve;
public static function classUrl()
{
return "/v1/sigma/scheduled_query_runs";
}
}

View File

@ -22,7 +22,9 @@ abstract class SingletonApiResource extends ApiResource
*/
public static function classUrl()
{
$base = static::className();
// Replace dots with slashes for namespaced resources, e.g. if the object's name is
// "foo.bar", then its URL will be "/v1/foo/bar".
$base = str_replace('.', '/', static::OBJECT_NAME);
return "/v1/${base}";
}

View File

@ -7,30 +7,74 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property mixed $ach_credit_transfer
* @property mixed $ach_debit
* @property mixed $alipay
* @property int $amount
* @property mixed $bancontact
* @property mixed $card
* @property mixed $card_present
* @property string $client_secret
* @property mixed $code_verification
* @property int $created
* @property string $currency
* @property mixed $eps
* @property string $flow
* @property mixed $giropay
* @property mixed $ideal
* @property bool $livemode
* @property StripeObject $metadata
* @property mixed $multibanco
* @property mixed $owner
* @property mixed $p24
* @property mixed $receiver
* @property mixed $redirect
* @property mixed $sepa_debit
* @property mixed $sofort
* @property string $statement_descriptor
* @property string $status
* @property mixed $three_d_secure
* @property string $type
* @property string $usage
*
* @property mixed $wechat
* @package Stripe
*/
class Source extends ApiResource
{
const OBJECT_NAME = "source";
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of source flows.
* @link https://stripe.com/docs/api#source_object-flow
*/
const FLOW_REDIRECT = 'redirect';
const FLOW_RECEIVER = 'receiver';
const FLOW_CODE_VERIFICATION = 'code_verification';
const FLOW_NONE = 'none';
/**
* Possible string representations of source statuses.
* @link https://stripe.com/docs/api#source_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_CHARGEABLE = 'chargeable';
const STATUS_CONSUMED = 'consumed';
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
/**
* Possible string representations of source usage.
* @link https://stripe.com/docs/api#source_object-usage
*/
const USAGE_REUSABLE = 'reusable';
const USAGE_SINGLE_USE = 'single_use';
/**
* @param array|null $params
* @param array|string|null $options

View File

@ -5,9 +5,19 @@ namespace Stripe;
/**
* Class SourceTransaction
*
* @property string $id
* @property string $object
* @property int $amount
* @property int $created
* @property string $customer_data
* @property string $currency
* @property string $type
* @property mixed $ach_credit_transfer
*
* @package Stripe
*/
class SourceTransaction extends ApiResource
{
const OBJECT_NAME = "source_transaction";
}

View File

@ -22,7 +22,7 @@ class Stripe
public static $connectBase = 'https://connect.stripe.com';
// @var string The base URL for the Stripe API uploads endpoint.
public static $apiUploadBase = 'https://uploads.stripe.com';
public static $apiUploadBase = 'https://files.stripe.com';
// @var string|null The version of the Stripe API to use for requests.
public static $apiVersion = null;
@ -46,13 +46,16 @@ class Stripe
// @var int Maximum number of request retries
public static $maxNetworkRetries = 0;
// @var boolean Whether client telemetry is enabled. Defaults to false.
public static $enableTelemetry = false;
// @var float Maximum delay between retries, in seconds
private static $maxNetworkRetryDelay = 2.0;
// @var float Initial delay between retries, in seconds
private static $initialNetworkRetryDelay = 0.5;
const VERSION = '6.4.1';
const VERSION = '6.34.3';
/**
* @return string The API key used for requests.
@ -199,12 +202,13 @@ class Stripe
* @param string $appVersion The application's version
* @param string $appUrl The application's URL
*/
public static function setAppInfo($appName, $appVersion = null, $appUrl = null)
public static function setAppInfo($appName, $appVersion = null, $appUrl = null, $appPartnerId = null)
{
self::$appInfo = self::$appInfo ?: [];
self::$appInfo['name'] = $appName;
self::$appInfo['version'] = $appVersion;
self::$appInfo['partner_id'] = $appPartnerId;
self::$appInfo['url'] = $appUrl;
self::$appInfo['version'] = $appVersion;
}
/**
@ -238,4 +242,24 @@ class Stripe
{
return self::$initialNetworkRetryDelay;
}
/**
* @return bool Whether client telemetry is enabled
*/
public static function getEnableTelemetry()
{
return self::$enableTelemetry;
}
/**
* @param bool $enableTelemetry Enables client telemetry.
*
* Client telemetry enables timing and request metrics to be sent back to Stripe as an HTTP Header
* with the current request. This enables Stripe to do latency and metrics analysis without adding extra
* overhead (such as extra network calls) on the client.
*/
public static function setEnableTelemetry($enableTelemetry)
{
self::$enableTelemetry = $enableTelemetry;
}
}

View File

@ -32,6 +32,73 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable
return $permanentAttributes;
}
/**
* Additive objects are subobjects in the API that don't have the same
* semantics as most subobjects, which are fully replaced when they're set.
* This is best illustrated by example. The `source` parameter sent when
* updating a subscription is *not* additive; if we set it:
*
* source[object]=card&source[number]=123
*
* We expect the old `source` object to have been overwritten completely. If
* the previous source had an `address_state` key associated with it and we
* didn't send one this time, that value of `address_state` is gone.
*
* By contrast, additive objects are those that will have new data added to
* them while keeping any existing data in place. The only known case of its
* use is for `metadata`, but it could in theory be more general. As an
* example, say we have a `metadata` object that looks like this on the
* server side:
*
* metadata = ["old" => "old_value"]
*
* If we update the object with `metadata[new]=new_value`, the server side
* object now has *both* fields:
*
* metadata = ["old" => "old_value", "new" => "new_value"]
*
* This is okay in itself because usually users will want to treat it as
* additive:
*
* $obj->metadata["new"] = "new_value";
* $obj->save();
*
* However, in other cases, they may want to replace the entire existing
* contents:
*
* $obj->metadata = ["new" => "new_value"];
* $obj->save();
*
* This is where things get a little bit tricky because in order to clear
* any old keys that may have existed, we actually have to send an explicit
* empty string to the server. So the operation above would have to send
* this form to get the intended behavior:
*
* metadata[old]=&metadata[new]=new_value
*
* This method allows us to track which parameters are considered additive,
* and lets us behave correctly where appropriate when serializing
* parameters to be sent.
*
* @return Util\Set Set of additive parameters
*/
public static function getAdditiveParams()
{
static $additiveParams = null;
if ($additiveParams === null) {
// Set `metadata` as additive so that when it's set directly we remember
// to clear keys that may have been previously set by sending empty
// values for them.
//
// It's possible that not every object has `metadata`, but having this
// option set when there is no `metadata` field is not harmful.
$additiveParams = new Util\Set([
'metadata',
]);
}
return $additiveParams;
}
public function __construct($id = null, $opts = null)
{
list($id, $this->_retrieveOptions) = Util\Util::normalizeId($id);
@ -153,7 +220,7 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable
* @param array $values
* @param null|string|array|Util\RequestOptions $opts
*
* @return StripeObject The object constructed from the given values.
* @return static The object constructed from the given values.
*/
public static function constructFrom($values, $opts = null)
{
@ -213,7 +280,7 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable
// This is necessary in case metadata is empty, as PHP arrays do
// not differentiate between lists and hashes, and we consider
// empty arrays to be lists.
if ($k === "metadata") {
if (($k === "metadata") && (is_array($v))) {
$this->_values[$k] = StripeObject::constructFrom($v, $opts);
} else {
$this->_values[$k] = Util\Util::convertToStripeObject($v, $opts);
@ -323,7 +390,7 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable
}
} elseif ($value instanceof StripeObject) {
$update = $value->serializeParameters($force);
if ($original && $unsaved) {
if ($original && $unsaved && $key && static::getAdditiveParams()->includes($key)) {
$update = array_merge(self::emptyValues($original), $update);
}
return $update;
@ -432,12 +499,25 @@ class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable
}
/**
* @param ApiResponse
* Sets the last response from the Stripe API
*
* @return void Set the last response from the Stripe API
* @param ApiResponse $resp
* @return void
*/
public function setLastResponse($resp)
{
$this->_lastResponse = $resp;
}
/**
* Indicates whether or not the resource has been deleted on the server.
* Note that some, but not all, resources can indicate whether they have
* been deleted.
*
* @return bool Whether the resource is deleted.
*/
public function isDeleted()
{
return isset($this->_values['deleted']) ? $this->_values['deleted'] : false;
}
}

View File

@ -9,20 +9,27 @@ namespace Stripe;
* @property string $object
* @property float $application_fee_percent
* @property string $billing
* @property int $billing_cycle_anchor
* @property mixed $billing_thresholds
* @property bool $cancel_at_period_end
* @property int $canceled_at
* @property int $created
* @property int current_period_end
* @property int current_period_start
* @property int $current_period_end
* @property int $current_period_start
* @property string $customer
* @property int $days_until_due
* @property mixed $discount
* @property string $default_payment_method
* @property string $default_source
* @property array $default_tax_rates
* @property Discount $discount
* @property int $ended_at
* @property Collection $items
* @property string $latest_invoice
* @property boolean $livemode
* @property StripeObject $metadata
* @property Plan $plan
* @property int $quantity
* @property SubscriptionSchedule $schedule
* @property int $start
* @property string $status
* @property float $tax_percent
@ -33,6 +40,9 @@ namespace Stripe;
*/
class Subscription extends ApiResource
{
const OBJECT_NAME = "subscription";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete {
@ -46,11 +56,13 @@ class Subscription extends ApiResource
*
* @link https://stripe.com/docs/api#subscription_object-status
*/
const STATUS_ACTIVE = 'active';
const STATUS_CANCELED = 'canceled';
const STATUS_PAST_DUE = 'past_due';
const STATUS_TRIALING = 'trialing';
const STATUS_UNPAID = 'unpaid';
const STATUS_ACTIVE = 'active';
const STATUS_CANCELED = 'canceled';
const STATUS_PAST_DUE = 'past_due';
const STATUS_TRIALING = 'trialing';
const STATUS_UNPAID = 'unpaid';
const STATUS_INCOMPLETE = 'incomplete';
const STATUS_INCOMPLETE_EXPIRED = 'incomplete_expired';
public static function getSavedNestedResources()
{
@ -82,13 +94,4 @@ class Subscription extends ApiResource
list($response, $opts) = $this->_request('delete', $url);
$this->refreshFrom(['discount' => null], $opts, true);
}
public function serializeParameters($force = false)
{
$update = parent::serializeParameters($force);
if ($this->_unsavedValues->includes('items')) {
$update['items'] = $this->serializeParamsValue($this->items, null, true, $force, 'items');
}
return $update;
}
}

View File

@ -7,16 +7,21 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property mixed $billing_thresholds
* @property int $created
* @property StripeObject $metadata
* @property Plan $plan
* @property int $quantity
* @property string $subscription
* @property array $tax_rates
*
* @package Stripe
*/
class SubscriptionItem extends ApiResource
{
const OBJECT_NAME = "subscription_item";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
@ -24,13 +29,17 @@ class SubscriptionItem extends ApiResource
use ApiOperations\Update;
/**
* This is a special case because the subscription items endpoint has an
* underscore in it. The parent `className` function strips underscores.
* @param array|null $params
* @param array|string|null $options
*
* @return string The name of the class.
* @return Collection The list of source transactions.
*/
public static function className()
public function usageRecordSummaries($params = null, $options = null)
{
return 'subscription_item';
$url = $this->instanceUrl() . '/usage_record_summaries';
list($response, $opts) = $this->_request('get', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@ -0,0 +1,111 @@
<?php
namespace Stripe;
/**
* Class SubscriptionSchedule
*
* @property string $id
* @property string $object
* @property string $billing
* @property mixed $billing_thresholds
* @property int $canceled_at
* @property int $completed_at
* @property int $created
* @property mixed $current_phase
* @property string $customer
* @property mixed $invoice_settings
* @property boolean $livemode
* @property StripeObject $metadata
* @property mixed $phases
* @property int $released_at
* @property string $released_subscription
* @property string $renewal_behavior
* @property mixed $renewal_interval
* @property string $revision
* @property string $status
* @property string $subscription
*
* @package Stripe
*/
class SubscriptionSchedule extends ApiResource
{
const OBJECT_NAME = "subscription_schedule";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
use ApiOperations\NestedResource;
const PATH_REVISIONS = '/revisions';
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return SubscriptionSchedule The canceled subscription schedule.
*/
public function cancel($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return SubscriptionSchedule The released subscription schedule.
*/
public function release($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/release';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Collection The list of subscription schedule revisions.
*/
public function revisions($params = null, $options = null)
{
$url = $this->instanceUrl() . '/revisions';
list($response, $opts) = $this->_request('get', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param array|null $id The ID of the subscription schedule to which the person belongs.
* @param array|null $personId The ID of the person to retrieve.
* @param array|null $params
* @param array|string|null $opts
*
* @return Revision
*/
public static function retrieveRevision($id, $personId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_REVISIONS, $personId, $params, $opts);
}
/**
* @param array|null $id The ID of the subscription schedule on which to retrieve the persons.
* @param array|null $params
* @param array|string|null $opts
*
* @return Collection The list of revisions.
*/
public static function allRevisions($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_REVISIONS, $params, $opts);
}
}

View File

@ -0,0 +1,77 @@
<?php
namespace Stripe;
/**
* Class SubscriptionScheduleRevision
*
* @property string $id
* @property string $object
* @property int $created
* @property mixed $invoice_settings
* @property boolean $livemode
* @property mixed $phases
* @property string $previous_revision
* @property string $renewal_behavior
* @property mixed $renewal_interval
* @property string $schedule
*
* @package Stripe
*/
class SubscriptionScheduleRevision extends ApiResource
{
const OBJECT_NAME = "subscription_schedule_revision";
use ApiOperations\All;
use ApiOperations\Retrieve;
/**
* @return string The API URL for this Subscription Schedule Revision.
*/
public function instanceUrl()
{
$id = $this['id'];
$schedule = $this['schedule'];
if (!$id) {
throw new Error\InvalidRequest(
"Could not determine which URL to request: " .
"class instance has invalid ID: $id",
null
);
}
$id = Util\Util::utf8($id);
$schedule = Util\Util::utf8($schedule);
$base = SubscriptionSchedule::classUrl();
$scheduleExtn = urlencode($schedule);
$extn = urlencode($id);
return "$base/$scheduleExtn/revisions/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Subscription Schedule Revisions cannot be accessed without a Subscription Schedule ID. " .
"Retrieve one using \$schedule->retrieveRevision('revision_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function all($params = null, $opts = null)
{
$msg = "Subscription Schedule Revisions cannot be listed without a Subscription Schedule ID. " .
"List those using \$schedule->allRevisions('revision_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace Stripe;
/**
* Class TaxId
*
* @package Stripe
*
* @property string $id
* @property string $object
* @property string $country
* @property int $created
* @property string $customer
* @property bool $deleted
* @property bool $livemode
* @property string $type
* @property string $value
* @property mixed $verification
*/
class TaxId extends ApiResource
{
const OBJECT_NAME = "tax_id";
use ApiOperations\Delete;
/**
* Possible string representations of a tax id's type.
* @link https://stripe.com/docs/api/customers/tax_id_object#tax_id_object-type
*/
const TYPE_AU_ABN = 'au_abn';
const TYPE_EU_VAT = 'eu_vat';
const TYPE_NZ_GST = 'nz_gst';
const TYPE_UNKNOWN = 'unknown';
/**
* Possible string representations of the verification status.
* @link https://stripe.com/docs/api/customer_tax_ids/object#tax_id_object-verification
*/
const VERIFICATION_STATUS_PENDING = 'pending';
const VERIFICATION_STATUS_UNAVAILABLE = 'unavailable';
const VERIFICATION_STATUS_UNVERIFIED = 'unverified';
const VERIFICATION_STATUS_VERIFIED = 'verified';
/**
* @return string The API URL for this tax id.
*/
public function instanceUrl()
{
$id = $this['id'];
$customer = $this['customer'];
if (!$id) {
throw new Error\InvalidRequest(
"Could not determine which URL to request: class instance has invalid ID: $id",
null
);
}
$id = Util\Util::utf8($id);
$customer = Util\Util::utf8($customer);
$base = Customer::classUrl();
$customerExtn = urlencode($customer);
$extn = urlencode($id);
return "$base/$customerExtn/tax_ids/$extn";
}
/**
* @param array|string $_id
* @param array|string|null $_opts
*
* @throws \Stripe\Error\InvalidRequest
*/
public static function retrieve($_id, $_opts = null)
{
$msg = "Tax Ids cannot be accessed without a customer ID. " .
"Retrieve a Tax Id using Customer::retrieveTaxId('tax_id') instead.";
throw new Error\InvalidRequest($msg, null);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Stripe;
/**
* Class TaxRate
*
* @property string $id
* @property string $object
* @property bool $active
* @property int $created
* @property string $description
* @property string $display_name
* @property bool $inclusive
* @property string $jurisdiction
* @property bool $livemode
* @property StripeObject $metadata
* @property float $percentage
*
* @package Stripe
*/
class TaxRate extends ApiResource
{
const OBJECT_NAME = "tax_rate";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
}

View File

@ -0,0 +1,17 @@
<?php
namespace Stripe\Terminal;
/**
* Class ConnectionToken
*
* @property string $secret
*
* @package Stripe\Terminal
*/
class ConnectionToken extends \Stripe\ApiResource
{
const OBJECT_NAME = "terminal.connection_token";
use \Stripe\ApiOperations\Create;
}

View File

@ -0,0 +1,25 @@
<?php
namespace Stripe\Terminal;
/**
* Class Location
*
* @property string $id
* @property string $object
* @property mixed $address
* @property bool $deleted
* @property string $display_name
*
* @package Stripe\Terminal
*/
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;
}

View File

@ -0,0 +1,30 @@
<?php
namespace Stripe\Terminal;
/**
* Class Reader
*
* @property string $id
* @property string $object
* @property bool $deleted
* @property string $device_sw_version
* @property string $device_type
* @property string $ip_address
* @property string $label
* @property string $location
* @property string $serial_number
* @property string $status
*
* @package Stripe\Terminal
*/
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;
}

View File

@ -4,6 +4,9 @@ namespace Stripe;
class ThreeDSecure extends ApiResource
{
const OBJECT_NAME = "three_d_secure";
use ApiOperations\Create;
use ApiOperations\Retrieve;

View File

@ -7,8 +7,8 @@ namespace Stripe;
*
* @property string $id
* @property string $object
* @property mixed $bank_account
* @property mixed $card
* @property BankAccount $bank_account
* @property Card $card
* @property string $client_ip
* @property int $created
* @property bool $livemode
@ -19,6 +19,18 @@ namespace Stripe;
*/
class Token extends ApiResource
{
const OBJECT_NAME = "token";
use ApiOperations\Create;
use ApiOperations\Retrieve;
/**
* Possible string representations of the token type.
* @link https://stripe.com/docs/api/tokens/object#token_object-type
*/
const TYPE_ACCOUNT = 'account';
const TYPE_BANK_ACCOUNT = 'bank_account';
const TYPE_CARD = 'card';
const TYPE_PII = 'pii';
}

View File

@ -20,13 +20,41 @@ namespace Stripe;
* @property mixed $source
* @property string $statement_descriptor
* @property string $status
* @property string $transfer_group
*
* @package Stripe
*/
class Topup extends ApiResource
{
const OBJECT_NAME = "topup";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Retrieve;
use ApiOperations\Update;
/**
* Possible string representations of the status of the top-up.
* @link https://stripe.com/docs/api/topups/object#topup_object-status
*/
const STATUS_CANCELED = 'canceled';
const STATUS_FAILED = 'failed';
const STATUS_PENDING = 'pending';
const STATUS_REVERSED = 'reversed';
const STATUS_SUCCEEDED = 'succeeded';
/**
* @param array|null $params
* @param array|string|null $options
*
* @return Topup The canceled topup.
*/
public function cancel($params = null, $options = null)
{
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $options);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@ -12,6 +12,7 @@ namespace Stripe;
* @property string $balance_transaction
* @property int $created
* @property string $currency
* @property string $description
* @property string $destination
* @property string $destination_payment
* @property bool $livemode
@ -26,6 +27,9 @@ namespace Stripe;
*/
class Transfer extends ApiResource
{
const OBJECT_NAME = "transfer";
use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\NestedResource;
@ -34,6 +38,15 @@ class Transfer extends ApiResource
const PATH_REVERSALS = '/reversals';
/**
* Possible string representations of the source type of the transfer.
* @link https://stripe.com/docs/api/transfers/object#transfer_object-source_type
*/
const SOURCE_TYPE_ALIPAY_ACCOUNT = 'alipay_account';
const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account';
const SOURCE_TYPE_CARD = 'card';
const SOURCE_TYPE_FINANCING = 'financing';
/**
* @return TransferReversal The created transfer reversal.
*/
@ -57,7 +70,7 @@ class Transfer extends ApiResource
}
/**
* @param array|null $id The ID of the transfer on which to create the reversal.
* @param string|null $id The ID of the transfer on which to create the reversal.
* @param array|null $params
* @param array|string|null $opts
*
@ -69,7 +82,7 @@ class Transfer extends ApiResource
}
/**
* @param array|null $id The ID of the transfer to which the reversal belongs.
* @param string|null $id The ID of the transfer to which the reversal belongs.
* @param array|null $reversalId The ID of the reversal to retrieve.
* @param array|null $params
* @param array|string|null $opts
@ -82,7 +95,7 @@ class Transfer extends ApiResource
}
/**
* @param array|null $id The ID of the transfer to which the reversal belongs.
* @param string|null $id The ID of the transfer to which the reversal belongs.
* @param array|null $reversalId The ID of the reversal to update.
* @param array|null $params
* @param array|string|null $opts
@ -95,11 +108,11 @@ class Transfer extends ApiResource
}
/**
* @param array|null $id The ID of the transfer on which to retrieve the reversals.
* @param string|null $id The ID of the transfer on which to retrieve the reversals.
* @param array|null $params
* @param array|string|null $opts
*
* @return TransferReversal
* @return Collection The list of reversals.
*/
public static function allReversals($id, $params = null, $opts = null)
{

View File

@ -11,13 +11,18 @@ namespace Stripe;
* @property string $balance_transaction
* @property int $created
* @property string $currency
* @property string $destination_payment_refund
* @property StripeObject $metadata
* @property string $source_refund
* @property string $transfer
*
* @package Stripe
*/
class TransferReversal extends ApiResource
{
const OBJECT_NAME = "transfer_reversal";
use ApiOperations\Update {
save as protected _save;
}

View File

@ -0,0 +1,44 @@
<?php
namespace Stripe;
/**
* Class UsageRecord
*
* @package Stripe
*
* @property string $id
* @property string $object
* @property bool $livemode
* @property int $quantity
* @property string $subscription_item
* @property int $timestamp
*/
class UsageRecord extends ApiResource
{
const OBJECT_NAME = "usage_record";
/**
* @param array|null $params
* @param array|string|null $options
*
* @return \Stripe\ApiResource The created resource.
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
if (!array_key_exists('subscription_item', $params)) {
throw new Error\InvalidRequest("Missing subscription_item param in request", null);
}
$subscription_item = $params['subscription_item'];
$url = "/v1/subscription_items/$subscription_item/usage_records";
$request_params = $params;
unset($request_params['subscription_item']);
list($response, $opts) = static::_staticRequest('post', $url, $request_params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Stripe;
/**
* Class UsageRecord
*
* @package Stripe
*
* @property string $id
* @property string $object
* @property string $invoice
* @property bool $livemode
* @property mixed $period
* @property string $subscription_item
* @property int $total_usage
*/
class UsageRecordSummary extends ApiResource
{
const OBJECT_NAME = "usage_record_summary";
}

View File

@ -0,0 +1,62 @@
<?php
namespace Stripe\Util;
use ArrayAccess;
/**
* CaseInsensitiveArray is an array-like class that ignores case for keys.
*
* It is used to store HTTP headers. Per RFC 2616, section 4.2:
* Each header field consists of a name followed by a colon (":") and the field value. Field names
* are case-insensitive.
*
* In the context of stripe-php, this is useful because the API will return headers with different
* case depending on whether HTTP/2 is used or not (with HTTP/2, headers are always in lowercase).
*/
class CaseInsensitiveArray implements ArrayAccess
{
private $container = array();
public function __construct($initial_array = array())
{
$this->container = array_map("strtolower", $initial_array);
}
public function offsetSet($offset, $value)
{
$offset = static::maybeLowercase($offset);
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
public function offsetExists($offset)
{
$offset = static::maybeLowercase($offset);
return isset($this->container[$offset]);
}
public function offsetUnset($offset)
{
$offset = static::maybeLowercase($offset);
unset($this->container[$offset]);
}
public function offsetGet($offset)
{
$offset = static::maybeLowercase($offset);
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
private static function maybeLowercase($v)
{
if (is_string($v)) {
return strtolower($v);
} else {
return $v;
}
}
}

Some files were not shown because too many files have changed in this diff Show More