Merge pull request #8279 from ptibogxiv/develop
New add a stripeconnect mode + add webhook key
This commit is contained in:
commit
913be91ac7
@ -181,8 +181,8 @@ function societe_prepare_head(Societe $object)
|
||||
$langs->load("banks");
|
||||
|
||||
$nbBankAccount=0;
|
||||
$head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("BankAccounts");
|
||||
$head[$h][0] = DOL_URL_ROOT .'/societe/gateway.php?socid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Gateways");
|
||||
$sql = "SELECT COUNT(n.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_rib as n";
|
||||
$sql.= " WHERE fk_soc = ".$object->id;
|
||||
@ -1707,3 +1707,5 @@ function show_subsidiaries($conf,$langs,$db,$object)
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
3
htdocs/includes/stripe/.gitignore
vendored
3
htdocs/includes/stripe/.gitignore
vendored
@ -12,3 +12,6 @@ composer.lock
|
||||
|
||||
# Ignore PHPUnit coverage file
|
||||
clover.xml
|
||||
|
||||
# Ignore IDE's configuration files
|
||||
.idea
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
sudo: false
|
||||
|
||||
language: php
|
||||
|
||||
php:
|
||||
@ -7,12 +9,33 @@ php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- hhvm
|
||||
|
||||
env:
|
||||
- AUTOLOAD=1
|
||||
- AUTOLOAD=0
|
||||
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
|
||||
sudo: false
|
||||
|
||||
@ -1,237 +1,315 @@
|
||||
### 4.7.0 2017-04-10
|
||||
# Changelog
|
||||
|
||||
## 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
|
||||
|
||||
## 6.4.0 - 2018-02-28
|
||||
* [#453](https://github.com/stripe/stripe-php/pull/453) Add constants for `reason` (`REASON_*`) and `status` (`STATUS_*`) on `\Stripe\Dispute`
|
||||
|
||||
## 6.3.2 - 2018-02-27
|
||||
* [#452](https://github.com/stripe/stripe-php/pull/452) Add PHPDoc for `amount_paid` and `amount_remaining` on `\Stripe\Invoice`
|
||||
|
||||
## 6.3.1 - 2018-02-26
|
||||
* [#443](https://github.com/stripe/stripe-php/pull/443) Add event types as constants to `\Stripe\Event` class
|
||||
|
||||
## 6.3.0 - 2018-02-23
|
||||
* [#450](https://github.com/stripe/stripe-php/pull/450) Add support for `code` attribute on all Stripe exceptions
|
||||
|
||||
## 6.2.0 - 2018-02-21
|
||||
* [#440](https://github.com/stripe/stripe-php/pull/440) Add support for topups
|
||||
* [#442](https://github.com/stripe/stripe-php/pull/442) Fix PHPDoc for `\Stripe\Error\SignatureVerification`
|
||||
|
||||
## 6.1.0 - 2018-02-12
|
||||
* [#435](https://github.com/stripe/stripe-php/pull/435) Fix header persistence on `Collection` objects
|
||||
* [#436](https://github.com/stripe/stripe-php/pull/436) Introduce new `Idempotency` error class
|
||||
|
||||
## 6.0.0 - 2018-02-07
|
||||
Major version release. List of backwards incompatible changes to watch out for:
|
||||
+ The minimum PHP version is now 5.4.0. If you're using PHP 5.3 or older, consider upgrading to a more recent version.
|
||||
* `\Stripe\AttachedObject` no longer exists. Attributes that used to be instances of `\Stripe\AttachedObject` (such as `metadata`) are now instances of `\Stripe\StripeObject`.
|
||||
+ Attributes that used to be PHP arrays (such as `legal_entity->additional_owners` on `\Stripe\Account` instances) are now instances of `\Stripe\StripeObject`, except when they are empty. `\Stripe\StripeObject` has array semantics so this should not be an issue unless you are actively checking types.
|
||||
* `\Stripe\Collection` now derives from `\Stripe\StripeObject` rather than from `\Stripe\ApiResource`.
|
||||
|
||||
Pull requests included in this release:
|
||||
* [#410](https://github.com/stripe/stripe-php/pull/410) Drop support for PHP 5.3
|
||||
* [#411](https://github.com/stripe/stripe-php/pull/411) Use traits for common API operations
|
||||
* [#414](https://github.com/stripe/stripe-php/pull/414) Use short array syntax
|
||||
* [#404](https://github.com/stripe/stripe-php/pull/404) Fix serialization logic
|
||||
* [#417](https://github.com/stripe/stripe-php/pull/417) Remove `ExternalAccount` class
|
||||
* [#418](https://github.com/stripe/stripe-php/pull/418) Increase test coverage
|
||||
* [#421](https://github.com/stripe/stripe-php/pull/421) Update CA bundle and add script for future updates
|
||||
* [#422](https://github.com/stripe/stripe-php/pull/422) Use vendored CA bundle for all requests
|
||||
* [#428](https://github.com/stripe/stripe-php/pull/428) Support for automatic request retries
|
||||
|
||||
## 5.9.2 - 2018-02-07
|
||||
* [#431](https://github.com/stripe/stripe-php/pull/431) Update PHPDoc @property tags for latest API version
|
||||
|
||||
## 5.9.1 - 2018-02-06
|
||||
* [#427](https://github.com/stripe/stripe-php/pull/427) Add and update PHPDoc @property tags on all API resources
|
||||
|
||||
## 5.9.0 - 2018-01-17
|
||||
* [#421](https://github.com/stripe/stripe-php/pull/421) Updated bundled CA certificates
|
||||
* [#423](https://github.com/stripe/stripe-php/pull/423) Escape unsanitized input in OAuth example
|
||||
|
||||
## 5.8.0 - 2017-12-20
|
||||
* [#403](https://github.com/stripe/stripe-php/pull/403) Add `__debugInfo()` magic method to `StripeObject`
|
||||
|
||||
## 5.7.0 - 2017-11-28
|
||||
* [#390](https://github.com/stripe/stripe-php/pull/390) Remove some unsupported API methods
|
||||
* [#391](https://github.com/stripe/stripe-php/pull/391) Alphabetize the list of API resources in `Util::convertToStripeObject()` and add missing resources
|
||||
* [#393](https://github.com/stripe/stripe-php/pull/393) Fix expiry date update for card sources
|
||||
|
||||
## 5.6.0 - 2017-10-31
|
||||
* [#386](https://github.com/stripe/stripe-php/pull/386) Support for exchange rates APIs
|
||||
|
||||
## 5.5.1 - 2017-10-30
|
||||
* [#387](https://github.com/stripe/stripe-php/pull/387) Allow `personal_address_kana` and `personal_address_kanji` to be updated on an account
|
||||
|
||||
## 5.5.0 - 2017-10-27
|
||||
* [#385](https://github.com/stripe/stripe-php/pull/385) Support for listing source transactions
|
||||
|
||||
## 5.4.0 - 2017-10-24
|
||||
* [#383](https://github.com/stripe/stripe-php/pull/383) Add static methods to manipulate resources from parent
|
||||
* `Account` gains methods for external accounts and login links (e.g. `createExternalAccount`, `createLoginLink`)
|
||||
* `ApplicationFee` gains methods for refunds
|
||||
* `Customer` gains methods for sources
|
||||
* `Transfer` gains methods for reversals
|
||||
|
||||
## 5.3.0 - 2017-10-11
|
||||
* [#378](https://github.com/stripe/stripe-php/pull/378) Rename source `delete` to `detach` (and deprecate the former)
|
||||
|
||||
## 5.2.3 - 2017-09-27
|
||||
* Add PHPDoc for `Card`
|
||||
|
||||
## 5.2.2 - 2017-09-20
|
||||
* Fix deserialization mapping of `FileUpload` objects
|
||||
|
||||
## 5.2.1 - 2017-09-14
|
||||
* Serialized `shipping` nested attribute
|
||||
|
||||
## 5.2.0 - 2017-08-29
|
||||
* Add support for `InvalidClient` OAuth error
|
||||
|
||||
## 5.1.3 - 2017-08-14
|
||||
* Allow `address_kana` and `address_kanji` to be updated for custom accounts
|
||||
|
||||
## 5.1.2 - 2017-08-01
|
||||
* Fix documented return type of `autoPagingIterator()` (was missing namespace)
|
||||
|
||||
## 5.1.1 - 2017-07-03
|
||||
* Fix order returns to use the right URL `/v1/order_returns`
|
||||
|
||||
## 5.1.0 - 2017-06-30
|
||||
* Add support for OAuth
|
||||
|
||||
## 5.0.0 - 2017-06-27
|
||||
* `pay` on invoice now takes params as well as opts
|
||||
|
||||
## 4.13.0 - 2017-06-19
|
||||
* Add support for ephemeral keys
|
||||
|
||||
## 4.12.0 - 2017-06-05
|
||||
* Clients can implement `getUserAgentInfo()` to add additional user agent information
|
||||
|
||||
## 4.11.0 - 2017-06-05
|
||||
* Implement `Countable` for `AttachedObject` (`metadata` and `additional_owners`)
|
||||
|
||||
## 4.10.0 - 2017-05-25
|
||||
* Add support for login links
|
||||
|
||||
## 4.9.1 - 2017-05-10
|
||||
* Fix docs to include arrays on `$id` parameter for retrieve methods
|
||||
|
||||
## 4.9.0 - 2017-04-28
|
||||
* Support for checking webhook signatures
|
||||
|
||||
## 4.8.1 - 2017-04-24
|
||||
* Allow nested field `payout_schedule` to be updated
|
||||
|
||||
## 4.8.0 - 2017-04-20
|
||||
* Add `\Stripe\Stripe::setLogger()` to support an external PSR-3 compatible logger
|
||||
|
||||
## 4.7.0 - 2017-04-10
|
||||
* Add support for payouts and recipient transfers
|
||||
|
||||
### 4.6.0 2017-04-06
|
||||
|
||||
## 4.6.0 - 2017-04-06
|
||||
* Please see 4.7.0 instead (no-op release)
|
||||
|
||||
### 4.5.1 2017-03-22
|
||||
|
||||
## 4.5.1 - 2017-03-22
|
||||
* Remove hard dependency on cURL
|
||||
|
||||
### 4.5.0 2017-03-20
|
||||
|
||||
## 4.5.0 - 2017-03-20
|
||||
* Support for detaching sources from customers
|
||||
|
||||
### 4.4.2 2017-02-27
|
||||
|
||||
## 4.4.2 - 2017-02-27
|
||||
* Correct handling of `owner` parameter when updating sources
|
||||
|
||||
### 4.4.1 2017-02-24
|
||||
|
||||
## 4.4.1 - 2017-02-24
|
||||
* Correct the error check on a bad JSON decoding
|
||||
|
||||
### 4.4.0 2017-01-18
|
||||
|
||||
## 4.4.0 - 2017-01-18
|
||||
* Add support for updating sources
|
||||
|
||||
### 4.3.0 2016-11-30
|
||||
|
||||
## 4.3.0 - 2016-11-30
|
||||
* Add support for verifying sources
|
||||
|
||||
### 4.2.0 2016-11-21
|
||||
|
||||
## 4.2.0 - 2016-11-21
|
||||
* Add retrieve method for 3-D Secure resources
|
||||
|
||||
### 4.1.1 2016-10-21
|
||||
|
||||
## 4.1.1 - 2016-10-21
|
||||
* Add docblock with model properties for `Plan`
|
||||
|
||||
### 4.1.0 2016-10-18
|
||||
|
||||
## 4.1.0 - 2016-10-18
|
||||
* Support for 403 status codes (permission denied)
|
||||
|
||||
### 4.0.1 2016-10-17
|
||||
|
||||
## 4.0.1 - 2016-10-17
|
||||
* Fix transfer reversal materialization
|
||||
* Fixes for some property definitions in docblocks
|
||||
|
||||
### 4.0.0 2016-09-28
|
||||
|
||||
## 4.0.0 - 2016-09-28
|
||||
* Support for subscription items
|
||||
* Drop attempt to force TLS 1.2: please note that this could be breaking if you're using old OS distributions or packages and upgraded recently (so please make sure to test your integration!)
|
||||
|
||||
### 3.23.0 2016-09-15
|
||||
|
||||
## 3.23.0 - 2016-09-15
|
||||
* Add support for Apple Pay domains
|
||||
|
||||
### 3.22.0 2016-09-13
|
||||
|
||||
## 3.22.0 - 2016-09-13
|
||||
* Add `Stripe::setAppInfo` to allow plugins to register user agent information
|
||||
|
||||
### 3.21.0 2016-08-25
|
||||
|
||||
## 3.21.0 - 2016-08-25
|
||||
* Add `Source` model for generic payment sources
|
||||
|
||||
### 3.20.0 2016-08-08
|
||||
|
||||
## 3.20.0 - 2016-08-08
|
||||
* Add `getDeclineCode` to card errors
|
||||
|
||||
### 3.19.0 2016-07-29
|
||||
|
||||
## 3.19.0 - 2016-07-29
|
||||
* Opt requests directly into TLS 1.2 where OpenSSL >= 1.0.1 (see #277 for context)
|
||||
|
||||
### 3.18.0 2016-07-28
|
||||
|
||||
## 3.18.0 - 2016-07-28
|
||||
* Add new `STATUS_` constants for subscriptions
|
||||
|
||||
### 3.17.1 2016-07-28
|
||||
|
||||
## 3.17.1 - 2016-07-28
|
||||
* Fix auto-paging iterator so that it plays nicely with `iterator_to_array`
|
||||
|
||||
### 3.17.0 2016-07-14
|
||||
|
||||
## 3.17.0 - 2016-07-14
|
||||
* Add field annotations to model classes for better editor hinting
|
||||
|
||||
### 3.16.0 2016-07-12
|
||||
|
||||
## 3.16.0 - 2016-07-12
|
||||
* Add `ThreeDSecure` model for 3-D secure payments
|
||||
|
||||
### 3.15.0 2016-06-29
|
||||
|
||||
## 3.15.0 - 2016-06-29
|
||||
* Add static `update` method to all resources that can be changed.
|
||||
|
||||
### 3.14.3 2016-06-20
|
||||
|
||||
## 3.14.3 - 2016-06-20
|
||||
* Make sure that cURL never sends `Expects: 100-continue`, even on large request bodies
|
||||
|
||||
### 3.14.2 2016-06-03
|
||||
|
||||
## 3.14.2 - 2016-06-03
|
||||
* Add `inventory` under `SKU` to list of keys that have nested data and can be updated
|
||||
|
||||
### 3.14.1 2016-05-27
|
||||
|
||||
## 3.14.1 - 2016-05-27
|
||||
* Fix some inconsistencies in PHPDoc
|
||||
|
||||
### 3.14.0 2016-05-25
|
||||
|
||||
## 3.14.0 - 2016-05-25
|
||||
* Add support for returning Relay orders
|
||||
|
||||
### 3.13.0 2016-05-04
|
||||
|
||||
## 3.13.0 - 2016-05-04
|
||||
* Add `list`, `create`, `update`, `retrieve`, and `delete` methods to the Subscription class
|
||||
|
||||
### 3.12.1 2016-04-07
|
||||
|
||||
## 3.12.1 - 2016-04-07
|
||||
* Additional check on value arrays for some extra safety
|
||||
|
||||
### 3.12.0 2016-03-31
|
||||
|
||||
## 3.12.0 - 2016-03-31
|
||||
* Fix bug `refreshFrom` on `StripeObject` would not take an `$opts` array
|
||||
* Fix bug where `$opts` not passed to parent `save` method in `Account`
|
||||
* Fix bug where non-existent variable was referenced in `reverse` in `Transfer`
|
||||
* Update CA cert bundle for compatibility with OpenSSL versions below 1.0.1
|
||||
|
||||
### 3.11.0 2016-03-22
|
||||
|
||||
## 3.11.0 - 2016-03-22
|
||||
* Allow `CurlClient` to be initialized with default `CURLOPT_*` options
|
||||
|
||||
### 3.10.1 2016-03-22
|
||||
|
||||
## 3.10.1 - 2016-03-22
|
||||
* Fix bug where request params and options were ignored in `ApplicationFee`'s `refund.`
|
||||
|
||||
### 3.10.0 2016-03-15
|
||||
|
||||
## 3.10.0 - 2016-03-15
|
||||
* Add `reject` on `Account` to support the new API feature
|
||||
|
||||
### 3.9.2 2016-03-04
|
||||
|
||||
## 3.9.2 - 2016-03-04
|
||||
* Fix error when an object's metadata is set more than once
|
||||
|
||||
### 3.9.1 2016-02-24
|
||||
|
||||
## 3.9.1 - 2016-02-24
|
||||
* Fix encoding behavior of nested arrays for requests (see #227)
|
||||
|
||||
### 3.9.0 2016-02-09
|
||||
|
||||
## 3.9.0 - 2016-02-09
|
||||
* Add automatic pagination mechanism with `autoPagingIterator()`
|
||||
* Allow global account ID to be set with `Stripe::setAccountId()`
|
||||
|
||||
### 3.8.0 2016-02-08
|
||||
|
||||
## 3.8.0 - 2016-02-08
|
||||
* Add `CountrySpec` model for looking up country payment information
|
||||
|
||||
### 3.7.1 2016-02-01
|
||||
|
||||
## 3.7.1 - 2016-02-01
|
||||
* Update bundled CA certs
|
||||
|
||||
### 3.7.0 2016-01-27
|
||||
|
||||
## 3.7.0 - 2016-01-27
|
||||
* Support deleting Relay products and SKUs
|
||||
|
||||
### 3.6.0 2016-01-05
|
||||
|
||||
## 3.6.0 - 2016-01-05
|
||||
* Allow configuration of HTTP client timeouts
|
||||
|
||||
### 3.5.0 2015-12-01
|
||||
|
||||
## 3.5.0 - 2015-12-01
|
||||
* Add a verification routine for external accounts
|
||||
|
||||
### 3.4.0 2015-09-14
|
||||
|
||||
## 3.4.0 - 2015-09-14
|
||||
* Products, SKUs, and Orders -- https://stripe.com/relay
|
||||
|
||||
### 3.3.0 2015-09-11
|
||||
|
||||
## 3.3.0 - 2015-09-11
|
||||
* Add support for 429 Rate Limit response
|
||||
|
||||
### 3.2.0 2015-08-17
|
||||
|
||||
## 3.2.0 - 2015-08-17
|
||||
* Add refund listing and retrieval without an associated charge
|
||||
|
||||
### 3.1.0 2015-08-03
|
||||
|
||||
## 3.1.0 - 2015-08-03
|
||||
* Add dispute listing and retrieval
|
||||
* Add support for manage account deletion
|
||||
|
||||
### 3.0.0 2015-07-28
|
||||
|
||||
## 3.0.0 - 2015-07-28
|
||||
* Rename `\Stripe\Object` to `\Stripe\StripeObject` (PHP 7 compatibility)
|
||||
* Rename `getCode` and `getParam` in exceptions to `getStripeCode` and `getStripeParam`
|
||||
* Add support for calling `json_encode` on Stripe objects in PHP 5.4+
|
||||
* Start supporting/testing PHP 7
|
||||
|
||||
### 2.3.0 2015-07-06
|
||||
|
||||
## 2.3.0 - 2015-07-06
|
||||
* Add request ID to all Stripe exceptions
|
||||
|
||||
### 2.2.0 2015-06-01
|
||||
|
||||
## 2.2.0 - 2015-06-01
|
||||
* Add support for Alipay accounts as sources
|
||||
* Add support for bank accounts as sources (private beta)
|
||||
* Add support for bank accounts and cards as external_accounts on Account objects
|
||||
|
||||
### 2.1.4 2015-05-13
|
||||
|
||||
## 2.1.4 - 2015-05-13
|
||||
* Fix CA certificate file path (thanks @lphilps & @matthewarkin)
|
||||
|
||||
### 2.1.3 2015-05-12
|
||||
|
||||
## 2.1.3 - 2015-05-12
|
||||
* Fix to account updating to permit `tos_acceptance` and `personal_address` to be set properly
|
||||
* Fix to Transfer reversal creation (thanks @neatness!)
|
||||
* Network requests are now done through a swappable class for easier mocking
|
||||
|
||||
### 2.1.2 2015-04-10
|
||||
|
||||
## 2.1.2 - 2015-04-10
|
||||
* Remove SSL cert revokation checking (all pre-Heartbleed certs have expired)
|
||||
* Bug fixes to account updating
|
||||
|
||||
### 2.1.1 2015-02-27
|
||||
## 2.1.1 - 2015-02-27
|
||||
* Support transfer reversals
|
||||
|
||||
### 2.1.0 2015-02-19
|
||||
|
||||
## 2.1.0 - 2015-02-19
|
||||
* Support new API version (2015-02-18)
|
||||
* Added Bitcoin Receiever update and delete actions
|
||||
* Edited tests to prefer "source" over "card" as per new API version
|
||||
|
||||
### 2.0.1 2015-02-16
|
||||
|
||||
## 2.0.1 - 2015-02-16
|
||||
* Fix to fetching endpoints that use a non-default baseUrl (`FileUpload`)
|
||||
|
||||
### 2.0.0 2015-02-14
|
||||
|
||||
## 2.0.0 - 2015-02-14
|
||||
* Bumped minimum version to 5.3.3
|
||||
* Switched to Stripe namespace instead of Stripe_ class name prefiexes (thanks @chadicus!)
|
||||
* Switched tests to PHPUnit (thanks @chadicus!)
|
||||
@ -239,192 +317,134 @@
|
||||
* Added $opts hash to the end of most methods: this permits passing 'idempotency_key', 'stripe_account', or 'stripe_version'. The last 2 will persist across multiple object loads.
|
||||
* Added support for retrieving Account by ID
|
||||
|
||||
### 1.18.0 2015-01-21
|
||||
|
||||
## 1.18.0 - 2015-01-21
|
||||
* Support making bitcoin charges through BitcoinReceiver source object
|
||||
|
||||
### 1.17.5 2014-12-23
|
||||
|
||||
## 1.17.5 - 2014-12-23
|
||||
* Adding support for creating file uploads.
|
||||
|
||||
### 1.17.4 2014-12-15
|
||||
|
||||
## 1.17.4 - 2014-12-15
|
||||
* Saving objects fetched with a custom key now works (thanks @JustinHook & @jpasilan)
|
||||
* Added methods for reporting charges as safe or fraudulent and for specifying the reason for refunds
|
||||
|
||||
### 1.17.3 2014-11-06
|
||||
|
||||
## 1.17.3 - 2014-11-06
|
||||
* Better handling of HHVM support for SSL certificate blacklist checking.
|
||||
|
||||
### 1.17.2 2014-09-23
|
||||
|
||||
## 1.17.2 - 2014-09-23
|
||||
* Coupons now are backed by a `Stripe_Coupon` instead of `Stripe_Object`, and support updating metadata
|
||||
* Running operations (`create`, `retrieve`, `all`) on upcoming invoice items now works
|
||||
|
||||
### 1.17.1 2014-07-31
|
||||
|
||||
## 1.17.1 - 2014-07-31
|
||||
* Requests now send Content-Type header
|
||||
|
||||
### 1.17.0 2014-07-29
|
||||
|
||||
## 1.17.0 - 2014-07-29
|
||||
* Application Fee refunds now a list instead of array
|
||||
* HHVM now works
|
||||
* Small bug fixes (thanks @bencromwell & @fastest963)
|
||||
* __toString now returns the name of the object in addition to its JSON representation
|
||||
|
||||
### 1.16.0 2014-06-17
|
||||
* `__toString` now returns the name of the object in addition to its JSON representation
|
||||
|
||||
## 1.16.0 - 2014-06-17
|
||||
* Add metadata for refunds and disputes
|
||||
|
||||
### 1.15.0 2014-05-28
|
||||
|
||||
## 1.15.0 - 2014-05-28
|
||||
* Support canceling transfers
|
||||
|
||||
### 1.14.1 2014-05-21
|
||||
|
||||
## 1.14.1 - 2014-05-21
|
||||
* Support cards for recipients.
|
||||
|
||||
### 1.13.1 2014-05-15
|
||||
|
||||
## 1.13.1 - 2014-05-15
|
||||
* Fix bug in account resource where `id` wasn't in the result
|
||||
|
||||
### 1.13.0 2014-04-10
|
||||
|
||||
## 1.13.0 - 2014-04-10
|
||||
* Add support for certificate blacklisting
|
||||
* Update ca bundle
|
||||
* Drop support for HHVM (Temporarily)
|
||||
|
||||
### 1.12.0 2014-04-01
|
||||
|
||||
## 1.12.0 - 2014-04-01
|
||||
* Add Stripe_RateLimitError for catching rate limit errors.
|
||||
* Update to Zend coding style (thanks, @jpiasetz)
|
||||
|
||||
### 1.11.0 2014-01-29
|
||||
|
||||
## 1.11.0 - 2014-01-29
|
||||
* Add support for multiple subscriptions per customer
|
||||
|
||||
### 1.10.1 2013-12-02
|
||||
|
||||
## 1.10.1 - 2013-12-02
|
||||
* Add new ApplicationFee
|
||||
|
||||
### 1.9.1 2013-11-08
|
||||
|
||||
## 1.9.1 - 2013-11-08
|
||||
* Fix a bug where a null nestable object causes warnings to fire.
|
||||
|
||||
### 1.9.0 2013-10-16
|
||||
|
||||
## 1.9.0 - 2013-10-16
|
||||
* Add support for metadata API.
|
||||
|
||||
### 1.8.4 2013-09-18
|
||||
|
||||
## 1.8.4 - 2013-09-18
|
||||
* Add support for closing disputes.
|
||||
|
||||
### 1.8.3 2013-08-13
|
||||
|
||||
## 1.8.3 - 2013-08-13
|
||||
* Add new Balance and BalanceTransaction
|
||||
|
||||
### 1.8.2 2013-08-12
|
||||
|
||||
* Add support for unsetting attributes by updating to NULL.
|
||||
Setting properties to a blank string is now an error.
|
||||
|
||||
### 1.8.1 2013-07-12
|
||||
## 1.8.2 - 2013-08-12
|
||||
* Add support for unsetting attributes by updating to NULL. Setting properties to a blank string is now an error.
|
||||
|
||||
## 1.8.1 - 2013-07-12
|
||||
* Add support for multiple cards API (Stripe API version 2013-07-12: https://stripe.com/docs/upgrades#2013-07-05)
|
||||
|
||||
### 1.8.0 2013-04-11
|
||||
|
||||
## 1.8.0 - 2013-04-11
|
||||
* Allow Transfers to be creatable
|
||||
* Add new Recipient resource
|
||||
|
||||
### 1.7.15 2013-02-21
|
||||
|
||||
## 1.7.15 - 2013-02-21
|
||||
* Add 'id' to the list of permanent object attributes
|
||||
|
||||
### 1.7.14 2013-02-20
|
||||
## 1.7.14 - 2013-02-20
|
||||
|
||||
* Don't re-encode strings that are already encoded in UTF-8. If you
|
||||
were previously using plan or coupon objects with UTF-8 IDs, they
|
||||
may have been treated as ISO-8859-1 (Latin-1) and encoded to UTF-8 a
|
||||
2nd time. You may now need to pass the IDs to utf8_encode before
|
||||
passing them to Stripe_Plan::retrieve or Stripe_Coupon::retrieve.
|
||||
* Ensure that all input is encoded in UTF-8 before submitting it to
|
||||
Stripe's servers. (github issue #27)
|
||||
* Don't re-encode strings that are already encoded in UTF-8. If you were previously using plan or coupon objects with UTF-8 IDs, they may have been treated as ISO-8859-1 (Latin-1) and encoded to UTF-8 a 2nd time. You may now need to pass the IDs to utf8_encode before passing them to Stripe_Plan::retrieve or Stripe_Coupon::retrieve.
|
||||
* Ensure that all input is encoded in UTF-8 before submitting it to Stripe's servers. (github issue #27)
|
||||
|
||||
### 1.7.13 2013-02-01
|
||||
|
||||
* Add support for passing options when retrieving Stripe objects
|
||||
e.g., Stripe_Charge::retrieve(array("id"=>"foo", "expand" => array("customer")))
|
||||
Stripe_Charge::retrieve("foo") will continue to work
|
||||
|
||||
### 1.7.12 2013-01-15
|
||||
## 1.7.13 - 2013-02-01
|
||||
* Add support for passing options when retrieving Stripe objects e.g., Stripe_Charge::retrieve(array("id"=>"foo", "expand" => array("customer"))); Stripe_Charge::retrieve("foo") will continue to work
|
||||
|
||||
## 1.7.12 - 2013-01-15
|
||||
* Add support for setting a Stripe API version override
|
||||
|
||||
### 1.7.11 2012-12-30
|
||||
|
||||
* Version bump to cleanup constants and such (github issue #26)
|
||||
|
||||
### 1.7.10 2012-11-08
|
||||
## 1.7.11 - 2012-12-30
|
||||
* Version bump to cleanup constants and such (fix issue #26)
|
||||
|
||||
## 1.7.10 - 2012-11-08
|
||||
* Add support for updating charge disputes.
|
||||
* Fix bug preventing retrieval of null attributes
|
||||
|
||||
### 1.7.9 2012-11-08
|
||||
## 1.7.9 - 2012-11-08
|
||||
* Fix usage under autoloaders such as the one generated by composer (fix issue #22)
|
||||
|
||||
* Fix usage under autoloaders such as the one generated by composer
|
||||
(github issue #22)
|
||||
|
||||
### 1.7.8 2012-10-30
|
||||
## 1.7.8 - 2012-10-30
|
||||
* Add support for creating invoices.
|
||||
* Add support for new invoice lines return format
|
||||
* Add support for new list objects
|
||||
|
||||
### 1.7.7 2012-09-14
|
||||
|
||||
* Get all of the various version numbers in the repo in sync (no other
|
||||
changes)
|
||||
|
||||
### 1.7.6 2012-08-31
|
||||
## 1.7.7 - 2012-09-14
|
||||
* Get all of the various version numbers in the repo in sync (no other changes)
|
||||
|
||||
## 1.7.6 - 2012-08-31
|
||||
* Add update and pay methods to Invoice resource
|
||||
|
||||
### 1.7.5 2012-08-23
|
||||
## 1.7.5 - 2012-08-23
|
||||
* Change internal function names so that Stripe_SingletonApiRequest is E_STRICT-clean (github issue #16)
|
||||
|
||||
* Change internal function names so that Stripe_SingletonApiRequest is
|
||||
E_STRICT-clean (github issue #16)
|
||||
|
||||
### 1.7.4 2012-08-21
|
||||
|
||||
* Bugfix so that Stripe objects (e.g. Customer, Charge objects) used
|
||||
in API calls are transparently converted to their object IDs
|
||||
|
||||
### 1.7.3 2012-08-15
|
||||
## 1.7.4 - 2012-08-21
|
||||
* Bugfix so that Stripe objects (e.g. Customer, Charge objects) used in API calls are transparently converted to their object IDs
|
||||
|
||||
## 1.7.3 - 2012-08-15
|
||||
* Add new Account resource
|
||||
|
||||
### 1.7.2 2012-06-26
|
||||
## 1.7.2 - 2012-06-26
|
||||
* Make clearer that you should be including lib/Stripe.php, not test/Stripe.php (github issue #14)
|
||||
|
||||
* Make clearer that you should be including lib/Stripe.php, not
|
||||
test/Stripe.php (github issue #14)
|
||||
|
||||
### 1.7.1 2012-05-24
|
||||
|
||||
* Add missing argument to Stripe_InvalidRequestError constructor in
|
||||
Stripe_ApiResource::instanceUrl. Fixes a warning when
|
||||
Stripe_ApiResource::instanceUrl is called on a resource with no ID
|
||||
(github issue #12)
|
||||
|
||||
### 1.7.0 2012-05-17
|
||||
## 1.7.1 - 2012-05-24
|
||||
* Add missing argument to Stripe_InvalidRequestError constructor in Stripe_ApiResource::instanceUrl. Fixes a warning when Stripe_ApiResource::instanceUrl is called on a resource with no ID (fix issue #12)
|
||||
|
||||
## 1.7.0 - 2012-05-17
|
||||
* Support Composer and Packagist (github issue #9)
|
||||
|
||||
* Add new deleteDiscount method to Stripe_Customer
|
||||
|
||||
* Add new Transfer resource
|
||||
|
||||
* Switch from using HTTP Basic auth to Bearer auth. (Note: Stripe will
|
||||
support Basic auth for the indefinite future, but recommends Bearer
|
||||
auth when possible going forward)
|
||||
|
||||
* Switch from using HTTP Basic auth to Bearer auth. (Note: Stripe will support Basic auth for the indefinite future, but recommends Bearer auth when possible going forward)
|
||||
* Numerous test suite improvements
|
||||
|
||||
@ -10,7 +10,7 @@ You can sign up for a Stripe account at https://stripe.com.
|
||||
|
||||
## Requirements
|
||||
|
||||
PHP 5.3.3 and later.
|
||||
PHP 5.4.0 and later.
|
||||
|
||||
## Composer
|
||||
|
||||
@ -20,7 +20,7 @@ You can install the bindings via [Composer](http://getcomposer.org/). Run the fo
|
||||
composer require stripe/stripe-php
|
||||
```
|
||||
|
||||
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading):
|
||||
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):
|
||||
|
||||
```php
|
||||
require_once('vendor/autoload.php');
|
||||
@ -36,7 +36,7 @@ require_once('/path/to/stripe-php/init.php');
|
||||
|
||||
## Dependencies
|
||||
|
||||
The bindings require the following extension in order to work properly:
|
||||
The bindings require the following extensions in order to work properly:
|
||||
|
||||
- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
|
||||
- [`json`](https://secure.php.net/manual/en/book.json.php)
|
||||
@ -50,7 +50,7 @@ Simple usage looks like:
|
||||
|
||||
```php
|
||||
\Stripe\Stripe::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
|
||||
$charge = \Stripe\Charge::create(array('amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq' ));
|
||||
$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq']);
|
||||
echo $charge;
|
||||
```
|
||||
|
||||
@ -60,14 +60,19 @@ Please see https://stripe.com/docs/api for up-to-date documentation.
|
||||
|
||||
## Legacy Version Support
|
||||
|
||||
### 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.
|
||||
|
||||
### PHP 5.2
|
||||
|
||||
If you are using PHP 5.2, you can download v1.18.0 ([zip](https://github.com/stripe/stripe-php/archive/v1.18.0.zip), [tar.gz](https://github.com/stripe/stripe-php/archive/v1.18.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.
|
||||
|
||||
This legacy version may be included via `require_once("/path/to/stripe-php/lib/Stripe.php");`, and used like:
|
||||
|
||||
```php
|
||||
Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249');
|
||||
$myCard = array('number' => '4242424242424242', 'exp_month' => 8, 'exp_year' => 2018);
|
||||
$charge = Stripe_Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd'));
|
||||
$charge = Stripe_Charge::create(array('source' => 'tok_XXXXXXXX', 'amount' => 2000, 'currency' => 'usd'));
|
||||
echo $charge;
|
||||
```
|
||||
|
||||
@ -98,13 +103,32 @@ Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array t
|
||||
|
||||
```php
|
||||
// set up your tweaked Curl client
|
||||
$curl = new \Stripe\HttpClient\CurlClient(array(CURLOPT_PROXY => 'proxy.local:80'));
|
||||
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
|
||||
// tell Stripe to use the tweaked client
|
||||
\Stripe\ApiRequestor::setHttpClient($curl);
|
||||
```
|
||||
|
||||
Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.
|
||||
|
||||
### Configuring a Logger
|
||||
|
||||
The library does minimal logging, but it can be configured
|
||||
with a [`PSR-3` compatible logger][psr3] so that messages
|
||||
end up there instead of `error_log`:
|
||||
|
||||
```php
|
||||
\Stripe\Stripe::setLogger($logger);
|
||||
```
|
||||
|
||||
### Accessing response data
|
||||
|
||||
You can access the data from the last API response on any object via `getLastResponse()`.
|
||||
|
||||
```php
|
||||
$charge = \Stripe\Charge::create(['amount' => 2000, 'currency' => 'usd', 'source' => 'tok_visa']);
|
||||
echo $charge->getLastResponse()->headers['Request-Id'];
|
||||
```
|
||||
|
||||
### SSL / TLS compatibility issues
|
||||
|
||||
Stripe's API now requires that [all connections use TLS 1.2](https://stripe.com/blog/upgrading-tls). Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default. In this case, you'd get an `invalid_request_error` with the following error message: "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at [https://stripe.com/blog/upgrading-tls](https://stripe.com/blog/upgrading-tls).".
|
||||
@ -112,10 +136,49 @@ Stripe's API now requires that [all connections use TLS 1.2](https://stripe.com/
|
||||
The recommended course of action is to [upgrade your cURL and OpenSSL packages](https://support.stripe.com/questions/how-do-i-upgrade-my-stripe-integration-from-tls-1-0-to-tls-1-2#php) so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:
|
||||
|
||||
```php
|
||||
$curl = new \Stripe\HttpClient\CurlClient(array(CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1));
|
||||
$curl = new \Stripe\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
|
||||
\Stripe\ApiRequestor::setHttpClient($curl);
|
||||
```
|
||||
|
||||
### Per-request Configuration
|
||||
|
||||
For apps that need to use multiple keys during the lifetime of a process, like
|
||||
one that uses [Stripe Connect][connect], it's also possible to set a
|
||||
per-request key and/or account:
|
||||
|
||||
```php
|
||||
\Stripe\Charge::all([], [
|
||||
'api_key' => 'sk_test_...',
|
||||
'stripe_account' => 'acct_...'
|
||||
]);
|
||||
|
||||
\Stripe\Charge::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [
|
||||
'api_key' => 'sk_test_...',
|
||||
'stripe_account' => 'acct_...'
|
||||
]);
|
||||
```
|
||||
|
||||
### Configuring CA Bundles
|
||||
|
||||
By default, the library will use its own internal bundle of known CA
|
||||
certificates, but it's possible to configure your own:
|
||||
|
||||
```php
|
||||
\Stripe\Stripe::setCABundlePath("path/to/ca/bundle");
|
||||
```
|
||||
|
||||
### Configuring Automatic Retries
|
||||
|
||||
The library can be configured to automatically retry requests that fail due to
|
||||
an intermittent network problem:
|
||||
|
||||
```php
|
||||
\Stripe\Stripe::setMaxNetworkRetries(2);
|
||||
```
|
||||
|
||||
[Idempotency keys][idempotency-keys] are added to requests to guarantee that
|
||||
retries are safe.
|
||||
|
||||
## Development
|
||||
|
||||
Install dependencies:
|
||||
@ -124,7 +187,12 @@ Install dependencies:
|
||||
composer install
|
||||
```
|
||||
|
||||
## Tests
|
||||
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
|
||||
|
||||
Install dependencies as mentioned above (which will resolve [PHPUnit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite:
|
||||
|
||||
@ -138,6 +206,12 @@ Or to run an individual test file:
|
||||
./vendor/bin/phpunit tests/UtilTest.php
|
||||
```
|
||||
|
||||
Update bundled CA certificates from the [Mozilla cURL release][curl]:
|
||||
|
||||
```bash
|
||||
./update_certs.php
|
||||
```
|
||||
|
||||
## Attention plugin developers
|
||||
|
||||
Are you writing a plugin that integrates Stripe and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
|
||||
@ -151,3 +225,9 @@ The method should be called once, before any request is sent to the API. The sec
|
||||
### SSL / TLS configuration option
|
||||
|
||||
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`.
|
||||
|
||||
[connect]: https://stripe.com/connect
|
||||
[curl]: http://curl.haxx.se/docs/caextract.html
|
||||
[psr3]: http://www.php-fig.org/psr/psr-3/
|
||||
[idempotency-keys]: https://stripe.com/docs/api/php#idempotent_requests
|
||||
[stripe-mock]: https://github.com/stripe/stripe-mock
|
||||
|
||||
@ -1 +1 @@
|
||||
4.7.0
|
||||
6.4.1
|
||||
|
||||
@ -10,7 +10,7 @@ if (!$autoload) {
|
||||
$composer = json_decode(file_get_contents('composer.json'), true);
|
||||
unset($composer['autoload']);
|
||||
unset($composer['require-dev']['squizlabs/php_codesniffer']);
|
||||
file_put_contents('composer.json', json_encode($composer));
|
||||
file_put_contents('composer.json', json_encode($composer, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
passthru('composer install', $returnStatus);
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": ">=5.4.0",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*"
|
||||
|
||||
@ -5,6 +5,9 @@ require(dirname(__FILE__) . '/lib/Stripe.php');
|
||||
|
||||
// Utilities
|
||||
require(dirname(__FILE__) . '/lib/Util/AutoPagingIterator.php');
|
||||
require(dirname(__FILE__) . '/lib/Util/LoggerInterface.php');
|
||||
require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');
|
||||
require(dirname(__FILE__) . '/lib/Util/RandomGenerator.php');
|
||||
require(dirname(__FILE__) . '/lib/Util/RequestOptions.php');
|
||||
require(dirname(__FILE__) . '/lib/Util/Set.php');
|
||||
require(dirname(__FILE__) . '/lib/Util/Util.php');
|
||||
@ -19,19 +22,36 @@ require(dirname(__FILE__) . '/lib/Error/Api.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/ApiConnection.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/Authentication.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/Card.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/Idempotency.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/InvalidRequest.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/Permission.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/RateLimit.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/SignatureVerification.php');
|
||||
|
||||
// OAuth errors
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/OAuthBase.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidClient.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidGrant.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidRequest.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidScope.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedGrantType.php');
|
||||
require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedResponseType.php');
|
||||
|
||||
// API operations
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/All.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/Create.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/Delete.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/NestedResource.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/Request.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/Retrieve.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiOperations/Update.php');
|
||||
|
||||
// Plumbing
|
||||
require(dirname(__FILE__) . '/lib/ApiResponse.php');
|
||||
require(dirname(__FILE__) . '/lib/JsonSerializable.php');
|
||||
require(dirname(__FILE__) . '/lib/StripeObject.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiRequestor.php');
|
||||
require(dirname(__FILE__) . '/lib/ApiResource.php');
|
||||
require(dirname(__FILE__) . '/lib/SingletonApiResource.php');
|
||||
require(dirname(__FILE__) . '/lib/AttachedObject.php');
|
||||
require(dirname(__FILE__) . '/lib/ExternalAccount.php');
|
||||
|
||||
// Stripe API Resources
|
||||
require(dirname(__FILE__) . '/lib/Account.php');
|
||||
@ -51,10 +71,13 @@ require(dirname(__FILE__) . '/lib/CountrySpec.php');
|
||||
require(dirname(__FILE__) . '/lib/Coupon.php');
|
||||
require(dirname(__FILE__) . '/lib/Customer.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/FileUpload.php');
|
||||
require(dirname(__FILE__) . '/lib/Invoice.php');
|
||||
require(dirname(__FILE__) . '/lib/InvoiceItem.php');
|
||||
require(dirname(__FILE__) . '/lib/LoginLink.php');
|
||||
require(dirname(__FILE__) . '/lib/Order.php');
|
||||
require(dirname(__FILE__) . '/lib/OrderReturn.php');
|
||||
require(dirname(__FILE__) . '/lib/Payout.php');
|
||||
@ -65,9 +88,18 @@ require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
|
||||
require(dirname(__FILE__) . '/lib/Refund.php');
|
||||
require(dirname(__FILE__) . '/lib/SKU.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/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');
|
||||
|
||||
// OAuth
|
||||
require(dirname(__FILE__) . '/lib/OAuth.php');
|
||||
|
||||
// Webhooks
|
||||
require(dirname(__FILE__) . '/lib/Webhook.php');
|
||||
require(dirname(__FILE__) . '/lib/WebhookSignature.php');
|
||||
|
||||
@ -7,11 +7,13 @@ namespace Stripe;
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property mixed $business_logo
|
||||
* @property string $business_logo
|
||||
* @property string $business_name
|
||||
* @property mixed $business_url
|
||||
* @property string $business_primary_color
|
||||
* @property string $business_url
|
||||
* @property bool $charges_enabled
|
||||
* @property string $country
|
||||
* @property int $created
|
||||
* @property bool $debit_negative_balances
|
||||
* @property mixed $decline_charge_on
|
||||
* @property string $default_currency
|
||||
@ -20,23 +22,46 @@ namespace Stripe;
|
||||
* @property string $email
|
||||
* @property mixed $external_accounts
|
||||
* @property mixed $legal_entity
|
||||
* @property bool $managed
|
||||
* @property StripeObject $metadata
|
||||
* @property mixed $payout_schedule
|
||||
* @property mixed $payout_statement_descriptor
|
||||
* @property string $payout_statement_descriptor
|
||||
* @property bool $payouts_enabled
|
||||
* @property mixed $product_description
|
||||
* @property mixed $statement_descriptor
|
||||
* @property mixed $support_email
|
||||
* @property mixed $support_phone
|
||||
* @property string $product_description
|
||||
* @property string $statement_descriptor
|
||||
* @property string $support_email
|
||||
* @property string $support_phone
|
||||
* @property string $timezone
|
||||
* @property mixed $tos_acceptance
|
||||
* @property mixed $verification
|
||||
* @property mixed $keys
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Account extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\NestedResource;
|
||||
use ApiOperations\Retrieve {
|
||||
retrieve as protected _retrieve;
|
||||
}
|
||||
use ApiOperations\Update;
|
||||
|
||||
public static function getSavedNestedResources()
|
||||
{
|
||||
static $savedNestedResources = null;
|
||||
if ($savedNestedResources === null) {
|
||||
$savedNestedResources = new Util\Set([
|
||||
'external_account',
|
||||
'bank_account',
|
||||
]);
|
||||
}
|
||||
return $savedNestedResources;
|
||||
}
|
||||
|
||||
const PATH_EXTERNAL_ACCOUNTS = '/external_accounts';
|
||||
const PATH_LOGIN_LINKS = '/login_links';
|
||||
|
||||
public function instanceUrl()
|
||||
{
|
||||
if ($this['id'] === null) {
|
||||
@ -47,7 +72,8 @@ class Account extends ApiResource
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $id
|
||||
* @param array|string|null $id The ID of the account to retrieve, or an
|
||||
* options array containing an `id` key.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Account
|
||||
@ -61,50 +87,6 @@ class Account extends ApiResource
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the account to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Account The updated account.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Account
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Account The deleted account.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
@ -120,13 +102,133 @@ class Account extends ApiResource
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $clientId
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return StripeObject Object containing the response from the API.
|
||||
*/
|
||||
public function deauthorize($clientId = null, $opts = null)
|
||||
{
|
||||
$params = [
|
||||
'client_id' => $clientId,
|
||||
'stripe_user_id' => $this->id,
|
||||
];
|
||||
OAuth::deauthorize($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the account on which to create the external account.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Accounts
|
||||
* @return BankAccount|Card
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
public static function createExternalAccount($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
return self::_createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return BankAccount|Card
|
||||
*/
|
||||
public static function retrieveExternalAccount($id, $externalAccountId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_retrieveNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return BankAccount|Card
|
||||
*/
|
||||
public static function updateExternalAccount($id, $externalAccountId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_updateNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return BankAccount|Card
|
||||
*/
|
||||
public static function deleteExternalAccount($id, $externalAccountId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_deleteNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $externalAccountId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*/
|
||||
public static function allExternalAccounts($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_allNestedResources($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the account on which to create the login link.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return LoginLink
|
||||
*/
|
||||
public static function createLoginLink($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_createNestedResource($id, static::PATH_LOGIN_LINKS, $params, $opts);
|
||||
}
|
||||
|
||||
public function serializeParameters($force = false)
|
||||
{
|
||||
$update = parent::serializeParameters($force);
|
||||
if (isset($this->_values['legal_entity'])) {
|
||||
$entity = $this['legal_entity'];
|
||||
if (isset($entity->_values['additional_owners'])) {
|
||||
$owners = $entity['additional_owners'];
|
||||
$entityUpdate = isset($update['legal_entity']) ? $update['legal_entity'] : [];
|
||||
$entityUpdate['additional_owners'] = $this->serializeAdditionalOwners($entity, $owners);
|
||||
$update['legal_entity'] = $entityUpdate;
|
||||
}
|
||||
}
|
||||
return $update;
|
||||
}
|
||||
|
||||
private function serializeAdditionalOwners($legalEntity, $additionalOwners)
|
||||
{
|
||||
if (isset($legalEntity->_originalValues['additional_owners'])) {
|
||||
$originalValue = $legalEntity->_originalValues['additional_owners'];
|
||||
} else {
|
||||
$originalValue = [];
|
||||
}
|
||||
if (($originalValue) && (count($originalValue) > count($additionalOwners))) {
|
||||
throw new \InvalidArgumentException(
|
||||
"You cannot delete an item from an array, you must instead set a new array"
|
||||
);
|
||||
}
|
||||
|
||||
$updateArr = [];
|
||||
foreach ($additionalOwners as $i => $v) {
|
||||
$update = ($v instanceof StripeObject) ? $v->serializeParameters() : $v;
|
||||
|
||||
if ($update !== []) {
|
||||
if (!$originalValue || ($update != $legalEntity->serializeParamsValue($originalValue[$i], null, false, true))) {
|
||||
$updateArr[$i] = $update;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $updateArr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,8 +6,64 @@ namespace Stripe;
|
||||
* Class AlipayAccount
|
||||
*
|
||||
* @package Stripe
|
||||
*
|
||||
* @deprecated Alipay accounts are deprecated. Please use the sources API instead.
|
||||
* @link https://stripe.com/docs/sources/alipay
|
||||
*/
|
||||
class AlipayAccount extends ExternalAccount
|
||||
class AlipayAccount extends ApiResource
|
||||
{
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @return string The instance URL for this resource. It needs to be special
|
||||
* cased because it doesn't fit into the standard resource pattern.
|
||||
*/
|
||||
public function instanceUrl()
|
||||
{
|
||||
if ($this['customer']) {
|
||||
$base = Customer::classUrl();
|
||||
$parent = $this['customer'];
|
||||
$path = 'sources';
|
||||
} else {
|
||||
$msg = "Alipay accounts cannot be accessed without a customer ID.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
$parentExtn = urlencode(Util\Util::utf8($parent));
|
||||
$extn = urlencode(Util\Util::utf8($this['id']));
|
||||
return "$base/$parentExtn/$path/$extn";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $_id
|
||||
* @param array|string|null $_opts
|
||||
*
|
||||
* @throws \Stripe\Error\InvalidRequest
|
||||
*
|
||||
* @deprecated Alipay accounts are deprecated. Please use the sources API instead.
|
||||
* @link https://stripe.com/docs/sources/alipay
|
||||
*/
|
||||
public static function retrieve($_id, $_opts = null)
|
||||
{
|
||||
$msg = "Alipay accounts cannot be accessed without a customer ID. " .
|
||||
"Retrieve an Alipay account using \$customer->sources->retrieve('alipay_account_id') instead.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $_id
|
||||
* @param array|null $_params
|
||||
* @param array|string|null $_options
|
||||
*
|
||||
* @throws \Stripe\Error\InvalidRequest
|
||||
*
|
||||
* @deprecated Alipay accounts are deprecated. Please use the sources API instead.
|
||||
* @link https://stripe.com/docs/sources/alipay
|
||||
*/
|
||||
public static function update($_id, $_params = null, $_options = null)
|
||||
{
|
||||
$msg = "Alipay accounts cannot be accessed without a customer ID. " .
|
||||
"Call save() on \$customer->sources->retrieve('alipay_account_id') instead.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ class ApiRequestor
|
||||
} elseif ($d === false) {
|
||||
return 'false';
|
||||
} elseif (is_array($d)) {
|
||||
$res = array();
|
||||
$res = [];
|
||||
foreach ($d as $k => $v) {
|
||||
$res[$k] = self::_encodeObjects($v);
|
||||
}
|
||||
@ -54,17 +54,13 @@ class ApiRequestor
|
||||
*/
|
||||
public function request($method, $url, $params = null, $headers = null)
|
||||
{
|
||||
if (!$params) {
|
||||
$params = array();
|
||||
}
|
||||
if (!$headers) {
|
||||
$headers = array();
|
||||
}
|
||||
$params = $params ?: [];
|
||||
$headers = $headers ?: [];
|
||||
list($rbody, $rcode, $rheaders, $myApiKey) =
|
||||
$this->_requestRaw($method, $url, $params, $headers);
|
||||
$json = $this->_interpretResponse($rbody, $rcode, $rheaders);
|
||||
$resp = new ApiResponse($rbody, $rcode, $rheaders, $json);
|
||||
return array($resp, $myApiKey);
|
||||
return [$resp, $myApiKey];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,6 +70,7 @@ 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
|
||||
@ -84,7 +81,7 @@ class ApiRequestor
|
||||
* hitting the API.
|
||||
* @throws Error\Api otherwise.
|
||||
*/
|
||||
public function handleApiError($rbody, $rcode, $rheaders, $resp)
|
||||
public function handleErrorResponse($rbody, $rcode, $rheaders, $resp)
|
||||
{
|
||||
if (!is_array($resp) || !isset($resp['error'])) {
|
||||
$msg = "Invalid response object from API: $rbody "
|
||||
@ -92,35 +89,75 @@ class ApiRequestor
|
||||
throw new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
}
|
||||
|
||||
$error = $resp['error'];
|
||||
$msg = isset($error['message']) ? $error['message'] : null;
|
||||
$param = isset($error['param']) ? $error['param'] : null;
|
||||
$code = isset($error['code']) ? $error['code'] : null;
|
||||
$errorData = $resp['error'];
|
||||
|
||||
$error = null;
|
||||
if (is_string($errorData)) {
|
||||
$error = self::_specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorData);
|
||||
}
|
||||
if (!$error) {
|
||||
$error = self::_specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData);
|
||||
}
|
||||
|
||||
throw $error;
|
||||
}
|
||||
|
||||
private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData)
|
||||
{
|
||||
$msg = isset($errorData['message']) ? $errorData['message'] : null;
|
||||
$param = isset($errorData['param']) ? $errorData['param'] : null;
|
||||
$code = isset($errorData['code']) ? $errorData['code'] : null;
|
||||
$type = isset($errorData['type']) ? $errorData['type'] : null;
|
||||
|
||||
switch ($rcode) {
|
||||
case 400:
|
||||
// 'rate_limit' code is deprecated, but left here for backwards compatibility
|
||||
// for API versions earlier than 2015-09-08
|
||||
if ($code == 'rate_limit') {
|
||||
throw new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
|
||||
}
|
||||
if ($type == 'idempotency_error') {
|
||||
return new Error\Idempotency($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
}
|
||||
|
||||
// intentional fall-through
|
||||
case 404:
|
||||
throw new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
|
||||
case 401:
|
||||
throw new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
case 402:
|
||||
throw new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
|
||||
case 403:
|
||||
throw new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
case 429:
|
||||
throw new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
|
||||
default:
|
||||
throw new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
return new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
|
||||
}
|
||||
}
|
||||
|
||||
private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode)
|
||||
{
|
||||
$description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode;
|
||||
|
||||
switch ($errorCode) {
|
||||
case 'invalid_client':
|
||||
return new Error\OAuth\InvalidClient($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
|
||||
case 'invalid_grant':
|
||||
return new Error\OAuth\InvalidGrant($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
|
||||
case 'invalid_request':
|
||||
return new Error\OAuth\InvalidRequest($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
|
||||
case 'invalid_scope':
|
||||
return new Error\OAuth\InvalidScope($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
|
||||
case 'unsupported_grant_type':
|
||||
return new Error\OAuth\UnsupportedGrantType($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
|
||||
case 'unsupported_response_type':
|
||||
return new Error\OAuth\UnsupportedResponseType($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function _formatAppInfo($appInfo)
|
||||
{
|
||||
if ($appInfo !== null) {
|
||||
@ -137,44 +174,34 @@ class ApiRequestor
|
||||
}
|
||||
}
|
||||
|
||||
private static function _defaultHeaders($apiKey)
|
||||
private static function _defaultHeaders($apiKey, $clientInfo = null)
|
||||
{
|
||||
$appInfo = Stripe::getAppInfo();
|
||||
|
||||
$uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION;
|
||||
|
||||
$langVersion = phpversion();
|
||||
$uname = php_uname();
|
||||
|
||||
$httplib = 'unknown';
|
||||
$ssllib = 'unknown';
|
||||
|
||||
if (function_exists('curl_version')) {
|
||||
$curlVersion = curl_version();
|
||||
$httplib = 'curl ' . $curlVersion['version'];
|
||||
$ssllib = $curlVersion['ssl_version'];
|
||||
}
|
||||
|
||||
$appInfo = Stripe::getAppInfo();
|
||||
$ua = array(
|
||||
$ua = [
|
||||
'bindings_version' => Stripe::VERSION,
|
||||
'lang' => 'php',
|
||||
'lang_version' => $langVersion,
|
||||
'publisher' => 'stripe',
|
||||
'uname' => $uname,
|
||||
'httplib' => $httplib,
|
||||
'ssllib' => $ssllib,
|
||||
);
|
||||
];
|
||||
if ($clientInfo) {
|
||||
$ua = array_merge($clientInfo, $ua);
|
||||
}
|
||||
if ($appInfo !== null) {
|
||||
$uaString .= ' ' . self::_formatAppInfo($appInfo);
|
||||
$ua['application'] = $appInfo;
|
||||
}
|
||||
|
||||
$defaultHeaders = array(
|
||||
$defaultHeaders = [
|
||||
'X-Stripe-Client-User-Agent' => json_encode($ua),
|
||||
'User-Agent' => $uaString,
|
||||
'Authorization' => 'Bearer ' . $apiKey,
|
||||
);
|
||||
];
|
||||
return $defaultHeaders;
|
||||
}
|
||||
|
||||
@ -193,9 +220,17 @@ class ApiRequestor
|
||||
throw new Error\Authentication($msg);
|
||||
}
|
||||
|
||||
// Clients can supply arbitrary additional keys to be included in the
|
||||
// X-Stripe-Client-User-Agent header via the optional getUserAgentInfo()
|
||||
// method
|
||||
$clientUAInfo = null;
|
||||
if (method_exists($this->httpClient(), 'getUserAgentInfo')) {
|
||||
$clientUAInfo = $this->httpClient()->getUserAgentInfo();
|
||||
}
|
||||
|
||||
$absUrl = $this->_apiBase.$url;
|
||||
$params = self::_encodeObjects($params);
|
||||
$defaultHeaders = $this->_defaultHeaders($myApiKey);
|
||||
$defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo);
|
||||
if (Stripe::$apiVersion) {
|
||||
$defaultHeaders['Stripe-Version'] = Stripe::$apiVersion;
|
||||
}
|
||||
@ -222,7 +257,7 @@ class ApiRequestor
|
||||
}
|
||||
|
||||
$combinedHeaders = array_merge($defaultHeaders, $headers);
|
||||
$rawHeaders = array();
|
||||
$rawHeaders = [];
|
||||
|
||||
foreach ($combinedHeaders as $header => $value) {
|
||||
$rawHeaders[] = $header . ': ' . $value;
|
||||
@ -235,7 +270,7 @@ class ApiRequestor
|
||||
$params,
|
||||
$hasFile
|
||||
);
|
||||
return array($rbody, $rcode, $rheaders, $myApiKey);
|
||||
return [$rbody, $rcode, $rheaders, $myApiKey];
|
||||
}
|
||||
|
||||
private function _processResourceParam($resource, $hasCurlFile)
|
||||
@ -272,7 +307,7 @@ class ApiRequestor
|
||||
}
|
||||
|
||||
if ($rcode < 200 || $rcode >= 300) {
|
||||
$this->handleApiError($rbody, $rcode, $rheaders, $resp);
|
||||
$this->handleErrorResponse($rbody, $rcode, $rheaders, $resp);
|
||||
}
|
||||
return $resp;
|
||||
}
|
||||
|
||||
@ -9,11 +9,42 @@ namespace Stripe;
|
||||
*/
|
||||
abstract class ApiResource extends StripeObject
|
||||
{
|
||||
private static $HEADERS_TO_PERSIST = array('Stripe-Account' => true, 'Stripe-Version' => true);
|
||||
use ApiOperations\Request;
|
||||
|
||||
public static function baseUrl()
|
||||
/**
|
||||
* @return \Stripe\Util\Set A list of fields that can be their own type of
|
||||
* API resource (say a nested card under an account for example), and if
|
||||
* that resource is set, it should be transmitted to the API on a create or
|
||||
* update. Doing so is not the default behavior because API resources
|
||||
* should normally be persisted on their own RESTful endpoints.
|
||||
*/
|
||||
public static function getSavedNestedResources()
|
||||
{
|
||||
return Stripe::$apiBase;
|
||||
static $savedNestedResources = null;
|
||||
if ($savedNestedResources === null) {
|
||||
$savedNestedResources = new Util\Set();
|
||||
}
|
||||
return $savedNestedResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var boolean A flag that can be set a behavior that will cause this
|
||||
* resource to be encoded and sent up along with an update of its parent
|
||||
* resource. This is usually not desirable because resources are updated
|
||||
* individually on their own endpoints, but there are certain cases,
|
||||
* replacing a customer's source for example, where this is allowed.
|
||||
*/
|
||||
public $saveWithParent = false;
|
||||
|
||||
public function __set($k, $v)
|
||||
{
|
||||
parent::__set($k, $v);
|
||||
$v = $this->$k;
|
||||
if ((static::getSavedNestedResources()->includes($k)) &&
|
||||
($v instanceof ApiResource)) {
|
||||
$v->saveWithParent = true;
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,6 +90,14 @@ abstract class ApiResource extends StripeObject
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The base URL for the given class.
|
||||
*/
|
||||
public static function baseUrl()
|
||||
{
|
||||
return Stripe::$apiBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The endpoint URL for the given class.
|
||||
*/
|
||||
@ -92,112 +131,4 @@ abstract class ApiResource extends StripeObject
|
||||
{
|
||||
return static::resourceUrl($this['id']);
|
||||
}
|
||||
|
||||
protected static function _validateParams($params = null)
|
||||
{
|
||||
if ($params && !is_array($params)) {
|
||||
$message = "You must pass an array as the first argument to Stripe API "
|
||||
. "method calls. (HINT: an example call to create a charge "
|
||||
. "would be: \"Stripe\\Charge::create(array('amount' => 100, "
|
||||
. "'currency' => 'usd', 'card' => array('number' => "
|
||||
. "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
|
||||
throw new Error\Api($message);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _request($method, $url, $params = array(), $options = null)
|
||||
{
|
||||
$opts = $this->_opts->merge($options);
|
||||
list($resp, $options) = static::_staticRequest($method, $url, $params, $opts);
|
||||
$this->setLastResponse($resp);
|
||||
return array($resp->json, $options);
|
||||
}
|
||||
|
||||
protected static function _staticRequest($method, $url, $params, $options)
|
||||
{
|
||||
$opts = Util\RequestOptions::parse($options);
|
||||
$requestor = new ApiRequestor($opts->apiKey, static::baseUrl());
|
||||
list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
|
||||
foreach ($opts->headers as $k => $v) {
|
||||
if (!array_key_exists($k, self::$HEADERS_TO_PERSIST)) {
|
||||
unset($opts->headers[$k]);
|
||||
}
|
||||
}
|
||||
return array($response, $opts);
|
||||
}
|
||||
|
||||
protected static function _retrieve($id, $options = null)
|
||||
{
|
||||
$opts = Util\RequestOptions::parse($options);
|
||||
$instance = new static($id, $opts);
|
||||
$instance->refresh();
|
||||
return $instance;
|
||||
}
|
||||
|
||||
protected static function _all($params = null, $options = null)
|
||||
{
|
||||
self::_validateParams($params);
|
||||
$url = static::classUrl();
|
||||
|
||||
list($response, $opts) = static::_staticRequest('get', $url, $params, $options);
|
||||
$obj = Util\Util::convertToStripeObject($response->json, $opts);
|
||||
if (!is_a($obj, 'Stripe\\Collection')) {
|
||||
$class = get_class($obj);
|
||||
$message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
|
||||
throw new Error\Api($message);
|
||||
}
|
||||
$obj->setLastResponse($response);
|
||||
$obj->setRequestParams($params);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected static function _create($params = null, $options = null)
|
||||
{
|
||||
self::_validateParams($params);
|
||||
$url = static::classUrl();
|
||||
|
||||
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
|
||||
$obj = Util\Util::convertToStripeObject($response->json, $opts);
|
||||
$obj->setLastResponse($response);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the API resource to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApiResource the updated API resource
|
||||
*/
|
||||
protected static function _update($id, $params = null, $options = null)
|
||||
{
|
||||
self::_validateParams($params);
|
||||
$url = static::resourceUrl($id);
|
||||
|
||||
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
|
||||
$obj = Util\Util::convertToStripeObject($response->json, $opts);
|
||||
$obj->setLastResponse($response);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
protected function _save($options = null)
|
||||
{
|
||||
$params = $this->serializeParameters();
|
||||
if (count($params) > 0) {
|
||||
$url = $this->instanceUrl();
|
||||
list($response, $opts) = $this->_request('post', $url, $params, $options);
|
||||
$this->refreshFrom($response, $opts);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _delete($params = null, $options = null)
|
||||
{
|
||||
self::_validateParams($params);
|
||||
|
||||
$url = $this->instanceUrl();
|
||||
list($response, $opts) = $this->_request('delete', $url, $params, $options);
|
||||
$this->refreshFrom($response, $opts);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,11 @@ namespace Stripe;
|
||||
*/
|
||||
class ApplePayDomain extends ApiResource
|
||||
{
|
||||
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
|
||||
/**
|
||||
* @return string The class URL for this resource. It needs to be special
|
||||
* cased because it doesn't fit into the standard resource pattern.
|
||||
@ -18,48 +22,4 @@ class ApplePayDomain extends ApiResource
|
||||
{
|
||||
return '/v1/apple_pay/domains';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the domain to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApplePayDomain
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApplePayDomain The created domain.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApplePayDomain The deleted domain.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of ApplePayDomains
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,31 @@ namespace Stripe;
|
||||
/**
|
||||
* Class ApplicationFee
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property string $account
|
||||
* @property int $amount
|
||||
* @property int $amount_refunded
|
||||
* @property string $application
|
||||
* @property string $balance_transaction
|
||||
* @property string $charge
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property bool $livemode
|
||||
* @property string $originating_transaction
|
||||
* @property bool $refunded
|
||||
* @property Collection $refunds
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class ApplicationFee extends ApiResource
|
||||
{
|
||||
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.
|
||||
@ -20,40 +41,6 @@ class ApplicationFee extends ApiResource
|
||||
return 'application_fee';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the application fee to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApplicationFee
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the application fee to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return ApplicationFee The updated application fee.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of ApplicationFees
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
@ -66,4 +53,54 @@ class ApplicationFee extends ApiResource
|
||||
$this->refresh();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the application fee on which to create the refund.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApplicationFeeRefund
|
||||
*/
|
||||
public static function createRefund($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_createNestedResource($id, static::PATH_REFUNDS, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return ApplicationFeeRefund
|
||||
*/
|
||||
public static function retrieveRefund($id, $refundId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_retrieveNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return ApplicationFeeRefund
|
||||
*/
|
||||
public static function updateRefund($id, $refundId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_updateNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*/
|
||||
public static function allRefunds($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_allNestedResources($id, static::PATH_REFUNDS, $params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,23 @@ namespace Stripe;
|
||||
/**
|
||||
* Class ApplicationFeeRefund
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property string $balance_transaction
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $fee
|
||||
* @property StripeObject $metadata
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class ApplicationFeeRefund extends ApiResource
|
||||
{
|
||||
use ApiOperations\Update {
|
||||
save as protected _save;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The API URL for this Stripe refund.
|
||||
*/
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
use Countable;
|
||||
|
||||
/**
|
||||
* Class AttachedObject
|
||||
*
|
||||
@ -9,7 +11,7 @@ namespace Stripe;
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class AttachedObject extends StripeObject
|
||||
class AttachedObject extends StripeObject implements Countable
|
||||
{
|
||||
/**
|
||||
* Updates this object.
|
||||
@ -28,4 +30,14 @@ class AttachedObject extends StripeObject
|
||||
$this->$k = $v;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of elements in the AttachedObject instance.
|
||||
*
|
||||
* @return int the number of elements
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->_values);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,9 @@ namespace Stripe;
|
||||
* Class Balance
|
||||
*
|
||||
* @property string $object
|
||||
* @property mixed $available
|
||||
* @property bool $livedmode
|
||||
* @property mixed $pending
|
||||
* @property array $available
|
||||
* @property bool $livemode
|
||||
* @property array $pending
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
|
||||
@ -12,11 +12,11 @@ namespace Stripe;
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $description
|
||||
* @property float $exchange_rate
|
||||
* @property int $fee
|
||||
* @property mixed $fee_details
|
||||
* @property int $net
|
||||
* @property string $source
|
||||
* @property mixed $sourced_transfers
|
||||
* @property string $status
|
||||
* @property string $type
|
||||
*
|
||||
@ -24,6 +24,9 @@ namespace Stripe;
|
||||
*/
|
||||
class BalanceTransaction extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Retrieve;
|
||||
|
||||
/**
|
||||
* @return string The class URL for this resource. It needs to be special
|
||||
* cased because it doesn't fit into the standard resource pattern.
|
||||
@ -32,26 +35,4 @@ class BalanceTransaction extends ApiResource
|
||||
{
|
||||
return "/v1/balance/history";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the balance transaction to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return BalanceTransaction
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of BalanceTransactions
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,11 +5,82 @@ namespace Stripe;
|
||||
/**
|
||||
* Class BankAccount
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property string $account
|
||||
* @property string $account_holder_name
|
||||
* @property string $account_holder_type
|
||||
* @property string $bank_name
|
||||
* @property string $country
|
||||
* @property string $currency
|
||||
* @property string $customer
|
||||
* @property bool $default_for_currency
|
||||
* @property string $fingerprint
|
||||
* @property string $last4
|
||||
* @property StripeObject $metadata
|
||||
* @property string $routing_number
|
||||
* @property string $status
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class BankAccount extends ExternalAccount
|
||||
class BankAccount extends ApiResource
|
||||
{
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @return string The instance URL for this resource. It needs to be special
|
||||
* cased because it doesn't fit into the standard resource pattern.
|
||||
*/
|
||||
public function instanceUrl()
|
||||
{
|
||||
if ($this['customer']) {
|
||||
$base = Customer::classUrl();
|
||||
$parent = $this['customer'];
|
||||
$path = 'sources';
|
||||
} elseif ($this['account']) {
|
||||
$base = Account::classUrl();
|
||||
$parent = $this['account'];
|
||||
$path = 'external_accounts';
|
||||
} else {
|
||||
$msg = "Bank accounts cannot be accessed without a customer ID or account ID.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
$parentExtn = urlencode(Util\Util::utf8($parent));
|
||||
$extn = urlencode(Util\Util::utf8($this['id']));
|
||||
return "$base/$parentExtn/$path/$extn";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $_id
|
||||
* @param array|string|null $_opts
|
||||
*
|
||||
* @throws \Stripe\Error\InvalidRequest
|
||||
*/
|
||||
public static function retrieve($_id, $_opts = null)
|
||||
{
|
||||
$msg = "Bank accounts cannot be accessed without a customer ID or account ID. " .
|
||||
"Retrieve a bank account using \$customer->sources->retrieve('bank_account_id') or " .
|
||||
"\$account->external_accounts->retrieve('bank_account_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 = "Bank accounts cannot be accessed without a customer ID or account ID. " .
|
||||
"Call save() on \$customer->sources->retrieve('bank_account_id') or " .
|
||||
"\$account->external_accounts->retrieve('bank_account_id') instead.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
|
||||
@ -6,9 +6,15 @@ namespace Stripe;
|
||||
* Class BitcoinReceiver
|
||||
*
|
||||
* @package Stripe
|
||||
*
|
||||
* @deprecated Bitcoin receivers are deprecated. Please use the sources API instead.
|
||||
* @link https://stripe.com/docs/sources/bitcoin
|
||||
*/
|
||||
class BitcoinReceiver extends ExternalAccount
|
||||
class BitcoinReceiver extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Retrieve;
|
||||
|
||||
/**
|
||||
* @return string The class URL for this resource. It needs to be special
|
||||
* cased because it doesn't fit into the standard resource pattern.
|
||||
@ -24,62 +30,17 @@ class BitcoinReceiver extends ExternalAccount
|
||||
*/
|
||||
public function instanceUrl()
|
||||
{
|
||||
$result = parent::instanceUrl();
|
||||
if ($result) {
|
||||
return $result;
|
||||
if ($this['customer']) {
|
||||
$base = Customer::classUrl();
|
||||
$parent = $this['customer'];
|
||||
$path = 'sources';
|
||||
$parentExtn = urlencode(Util\Util::utf8($parent));
|
||||
$extn = urlencode(Util\Util::utf8($this['id']));
|
||||
return "$base/$parentExtn/$path/$extn";
|
||||
} else {
|
||||
$id = $this['id'];
|
||||
$id = Util\Util::utf8($id);
|
||||
$extn = urlencode($id);
|
||||
$base = BitcoinReceiver::classUrl();
|
||||
$extn = urlencode(Util\Util::utf8($this['id']));
|
||||
return "$base/$extn";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the Bitcoin Receiver to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return BitcoinReceiver
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of BitcoinReceivers
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return BitcoinReceiver The created Bitcoin Receiver item.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return BitcoinReceiver The refunded Bitcoin Receiver item.
|
||||
*/
|
||||
public function refund($params = null, $options = null)
|
||||
{
|
||||
$url = $this->instanceUrl() . '/refund';
|
||||
list($response, $opts) = $this->_request('post', $url, $params, $options);
|
||||
$this->refreshFrom($response, $opts);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,9 +5,93 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Card
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property string $address_city
|
||||
* @property string $address_country
|
||||
* @property string $address_line1
|
||||
* @property string $address_line1_check
|
||||
* @property string $address_line2
|
||||
* @property string $address_state
|
||||
* @property string $address_zip
|
||||
* @property string $address_zip_check
|
||||
* @property string $brand
|
||||
* @property string $country
|
||||
* @property string $customer
|
||||
* @property string $cvc_check
|
||||
* @property string $dynamic_last4
|
||||
* @property int $exp_month
|
||||
* @property int $exp_year
|
||||
* @property string $fingerprint
|
||||
* @property string $funding
|
||||
* @property string $last4
|
||||
* @property StripeObject $metadata
|
||||
* @property string $name
|
||||
* @property string $tokenization_method
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Card extends ExternalAccount
|
||||
class Card extends ApiResource
|
||||
{
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @return string The instance URL for this resource. It needs to be special
|
||||
* cased because cards are nested resources that may belong to different
|
||||
* top-level resources.
|
||||
*/
|
||||
public function instanceUrl()
|
||||
{
|
||||
if ($this['customer']) {
|
||||
$base = Customer::classUrl();
|
||||
$parent = $this['customer'];
|
||||
$path = 'sources';
|
||||
} elseif ($this['account']) {
|
||||
$base = Account::classUrl();
|
||||
$parent = $this['account'];
|
||||
$path = 'external_accounts';
|
||||
} elseif ($this['recipient']) {
|
||||
$base = Recipient::classUrl();
|
||||
$parent = $this['recipient'];
|
||||
$path = 'cards';
|
||||
} else {
|
||||
$msg = "Cards cannot be accessed without a customer ID, account ID or recipient ID.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
$parentExtn = urlencode(Util\Util::utf8($parent));
|
||||
$extn = urlencode(Util\Util::utf8($this['id']));
|
||||
return "$base/$parentExtn/$path/$extn";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $_id
|
||||
* @param array|string|null $_opts
|
||||
*
|
||||
* @throws \Stripe\Error\InvalidRequest
|
||||
*/
|
||||
public static function retrieve($_id, $_opts = null)
|
||||
{
|
||||
$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";
|
||||
"\$account->external_accounts->retrieve('card_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 = "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";
|
||||
"\$account->external_accounts->retrieve('card_id') instead.";
|
||||
throw new Error\InvalidRequest($msg, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,91 +9,47 @@ namespace Stripe;
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property int $amount_refunded
|
||||
* @property mixed $application_fee
|
||||
* @property string $application
|
||||
* @property string $application_fee
|
||||
* @property string $balance_transaction
|
||||
* @property bool $captured
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $customer
|
||||
* @property mixed $description
|
||||
* @property mixed $destination
|
||||
* @property string|null $dispute
|
||||
* @property mixed $failure_code
|
||||
* @property mixed $failure_message
|
||||
* @property string $description
|
||||
* @property string $destination
|
||||
* @property string $dispute
|
||||
* @property string $failure_code
|
||||
* @property string $failure_message
|
||||
* @property mixed $fraud_details
|
||||
* @property mixed $invoice
|
||||
* @property string $invoice
|
||||
* @property bool $livemode
|
||||
* @property mixed $metadata
|
||||
* @property mixed $order
|
||||
* @property StripeObject $metadata
|
||||
* @property string $on_behalf_of
|
||||
* @property string $order
|
||||
* @property mixed $outcome
|
||||
* @property bool $paid
|
||||
* @property mixed $receipt_email
|
||||
* @property mixed $receipt_number
|
||||
* @property string $receipt_email
|
||||
* @property string $receipt_number
|
||||
* @property bool $refunded
|
||||
* @property mixed $refunds
|
||||
* @property Collection $refunds
|
||||
* @property string $review
|
||||
* @property mixed $shipping
|
||||
* @property mixed $source
|
||||
* @property mixed $source_transfer
|
||||
* @property mixed $statement_descriptor
|
||||
* @property string $source_transfer
|
||||
* @property string $statement_descriptor
|
||||
* @property string $status
|
||||
* @property string $transfer
|
||||
* @property string $transfer_group
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Charge extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the charge to retrieve.
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Charge
|
||||
*/
|
||||
public static function retrieve($id, $options = null)
|
||||
{
|
||||
return self::_retrieve($id, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Collection of Charges
|
||||
*/
|
||||
public static function all($params = null, $options = null)
|
||||
{
|
||||
return self::_all($params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Charge The created charge.
|
||||
*/
|
||||
public static function create($params = null, $options = null)
|
||||
{
|
||||
return self::_create($params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the charge to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Charge The updated charge.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Charge The saved charge.
|
||||
*/
|
||||
public function save($options = null)
|
||||
{
|
||||
return $this->_save($options);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
@ -135,7 +91,7 @@ class Charge extends ApiResource
|
||||
{
|
||||
$url = $this->instanceUrl() . '/dispute';
|
||||
list($response, $opts) = $this->_request('post', $url, $params, $options);
|
||||
$this->refreshFrom(array('dispute' => $response), $opts, true);
|
||||
$this->refreshFrom(['dispute' => $response], $opts, true);
|
||||
return $this->dispute;
|
||||
}
|
||||
|
||||
@ -161,7 +117,7 @@ class Charge extends ApiResource
|
||||
*/
|
||||
public function markAsFraudulent($opts = null)
|
||||
{
|
||||
$params = array('fraud_details' => array('user_report' => 'fraudulent'));
|
||||
$params = ['fraud_details' => ['user_report' => 'fraudulent']];
|
||||
$url = $this->instanceUrl();
|
||||
list($response, $opts) = $this->_request('post', $url, $params, $opts);
|
||||
$this->refreshFrom($response, $opts);
|
||||
@ -175,7 +131,7 @@ class Charge extends ApiResource
|
||||
*/
|
||||
public function markAsSafe($opts = null)
|
||||
{
|
||||
$params = array('fraud_details' => array('user_report' => 'safe'));
|
||||
$params = ['fraud_details' => ['user_report' => 'safe']];
|
||||
$url = $this->instanceUrl();
|
||||
list($response, $opts) = $this->_request('post', $url, $params, $opts);
|
||||
$this->refreshFrom($response, $opts);
|
||||
|
||||
@ -12,9 +12,19 @@ namespace Stripe;
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Collection extends ApiResource
|
||||
class Collection extends StripeObject
|
||||
{
|
||||
protected $_requestParams = array();
|
||||
use ApiOperations\Request;
|
||||
|
||||
protected $_requestParams = [];
|
||||
|
||||
/**
|
||||
* @return string The base URL for the given class.
|
||||
*/
|
||||
public static function baseUrl()
|
||||
{
|
||||
return Stripe::$apiBase;
|
||||
}
|
||||
|
||||
public function setRequestParams($params)
|
||||
{
|
||||
@ -56,7 +66,7 @@ class Collection extends ApiResource
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AutoPagingIterator An iterator that can be used to iterate
|
||||
* @return Util\AutoPagingIterator An iterator that can be used to iterate
|
||||
* across all objects across all pages. As page boundaries are
|
||||
* encountered, the next page will be fetched automatically for
|
||||
* continued iteration.
|
||||
@ -76,12 +86,11 @@ class Collection extends ApiResource
|
||||
if (isset($url['query'])) {
|
||||
// If the URL contains a query param, parse it out into $params so they
|
||||
// don't interact weirdly with each other.
|
||||
$query = array();
|
||||
$query = [];
|
||||
parse_str($url['query'], $query);
|
||||
// PHP 5.2 doesn't support the ?: operator :(
|
||||
$params = array_merge($params ? $params : array(), $query);
|
||||
$params = array_merge($params ?: [], $query);
|
||||
}
|
||||
|
||||
return array($url['path'], $params);
|
||||
return [$url['path'], $params];
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,21 @@ namespace Stripe;
|
||||
/**
|
||||
* Class CountrySpec
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property string $default_currency
|
||||
* @property mixed $supported_bank_account_currencies
|
||||
* @property string[] $supported_payment_currencies
|
||||
* @property string[] $supported_payment_methods
|
||||
* @property mixed $verification_fields
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class CountrySpec extends ApiResource
|
||||
{
|
||||
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.
|
||||
@ -19,26 +30,4 @@ class CountrySpec extends ApiResource
|
||||
{
|
||||
return 'country_spec';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $country The ISO country code of the country we retrieve the CountrySpec for.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return CountrySpec
|
||||
*/
|
||||
public static function retrieve($country, $opts = null)
|
||||
{
|
||||
return self::_retrieve($country, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of CountrySpecs
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,73 +5,28 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Coupon
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount_off
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $duration
|
||||
* @property int $duration_in_months
|
||||
* @property bool $livemode
|
||||
* @property int $max_redemptions
|
||||
* @property StripeObject $metadata
|
||||
* @property int $percent_off
|
||||
* @property int $redeem_by
|
||||
* @property int $times_redeemed
|
||||
* @property bool $valid
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Coupon extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the coupon to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Coupon
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Coupon The created coupon.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the coupon to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Coupon The updated coupon.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Coupon The deleted coupon.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Coupon The saved coupon.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Coupons
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Stripe;
|
||||
* @property mixed $discount
|
||||
* @property string $email
|
||||
* @property bool $livemode
|
||||
* @property array $metadata
|
||||
* @property StripeObject $metadata
|
||||
* @property mixed $shipping
|
||||
* @property Collection $sources
|
||||
* @property Collection $subscriptions
|
||||
@ -26,71 +26,25 @@ namespace Stripe;
|
||||
*/
|
||||
class Customer extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the customer to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Customer
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\NestedResource;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
public static function getSavedNestedResources()
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
static $savedNestedResources = null;
|
||||
if ($savedNestedResources === null) {
|
||||
$savedNestedResources = new Util\Set([
|
||||
'source',
|
||||
]);
|
||||
}
|
||||
return $savedNestedResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Customers
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Customer The created customer.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the customer to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Customer The updated customer.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Customer The saved customer.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Customer The deleted customer.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
const PATH_SOURCES = '/sources';
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
@ -99,9 +53,7 @@ class Customer extends ApiResource
|
||||
*/
|
||||
public function addInvoiceItem($params = null)
|
||||
{
|
||||
if (!$params) {
|
||||
$params = array();
|
||||
}
|
||||
$params = $params ?: [];
|
||||
$params['customer'] = $this->id;
|
||||
$ii = InvoiceItem::create($params, $this->_opts);
|
||||
return $ii;
|
||||
@ -114,9 +66,7 @@ class Customer extends ApiResource
|
||||
*/
|
||||
public function invoices($params = null)
|
||||
{
|
||||
if (!$params) {
|
||||
$params = array();
|
||||
}
|
||||
$params = $params ?: [];
|
||||
$params['customer'] = $this->id;
|
||||
$invoices = Invoice::all($params, $this->_opts);
|
||||
return $invoices;
|
||||
@ -129,9 +79,7 @@ class Customer extends ApiResource
|
||||
*/
|
||||
public function invoiceItems($params = null)
|
||||
{
|
||||
if (!$params) {
|
||||
$params = array();
|
||||
}
|
||||
$params = $params ?: [];
|
||||
$params['customer'] = $this->id;
|
||||
$iis = InvoiceItem::all($params, $this->_opts);
|
||||
return $iis;
|
||||
@ -144,9 +92,7 @@ class Customer extends ApiResource
|
||||
*/
|
||||
public function charges($params = null)
|
||||
{
|
||||
if (!$params) {
|
||||
$params = array();
|
||||
}
|
||||
$params = $params ?: [];
|
||||
$params['customer'] = $this->id;
|
||||
$charges = Charge::all($params, $this->_opts);
|
||||
return $charges;
|
||||
@ -161,7 +107,7 @@ class Customer extends ApiResource
|
||||
{
|
||||
$url = $this->instanceUrl() . '/subscription';
|
||||
list($response, $opts) = $this->_request('post', $url, $params);
|
||||
$this->refreshFrom(array('subscription' => $response), $opts, true);
|
||||
$this->refreshFrom(['subscription' => $response], $opts, true);
|
||||
return $this->subscription;
|
||||
}
|
||||
|
||||
@ -174,7 +120,7 @@ class Customer extends ApiResource
|
||||
{
|
||||
$url = $this->instanceUrl() . '/subscription';
|
||||
list($response, $opts) = $this->_request('delete', $url, $params);
|
||||
$this->refreshFrom(array('subscription' => $response), $opts, true);
|
||||
$this->refreshFrom(['subscription' => $response], $opts, true);
|
||||
return $this->subscription;
|
||||
}
|
||||
|
||||
@ -185,6 +131,69 @@ class Customer extends ApiResource
|
||||
{
|
||||
$url = $this->instanceUrl() . '/discount';
|
||||
list($response, $opts) = $this->_request('delete', $url);
|
||||
$this->refreshFrom(array('discount' => null), $opts, true);
|
||||
$this->refreshFrom(['discount' => null], $opts, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the customer on which to create the source.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApiResource
|
||||
*/
|
||||
public static function createSource($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_createNestedResource($id, static::PATH_SOURCES, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApiResource
|
||||
*/
|
||||
public static function retrieveSource($id, $sourceId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_retrieveNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApiResource
|
||||
*/
|
||||
public static function updateSource($id, $sourceId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_updateNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApiResource
|
||||
*/
|
||||
public static function deleteSource($id, $sourceId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_deleteNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the customer on which to retrieve the sources.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ApiResource
|
||||
*/
|
||||
public static function allSources($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_allNestedResources($id, static::PATH_SOURCES, $params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Stripe;
|
||||
* @property mixed $evidence_details
|
||||
* @property bool $is_charge_refundable
|
||||
* @property bool $livemode
|
||||
* @property mixed $metadata
|
||||
* @property StripeObject $metadata
|
||||
* @property string $reason
|
||||
* @property string $status
|
||||
*
|
||||
@ -24,49 +24,40 @@ namespace Stripe;
|
||||
*/
|
||||
class Dispute extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the dispute to retrieve.
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Dispute
|
||||
*/
|
||||
public static function retrieve($id, $options = null)
|
||||
{
|
||||
return self::_retrieve($id, $options);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return array An array of Disputes.
|
||||
* Possible string representations of dispute reasons.
|
||||
* @link https://stripe.com/docs/api#dispute_object
|
||||
*/
|
||||
public static function all($params = null, $options = null)
|
||||
{
|
||||
return self::_all($params, $options);
|
||||
}
|
||||
const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process';
|
||||
const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed';
|
||||
const REASON_CUSTOMER_INITIATED = 'customer_initiated';
|
||||
const REASON_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';
|
||||
const REASON_DUPLICATE = 'duplicate';
|
||||
const REASON_FRAUDULENT = 'fraudulent';
|
||||
const REASON_GENERAL = 'general';
|
||||
const REASON_INCORRECT_ACCOUNT_DETAILS = 'incorrect_account_details';
|
||||
const REASON_INSUFFICIENT_FUNDS = 'insufficient_funds';
|
||||
const REASON_PRODUCT_NOT_RECEIVED = 'product_not_received';
|
||||
const REASON_PRODUCT_UNACCEPTABLE = 'product_unacceptable';
|
||||
const REASON_SUBSCRIPTION_CANCELED = 'subscription_canceled';
|
||||
const REASON_UNRECOGNIZED = 'unrecognized';
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the dispute to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Dispute The updated dispute.
|
||||
* Possible string representations of dispute statuses.
|
||||
* @link https://stripe.com/docs/api#dispute_object
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Dispute The saved charge.
|
||||
*/
|
||||
public function save($options = null)
|
||||
{
|
||||
return $this->_save($options);
|
||||
}
|
||||
const STATUS_CHARGE_REFUNDED = 'charge_refunded';
|
||||
const STATUS_LOST = 'lost';
|
||||
const STATUS_NEEDS_RESPONSE = 'needs_response';
|
||||
const STATUS_UNDER_REVIEW = 'under_review';
|
||||
const STATUS_WARNING_CLOSED = 'warning_closed';
|
||||
const STATUS_WARNING_NEEDS_RESPONSE = 'warning_needs_response';
|
||||
const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review';
|
||||
const STATUS_WON = 'won';
|
||||
|
||||
/**
|
||||
* @param array|string|null $options
|
||||
|
||||
49
htdocs/includes/stripe/lib/EphemeralKey.php
Normal file
49
htdocs/includes/stripe/lib/EphemeralKey.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
/**
|
||||
* Class EphemeralKey
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $created
|
||||
* @property int $expires
|
||||
* @property bool $livemode
|
||||
* @property string $secret
|
||||
* @property array $associated_objects
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class EphemeralKey extends ApiResource
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return EphemeralKey The created key.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
if (!$opts['stripe_version']) {
|
||||
throw new \InvalidArgumentException('stripe_version must be specified to create an ephemeral key');
|
||||
}
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
}
|
||||
@ -12,32 +12,103 @@ namespace Stripe;
|
||||
* @property mixed $data
|
||||
* @property bool $livemode
|
||||
* @property int $pending_webhooks
|
||||
* @property string $request
|
||||
* @property mixed $request
|
||||
* @property string $type
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Event extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the event to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Event
|
||||
/**
|
||||
* Possible string representations of event types.
|
||||
* @link https://stripe.com/docs/api#event_types
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
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';
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Events
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Retrieve;
|
||||
}
|
||||
|
||||
25
htdocs/includes/stripe/lib/ExchangeRate.php
Normal file
25
htdocs/includes/stripe/lib/ExchangeRate.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
/**
|
||||
* Class ExchangeRate
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class ExchangeRate extends ApiResource
|
||||
{
|
||||
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';
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,9 @@ namespace Stripe;
|
||||
/**
|
||||
* Class ExternalAccount
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
abstract class ExternalAccount extends ApiResource
|
||||
|
||||
@ -16,6 +16,10 @@ namespace Stripe;
|
||||
*/
|
||||
class FileUpload extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
|
||||
public static function baseUrl()
|
||||
{
|
||||
return Stripe::$apiUploadBase;
|
||||
@ -25,37 +29,4 @@ class FileUpload extends ApiResource
|
||||
{
|
||||
return 'file';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the file upload to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return FileUpload
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return FileUpload The created file upload.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of FileUploads
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,54 +5,52 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Invoice
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount_due
|
||||
* @property int $amount_paid
|
||||
* @property int $amount_remaining
|
||||
* @property int $application_fee
|
||||
* @property int $attempt_count
|
||||
* @property bool $attempted
|
||||
* @property string $billing
|
||||
* @property string $charge
|
||||
* @property bool $closed
|
||||
* @property string $currency
|
||||
* @property string $customer
|
||||
* @property int $date
|
||||
* @property string $description
|
||||
* @property mixed $discount
|
||||
* @property int $due_date
|
||||
* @property int $ending_balance
|
||||
* @property bool $forgiven
|
||||
* @property Collection $lines
|
||||
* @property bool $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property int $next_payment_attempt
|
||||
* @property string $number
|
||||
* @property bool $paid
|
||||
* @property int $period_end
|
||||
* @property int $period_start
|
||||
* @property string $receipt_number
|
||||
* @property int $starting_balance
|
||||
* @property string $statement_descriptor
|
||||
* @property string $subscription
|
||||
* @property int $subscription_proration_date
|
||||
* @property int $subtotal
|
||||
* @property int $tax
|
||||
* @property float $tax_percent
|
||||
* @property int $total
|
||||
* @property int $webhooks_delivered_at
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Invoice extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Invoice The created invoice.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the invoice to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Invoice
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Invoices
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the invoice to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Invoice The updated invoice.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
@ -69,23 +67,13 @@ class Invoice extends ApiResource
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Invoice The saved invoice.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Invoice The paid invoice.
|
||||
*/
|
||||
public function pay($opts = null)
|
||||
public function pay($params = null, $opts = null)
|
||||
{
|
||||
$url = $this->instanceUrl() . '/pay';
|
||||
list($response, $opts) = $this->_request('post', $url, null, $opts);
|
||||
list($response, $opts) = $this->_request('post', $url, $params, $opts);
|
||||
$this->refreshFrom($response, $opts);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -5,73 +5,31 @@ namespace Stripe;
|
||||
/**
|
||||
* Class InvoiceItem
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property string $currency
|
||||
* @property string $customer
|
||||
* @property int $date
|
||||
* @property string $description
|
||||
* @property bool $discountable
|
||||
* @property string $invoice
|
||||
* @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
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class InvoiceItem extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the invoice item to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return InvoiceItem
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of InvoiceItems
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return InvoiceItem The created invoice item.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the invoice item to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return InvoiceItem The updated invoice item.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return InvoiceItem The saved invoice item.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return InvoiceItem The deleted invoice item.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
|
||||
13
htdocs/includes/stripe/lib/LoginLink.php
Normal file
13
htdocs/includes/stripe/lib/LoginLink.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
/**
|
||||
* Class LoginLink
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class LoginLink extends ApiResource
|
||||
{
|
||||
|
||||
}
|
||||
93
htdocs/includes/stripe/lib/OAuth.php
Normal file
93
htdocs/includes/stripe/lib/OAuth.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
abstract class OAuth
|
||||
{
|
||||
/**
|
||||
* Generates a URL to Stripe's OAuth form.
|
||||
*
|
||||
* @param array|null $params
|
||||
* @param array|null $opts
|
||||
*
|
||||
* @return string The URL to Stripe's OAuth form.
|
||||
*/
|
||||
public static function authorizeUrl($params = null, $opts = null)
|
||||
{
|
||||
$params = $params ?: [];
|
||||
|
||||
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
|
||||
|
||||
$params['client_id'] = self::_getClientId($params);
|
||||
if (!array_key_exists('response_type', $params)) {
|
||||
$params['response_type'] = 'code';
|
||||
}
|
||||
$query = Util\Util::urlEncode($params);
|
||||
|
||||
return $base . '/oauth/authorize?' . $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use an authoriztion code to connect an account to your platform and
|
||||
* fetch the user's credentials.
|
||||
*
|
||||
* @param array|null $params
|
||||
* @param array|null $opts
|
||||
*
|
||||
* @return StripeObject Object containing the response from the API.
|
||||
*/
|
||||
public static function token($params = null, $opts = null)
|
||||
{
|
||||
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
|
||||
$requestor = new ApiRequestor(null, $base);
|
||||
list($response, $apiKey) = $requestor->request(
|
||||
'post',
|
||||
'/oauth/token',
|
||||
$params,
|
||||
null
|
||||
);
|
||||
return Util\Util::convertToStripeObject($response->json, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects an account from your platform.
|
||||
*
|
||||
* @param array|null $params
|
||||
* @param array|null $opts
|
||||
*
|
||||
* @return StripeObject Object containing the response from the API.
|
||||
*/
|
||||
public static function deauthorize($params = null, $opts = null)
|
||||
{
|
||||
$params = $params ?: [];
|
||||
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
|
||||
$requestor = new ApiRequestor(null, $base);
|
||||
$params['client_id'] = self::_getClientId($params);
|
||||
list($response, $apiKey) = $requestor->request(
|
||||
'post',
|
||||
'/oauth/deauthorize',
|
||||
$params,
|
||||
null
|
||||
);
|
||||
return Util\Util::convertToStripeObject($response->json, $opts);
|
||||
}
|
||||
|
||||
private static function _getClientId($params = null)
|
||||
{
|
||||
$clientId = ($params && array_key_exists('client_id', $params)) ? $params['client_id'] : null;
|
||||
if ($clientId === null) {
|
||||
$clientId = Stripe::getClientId();
|
||||
}
|
||||
if ($clientId === null) {
|
||||
$msg = 'No client_id provided. (HINT: set your client_id using '
|
||||
. '"Stripe::setClientId(<CLIENT-ID>)". You can find your client_ids '
|
||||
. 'in your Stripe dashboard at '
|
||||
. 'https://dashboard.stripe.com/account/applications/settings, '
|
||||
. 'after registering your account as a platform. See '
|
||||
. 'https://stripe.com/docs/connect/standard-accounts for details, '
|
||||
. 'or email support@stripe.com if you have any questions.';
|
||||
throw new Error\Authentication($msg);
|
||||
}
|
||||
return $clientId;
|
||||
}
|
||||
}
|
||||
@ -5,64 +5,38 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Order
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property int $amount_returned
|
||||
* @property string $application
|
||||
* @property int $application_fee
|
||||
* @property string $charge
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $customer
|
||||
* @property string $email
|
||||
* @property string $external_coupon_code
|
||||
* @property mixed $items
|
||||
* @property bool $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property Collection $returns
|
||||
* @property string $selected_shipping_method
|
||||
* @property mixed $shipping
|
||||
* @property mixed $shipping_methods
|
||||
* @property string $status
|
||||
* @property mixed $status_transitions
|
||||
* @property int $updated
|
||||
* @property string $upstream_id
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Order extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the Order to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Order
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Order The created Order.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the order to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Order The updated order.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Order The saved Order.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Orders
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @return Order The paid order.
|
||||
|
||||
@ -9,25 +9,17 @@ namespace Stripe;
|
||||
*/
|
||||
class OrderReturn extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the OrderReturn to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Order
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Retrieve;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
* This is a special case because the order returns endpoint has an
|
||||
* underscore in it. The parent `className` function strips underscores.
|
||||
*
|
||||
* @return Collection of OrderReturns
|
||||
* @return string The name of the class.
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
public static function className()
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
return 'order_return';
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Stripe;
|
||||
* @property string $failure_code
|
||||
* @property string $failure_message
|
||||
* @property bool $livemode
|
||||
* @property mixed $metadata
|
||||
* @property StripeObject $metadata
|
||||
* @property string $method
|
||||
* @property string $recipient
|
||||
* @property string $source_type
|
||||
@ -29,50 +29,10 @@ namespace Stripe;
|
||||
*/
|
||||
class Payout extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the payout to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Payout
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Payouts
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Payout The created payout.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the payout to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Payout The updated payout.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @return Payout The canceled payout.
|
||||
@ -84,14 +44,4 @@ class Payout extends ApiResource
|
||||
$this->refreshFrom($response, $opts);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Payout The saved payout.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,84 +7,24 @@ namespace Stripe;
|
||||
*
|
||||
* @package Stripe
|
||||
*
|
||||
* @property $id
|
||||
* @property $object
|
||||
* @property $amount
|
||||
* @property $created
|
||||
* @property $currency
|
||||
* @property $interval
|
||||
* @property $interval_count
|
||||
* @property $livemode
|
||||
* @property AttachedObject $metadata
|
||||
* @property $name
|
||||
* @property $statement_descriptor
|
||||
* @property $trial_period_days
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $interval
|
||||
* @property int $interval_count
|
||||
* @property bool $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property string $nickname
|
||||
* @property string $product
|
||||
* @property int $trial_period_days
|
||||
*/
|
||||
class Plan extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the plan to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Plan
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Plan The created plan.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the plan to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Plan The updated plan.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Plan The deleted plan.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Plan The saved plan.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Plans
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
|
||||
@ -5,73 +5,33 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Product
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property bool $active
|
||||
* @property string[] $attributes
|
||||
* @property string $caption
|
||||
* @property int $created
|
||||
* @property string[] $deactivate_on
|
||||
* @property string $description
|
||||
* @property array $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 int $updated
|
||||
* @property string $url
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Product extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the Product to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Product
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Product The created Product.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the product to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Product The updated product.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Product The saved Product.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Products
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Product The deleted product.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
|
||||
@ -9,71 +9,11 @@ namespace Stripe;
|
||||
*/
|
||||
class Recipient extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the recipient to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Recipient
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Recipients
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Recipient The created recipient.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the recipient to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Recipient The updated recipient.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Recipient The saved recipient.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
*
|
||||
* @return Recipient The deleted recipient.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
@ -82,9 +22,7 @@ class Recipient extends ApiResource
|
||||
*/
|
||||
public function transfers($params = null)
|
||||
{
|
||||
if ($params === null) {
|
||||
$params = array();
|
||||
}
|
||||
$params = $params ?: [];
|
||||
$params['recipient'] = $this->id;
|
||||
$transfers = Transfer::all($params, $this->_opts);
|
||||
return $transfers;
|
||||
|
||||
@ -20,7 +20,7 @@ namespace Stripe;
|
||||
* @property string $failure_code
|
||||
* @property string $failure_message
|
||||
* @property bool $livemode
|
||||
* @property mixed $metadata
|
||||
* @property StripeObject $metadata
|
||||
* @property string $method
|
||||
* @property string $recipient
|
||||
* @property mixed $reversals
|
||||
|
||||
@ -8,11 +8,13 @@ namespace Stripe;
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property mixed $balance_transaction
|
||||
* @property string $balance_transaction
|
||||
* @property string $charge
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property mixed $metadata
|
||||
* @property string $failure_balance_transaction
|
||||
* @property string failure_reason
|
||||
* @property StripeObject $metadata
|
||||
* @property mixed $reason
|
||||
* @property mixed $receipt_number
|
||||
* @property string $status
|
||||
@ -21,59 +23,8 @@ namespace Stripe;
|
||||
*/
|
||||
class Refund extends ApiResource
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the refund to retrieve.
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Refund
|
||||
*/
|
||||
public static function retrieve($id, $options = null)
|
||||
{
|
||||
return self::_retrieve($id, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the refund to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Refund The updated refund.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Collection of Refunds
|
||||
*/
|
||||
public static function all($params = null, $options = null)
|
||||
{
|
||||
return self::_all($params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Refund The created refund.
|
||||
*/
|
||||
public static function create($params = null, $options = null)
|
||||
{
|
||||
return self::_create($params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Refund The saved refund.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
|
||||
@ -5,73 +5,28 @@ namespace Stripe;
|
||||
/**
|
||||
* Class SKU
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property bool $active
|
||||
* @property mixed $attributes
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $image
|
||||
* @property mixed $inventory
|
||||
* @property bool $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property mixed $package_dimensions
|
||||
* @property int $price
|
||||
* @property string $product
|
||||
* @property int $updated
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class SKU extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the SKU to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SKU
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SKU The created SKU.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the SKU to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return SKU The updated SKU.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SKU The saved SKU.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of SKUs
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SKU The deleted sku.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
|
||||
@ -5,72 +5,39 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Source
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property string $client_secret
|
||||
* @property mixed $code_verification
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $flow
|
||||
* @property bool $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property mixed $owner
|
||||
* @property mixed $receiver
|
||||
* @property mixed $redirect
|
||||
* @property string $statement_descriptor
|
||||
* @property string $status
|
||||
* @property string $type
|
||||
* @property string $usage
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Source extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the Source to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Source
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Sources
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Source The created Source.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the source to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Source The updated source.
|
||||
* @return Source The detached source.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Source The saved source.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Source The deleted source.
|
||||
*/
|
||||
public function delete($params = null, $options = null)
|
||||
public function detach($params = null, $options = null)
|
||||
{
|
||||
self::_validateParams($params);
|
||||
|
||||
@ -92,9 +59,8 @@ class Source extends ApiResource
|
||||
$this->refreshFrom($response, $opts);
|
||||
return $this;
|
||||
} else {
|
||||
$message = "Source objects cannot be deleted, they can only be "
|
||||
. "detached from customer objects. This source object does not "
|
||||
. "appear to be currently attached to a customer object.";
|
||||
$message = "This source object does not appear to be currently attached "
|
||||
. "to a customer object.";
|
||||
throw new Error\Api($message);
|
||||
}
|
||||
}
|
||||
@ -103,7 +69,35 @@ class Source extends ApiResource
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return BankAccount The verified bank account.
|
||||
* @return Source The detached source.
|
||||
*
|
||||
* @deprecated Use the `detach` method instead.
|
||||
*/
|
||||
public function delete($params = null, $options = null)
|
||||
{
|
||||
$this->detach($params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Collection The list of source transactions.
|
||||
*/
|
||||
public function sourceTransactions($params = null, $options = null)
|
||||
{
|
||||
$url = $this->instanceUrl() . '/source_transactions';
|
||||
list($response, $opts) = $this->_request('get', $url, $params, $options);
|
||||
$obj = Util\Util::convertToStripeObject($response, $opts);
|
||||
$obj->setLastResponse($response);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Source The verified source.
|
||||
*/
|
||||
public function verify($params = null, $options = null)
|
||||
{
|
||||
|
||||
13
htdocs/includes/stripe/lib/SourceTransaction.php
Normal file
13
htdocs/includes/stripe/lib/SourceTransaction.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
/**
|
||||
* Class SourceTransaction
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class SourceTransaction extends ApiResource
|
||||
{
|
||||
|
||||
}
|
||||
@ -12,9 +12,15 @@ class Stripe
|
||||
// @var string The Stripe API key to be used for requests.
|
||||
public static $apiKey;
|
||||
|
||||
// @var string The Stripe client_id to be used for Connect requests.
|
||||
public static $clientId;
|
||||
|
||||
// @var string The base URL for the Stripe API.
|
||||
public static $apiBase = 'https://api.stripe.com';
|
||||
|
||||
// @var string The base URL for the OAuth API.
|
||||
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';
|
||||
|
||||
@ -24,13 +30,29 @@ class Stripe
|
||||
// @var string|null The account ID for connected accounts requests.
|
||||
public static $accountId = null;
|
||||
|
||||
// @var string Path to the CA bundle used to verify SSL certificates
|
||||
public static $caBundlePath = null;
|
||||
|
||||
// @var boolean Defaults to true.
|
||||
public static $verifySslCerts = true;
|
||||
|
||||
// @var array The application's information (name, version, URL)
|
||||
public static $appInfo = null;
|
||||
|
||||
const VERSION = '4.7.0';
|
||||
// @var Util\LoggerInterface|null The logger to which the library will
|
||||
// produce messages.
|
||||
public static $logger = null;
|
||||
|
||||
// @var int Maximum number of request retries
|
||||
public static $maxNetworkRetries = 0;
|
||||
|
||||
// @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';
|
||||
|
||||
/**
|
||||
* @return string The API key used for requests.
|
||||
@ -40,6 +62,35 @@ class Stripe
|
||||
return self::$apiKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The client_id used for Connect requests.
|
||||
*/
|
||||
public static function getClientId()
|
||||
{
|
||||
return self::$clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Util\LoggerInterface The logger to which the library will
|
||||
* produce messages.
|
||||
*/
|
||||
public static function getLogger()
|
||||
{
|
||||
if (self::$logger == null) {
|
||||
return new Util\DefaultLogger();
|
||||
}
|
||||
return self::$logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Util\LoggerInterface $logger The logger to which the library
|
||||
* will produce messages.
|
||||
*/
|
||||
public static function setLogger($logger)
|
||||
{
|
||||
self::$logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the API key to be used for requests.
|
||||
*
|
||||
@ -50,6 +101,16 @@ class Stripe
|
||||
self::$apiKey = $apiKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client_id to be used for Connect requests.
|
||||
*
|
||||
* @param string $clientId
|
||||
*/
|
||||
public static function setClientId($clientId)
|
||||
{
|
||||
self::$clientId = $clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The API version used for requests. null if we're using the
|
||||
* latest version.
|
||||
@ -67,6 +128,30 @@ class Stripe
|
||||
self::$apiVersion = $apiVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private static function getDefaultCABundlePath()
|
||||
{
|
||||
return realpath(dirname(__FILE__) . '/../data/ca-certificates.crt');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getCABundlePath()
|
||||
{
|
||||
return self::$caBundlePath ?: self::getDefaultCABundlePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $caBundlePath
|
||||
*/
|
||||
public static function setCABundlePath($caBundlePath)
|
||||
{
|
||||
self::$caBundlePath = $caBundlePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
@ -116,11 +201,41 @@ class Stripe
|
||||
*/
|
||||
public static function setAppInfo($appName, $appVersion = null, $appUrl = null)
|
||||
{
|
||||
if (self::$appInfo === null) {
|
||||
self::$appInfo = array();
|
||||
}
|
||||
self::$appInfo = self::$appInfo ?: [];
|
||||
self::$appInfo['name'] = $appName;
|
||||
self::$appInfo['version'] = $appVersion;
|
||||
self::$appInfo['url'] = $appUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int Maximum number of request retries
|
||||
*/
|
||||
public static function getMaxNetworkRetries()
|
||||
{
|
||||
return self::$maxNetworkRetries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $maxNetworkRetries Maximum number of request retries
|
||||
*/
|
||||
public static function setMaxNetworkRetries($maxNetworkRetries)
|
||||
{
|
||||
self::$maxNetworkRetries = $maxNetworkRetries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float Maximum delay between retries, in seconds
|
||||
*/
|
||||
public static function getMaxNetworkRetryDelay()
|
||||
{
|
||||
return self::$maxNetworkRetryDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float Initial delay between retries, in seconds
|
||||
*/
|
||||
public static function getInitialNetworkRetryDelay()
|
||||
{
|
||||
return self::$initialNetworkRetryDelay;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,38 +2,425 @@
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
use ArrayAccess;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class StripeObject
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class StripeObject implements ArrayAccess, JsonSerializable
|
||||
class StripeObject implements \ArrayAccess, \Countable, \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var Util\Set Attributes that should not be sent to the API because
|
||||
* they're not updatable (e.g. API key, ID).
|
||||
*/
|
||||
public static $permanentAttributes;
|
||||
/**
|
||||
* @var Util\Set Attributes that are nested but still updatable from
|
||||
* the parent class's URL (e.g. metadata).
|
||||
*/
|
||||
public static $nestedUpdatableAttributes;
|
||||
protected $_opts;
|
||||
protected $_originalValues;
|
||||
protected $_values;
|
||||
protected $_unsavedValues;
|
||||
protected $_transientValues;
|
||||
protected $_retrieveOptions;
|
||||
protected $_lastResponse;
|
||||
|
||||
public static function init()
|
||||
/**
|
||||
* @return Util\Set Attributes that should not be sent to the API because
|
||||
* they're not updatable (e.g. ID).
|
||||
*/
|
||||
public static function getPermanentAttributes()
|
||||
{
|
||||
self::$permanentAttributes = new Util\Set(array('_opts', 'id'));
|
||||
self::$nestedUpdatableAttributes = new Util\Set(array(
|
||||
'metadata', 'legal_entity', 'address', 'dob', 'transfer_schedule', 'verification',
|
||||
'tos_acceptance', 'personal_address',
|
||||
// will make the array into an AttachedObject: weird, but works for now
|
||||
'additional_owners', 0, 1, 2, 3, 4, // Max 3, but leave the 4th so errors work properly
|
||||
'inventory',
|
||||
'owner',
|
||||
));
|
||||
static $permanentAttributes = null;
|
||||
if ($permanentAttributes === null) {
|
||||
$permanentAttributes = new Util\Set([
|
||||
'id',
|
||||
]);
|
||||
}
|
||||
return $permanentAttributes;
|
||||
}
|
||||
|
||||
public function __construct($id = null, $opts = null)
|
||||
{
|
||||
list($id, $this->_retrieveOptions) = Util\Util::normalizeId($id);
|
||||
$this->_opts = Util\RequestOptions::parse($opts);
|
||||
$this->_originalValues = [];
|
||||
$this->_values = [];
|
||||
$this->_unsavedValues = new Util\Set();
|
||||
$this->_transientValues = new Util\Set();
|
||||
if ($id !== null) {
|
||||
$this->_values['id'] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
// Standard accessor magic methods
|
||||
public function __set($k, $v)
|
||||
{
|
||||
if (static::getPermanentAttributes()->includes($k)) {
|
||||
throw new \InvalidArgumentException(
|
||||
"Cannot set $k on this object. HINT: you can't set: " .
|
||||
join(', ', static::getPermanentAttributes()->toArray())
|
||||
);
|
||||
}
|
||||
|
||||
if ($v === "") {
|
||||
throw new \InvalidArgumentException(
|
||||
'You cannot set \''.$k.'\'to an empty string. '
|
||||
.'We interpret empty strings as NULL in requests. '
|
||||
.'You may set obj->'.$k.' = NULL to delete the property'
|
||||
);
|
||||
}
|
||||
|
||||
$this->_values[$k] = Util\Util::convertToStripeObject($v, $this->_opts);
|
||||
$this->dirtyValue($this->_values[$k]);
|
||||
$this->_unsavedValues->add($k);
|
||||
}
|
||||
|
||||
public function __isset($k)
|
||||
{
|
||||
return isset($this->_values[$k]);
|
||||
}
|
||||
|
||||
public function __unset($k)
|
||||
{
|
||||
unset($this->_values[$k]);
|
||||
$this->_transientValues->add($k);
|
||||
$this->_unsavedValues->discard($k);
|
||||
}
|
||||
|
||||
public function &__get($k)
|
||||
{
|
||||
// function should return a reference, using $nullval to return a reference to null
|
||||
$nullval = null;
|
||||
if (!empty($this->_values) && array_key_exists($k, $this->_values)) {
|
||||
return $this->_values[$k];
|
||||
} else if (!empty($this->_transientValues) && $this->_transientValues->includes($k)) {
|
||||
$class = get_class($this);
|
||||
$attrs = join(', ', array_keys($this->_values));
|
||||
$message = "Stripe Notice: Undefined property of $class instance: $k. "
|
||||
. "HINT: The $k attribute was set in the past, however. "
|
||||
. "It was then wiped when refreshing the object "
|
||||
. "with the result returned by Stripe's API, "
|
||||
. "probably as a result of a save(). The attributes currently "
|
||||
. "available on this object are: $attrs";
|
||||
Stripe::getLogger()->error($message);
|
||||
return $nullval;
|
||||
} else {
|
||||
$class = get_class($this);
|
||||
Stripe::getLogger()->error("Stripe Notice: Undefined property of $class instance: $k");
|
||||
return $nullval;
|
||||
}
|
||||
}
|
||||
|
||||
// Magic method for var_dump output. Only works with PHP >= 5.6
|
||||
public function __debugInfo()
|
||||
{
|
||||
return $this->_values;
|
||||
}
|
||||
|
||||
// ArrayAccess methods
|
||||
public function offsetSet($k, $v)
|
||||
{
|
||||
$this->$k = $v;
|
||||
}
|
||||
|
||||
public function offsetExists($k)
|
||||
{
|
||||
return array_key_exists($k, $this->_values);
|
||||
}
|
||||
|
||||
public function offsetUnset($k)
|
||||
{
|
||||
unset($this->$k);
|
||||
}
|
||||
|
||||
public function offsetGet($k)
|
||||
{
|
||||
return array_key_exists($k, $this->_values) ? $this->_values[$k] : null;
|
||||
}
|
||||
|
||||
// Countable method
|
||||
public function count()
|
||||
{
|
||||
return count($this->_values);
|
||||
}
|
||||
|
||||
public function keys()
|
||||
{
|
||||
return array_keys($this->_values);
|
||||
}
|
||||
|
||||
public function values()
|
||||
{
|
||||
return array_values($this->_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* This unfortunately needs to be public to be used in Util\Util
|
||||
*
|
||||
* @param array $values
|
||||
* @param null|string|array|Util\RequestOptions $opts
|
||||
*
|
||||
* @return StripeObject The object constructed from the given values.
|
||||
*/
|
||||
public static function constructFrom($values, $opts = null)
|
||||
{
|
||||
$obj = new static(isset($values['id']) ? $values['id'] : null);
|
||||
$obj->refreshFrom($values, $opts);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes this object using the provided values.
|
||||
*
|
||||
* @param array $values
|
||||
* @param null|string|array|Util\RequestOptions $opts
|
||||
* @param boolean $partial Defaults to false.
|
||||
*/
|
||||
public function refreshFrom($values, $opts, $partial = false)
|
||||
{
|
||||
$this->_opts = Util\RequestOptions::parse($opts);
|
||||
|
||||
$this->_originalValues = self::deepCopy($values);
|
||||
|
||||
if ($values instanceof StripeObject) {
|
||||
$values = $values->__toArray(true);
|
||||
}
|
||||
|
||||
// Wipe old state before setting new. This is useful for e.g. updating a
|
||||
// customer, where there is no persistent card parameter. Mark those values
|
||||
// which don't persist as transient
|
||||
if ($partial) {
|
||||
$removed = new Util\Set();
|
||||
} else {
|
||||
$removed = new Util\Set(array_diff(array_keys($this->_values), array_keys($values)));
|
||||
}
|
||||
|
||||
foreach ($removed->toArray() as $k) {
|
||||
unset($this->$k);
|
||||
}
|
||||
|
||||
$this->updateAttributes($values, $opts, false);
|
||||
foreach ($values as $k => $v) {
|
||||
$this->_transientValues->discard($k);
|
||||
$this->_unsavedValues->discard($k);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass assigns attributes on the model.
|
||||
*
|
||||
* @param array $values
|
||||
* @param null|string|array|Util\RequestOptions $opts
|
||||
* @param boolean $dirty Defaults to true.
|
||||
*/
|
||||
public function updateAttributes($values, $opts = null, $dirty = true)
|
||||
{
|
||||
foreach ($values as $k => $v) {
|
||||
// Special-case metadata to always be cast as a StripeObject
|
||||
// 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") {
|
||||
$this->_values[$k] = StripeObject::constructFrom($v, $opts);
|
||||
} else {
|
||||
$this->_values[$k] = Util\Util::convertToStripeObject($v, $opts);
|
||||
}
|
||||
if ($dirty) {
|
||||
$this->dirtyValue($this->_values[$k]);
|
||||
}
|
||||
$this->_unsavedValues->add($k);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array A recursive mapping of attributes to values for this object,
|
||||
* including the proper value for deleted attributes.
|
||||
*/
|
||||
public function serializeParameters($force = false)
|
||||
{
|
||||
$updateParams = [];
|
||||
|
||||
foreach ($this->_values as $k => $v) {
|
||||
// There are a few reasons that we may want to add in a parameter for
|
||||
// update:
|
||||
//
|
||||
// 1. The `$force` option has been set.
|
||||
// 2. We know that it was modified.
|
||||
// 3. Its value is a StripeObject. A StripeObject may contain modified
|
||||
// values within in that its parent StripeObject doesn't know about.
|
||||
//
|
||||
$original = array_key_exists($k, $this->_originalValues) ? $this->_originalValues[$k] : null;
|
||||
$unsaved = $this->_unsavedValues->includes($k);
|
||||
if ($force || $unsaved || $v instanceof StripeObject) {
|
||||
$updateParams[$k] = $this->serializeParamsValue(
|
||||
$this->_values[$k],
|
||||
$original,
|
||||
$unsaved,
|
||||
$force,
|
||||
$k
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// a `null` that makes it out of `serializeParamsValue` signals an empty
|
||||
// value that we shouldn't appear in the serialized form of the object
|
||||
$updateParams = array_filter(
|
||||
$updateParams,
|
||||
function ($v) {
|
||||
return $v !== null;
|
||||
}
|
||||
);
|
||||
|
||||
return $updateParams;
|
||||
}
|
||||
|
||||
|
||||
public function serializeParamsValue($value, $original, $unsaved, $force, $key = null)
|
||||
{
|
||||
// The logic here is that essentially any object embedded in another
|
||||
// object that had a `type` is actually an API resource of a different
|
||||
// type that's been included in the response. These other resources must
|
||||
// be updated from their proper endpoints, and therefore they are not
|
||||
// included when serializing even if they've been modified.
|
||||
//
|
||||
// There are _some_ known exceptions though.
|
||||
//
|
||||
// For example, if the value is unsaved (meaning the user has set it), and
|
||||
// it looks like the API resource is persisted with an ID, then we include
|
||||
// the object so that parameters are serialized with a reference to its
|
||||
// ID.
|
||||
//
|
||||
// Another example is that on save API calls it's sometimes desirable to
|
||||
// update a customer's default source by setting a new card (or other)
|
||||
// object with `->source=` and then saving the customer. The
|
||||
// `saveWithParent` flag to override the default behavior allows us to
|
||||
// handle these exceptions.
|
||||
//
|
||||
// We throw an error if a property was set explicitly but we can't do
|
||||
// anything with it because the integration is probably not working as the
|
||||
// user intended it to.
|
||||
if ($value === null) {
|
||||
return "";
|
||||
} elseif (($value instanceof APIResource) && (!$value->saveWithParent)) {
|
||||
if (!$unsaved) {
|
||||
return null;
|
||||
} elseif (isset($value->id)) {
|
||||
return $value;
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
"Cannot save property `$key` containing an API resource of type " .
|
||||
get_class($value) . ". It doesn't appear to be persisted and is " .
|
||||
"not marked as `saveWithParent`."
|
||||
);
|
||||
}
|
||||
} elseif (is_array($value)) {
|
||||
if (Util\Util::isList($value)) {
|
||||
// Sequential array, i.e. a list
|
||||
$update = [];
|
||||
foreach ($value as $v) {
|
||||
array_push($update, $this->serializeParamsValue($v, null, true, $force));
|
||||
}
|
||||
// This prevents an array that's unchanged from being resent.
|
||||
if ($update !== $this->serializeParamsValue($original, null, true, $force, $key)) {
|
||||
return $update;
|
||||
}
|
||||
} else {
|
||||
// Associative array, i.e. a map
|
||||
return Util\Util::convertToStripeObject($value, $this->_opts)->serializeParameters();
|
||||
}
|
||||
} elseif ($value instanceof StripeObject) {
|
||||
$update = $value->serializeParameters($force);
|
||||
if ($original && $unsaved) {
|
||||
$update = array_merge(self::emptyValues($original), $update);
|
||||
}
|
||||
return $update;
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->__toArray(true);
|
||||
}
|
||||
|
||||
public function __toJSON()
|
||||
{
|
||||
return json_encode($this->__toArray(true), JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$class = get_class($this);
|
||||
return $class . ' JSON: ' . $this->__toJSON();
|
||||
}
|
||||
|
||||
public function __toArray($recursive = false)
|
||||
{
|
||||
if ($recursive) {
|
||||
return Util\Util::convertStripeObjectToArray($this->_values);
|
||||
} else {
|
||||
return $this->_values;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all keys within the StripeObject as unsaved so that they will be
|
||||
* included with an update when `serializeParameters` is called. This
|
||||
* method is also recursive, so any StripeObjects contained as values or
|
||||
* which are values in a tenant array are also marked as dirty.
|
||||
*/
|
||||
public function dirty()
|
||||
{
|
||||
$this->_unsavedValues = new Util\Set(array_keys($this->_values));
|
||||
foreach ($this->_values as $k => $v) {
|
||||
$this->dirtyValue($v);
|
||||
}
|
||||
}
|
||||
|
||||
protected function dirtyValue($value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $v) {
|
||||
$this->dirtyValue($v);
|
||||
}
|
||||
} elseif ($value instanceof StripeObject) {
|
||||
$value->dirty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a deep copy of the given object including support for arrays
|
||||
* and StripeObjects.
|
||||
*/
|
||||
protected static function deepCopy($obj)
|
||||
{
|
||||
if (is_array($obj)) {
|
||||
$copy = [];
|
||||
foreach ($obj as $k => $v) {
|
||||
$copy[$k] = self::deepCopy($v);
|
||||
}
|
||||
return $copy;
|
||||
} elseif ($obj instanceof StripeObject) {
|
||||
return $obj::constructFrom(
|
||||
self::deepCopy($obj->_values),
|
||||
clone $obj->_opts
|
||||
);
|
||||
} else {
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash of empty values for all the values that are in the given
|
||||
* StripeObject.
|
||||
*/
|
||||
public static function emptyValues($obj)
|
||||
{
|
||||
if (is_array($obj)) {
|
||||
$values = $obj;
|
||||
} elseif ($obj instanceof StripeObject) {
|
||||
$values = $obj->_values;
|
||||
} else {
|
||||
throw new \InvalidArgumentException(
|
||||
"empty_values got got unexpected object type: " . get_class($obj)
|
||||
);
|
||||
}
|
||||
$update = array_fill_keys(array_keys($values), "");
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,242 +440,4 @@ class StripeObject implements ArrayAccess, JsonSerializable
|
||||
{
|
||||
$this->_lastResponse = $resp;
|
||||
}
|
||||
|
||||
protected $_opts;
|
||||
protected $_values;
|
||||
protected $_unsavedValues;
|
||||
protected $_transientValues;
|
||||
protected $_retrieveOptions;
|
||||
protected $_lastResponse;
|
||||
|
||||
public function __construct($id = null, $opts = null)
|
||||
{
|
||||
$this->_opts = $opts ? $opts : new Util\RequestOptions();
|
||||
$this->_values = array();
|
||||
$this->_unsavedValues = new Util\Set();
|
||||
$this->_transientValues = new Util\Set();
|
||||
|
||||
$this->_retrieveOptions = array();
|
||||
if (is_array($id)) {
|
||||
foreach ($id as $key => $value) {
|
||||
if ($key != 'id') {
|
||||
$this->_retrieveOptions[$key] = $value;
|
||||
}
|
||||
}
|
||||
$id = $id['id'];
|
||||
}
|
||||
|
||||
if ($id !== null) {
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
||||
// Standard accessor magic methods
|
||||
public function __set($k, $v)
|
||||
{
|
||||
if ($v === "") {
|
||||
throw new InvalidArgumentException(
|
||||
'You cannot set \''.$k.'\'to an empty string. '
|
||||
.'We interpret empty strings as NULL in requests. '
|
||||
.'You may set obj->'.$k.' = NULL to delete the property'
|
||||
);
|
||||
}
|
||||
|
||||
if (self::$nestedUpdatableAttributes->includes($k)
|
||||
&& isset($this->$k) && $this->$k instanceof AttachedObject && is_array($v)) {
|
||||
$this->$k->replaceWith($v);
|
||||
} else {
|
||||
// TODO: may want to clear from $_transientValues (Won't be user-visible).
|
||||
$this->_values[$k] = $v;
|
||||
}
|
||||
if (!self::$permanentAttributes->includes($k)) {
|
||||
$this->_unsavedValues->add($k);
|
||||
}
|
||||
}
|
||||
|
||||
public function __isset($k)
|
||||
{
|
||||
return isset($this->_values[$k]);
|
||||
}
|
||||
public function __unset($k)
|
||||
{
|
||||
unset($this->_values[$k]);
|
||||
$this->_transientValues->add($k);
|
||||
$this->_unsavedValues->discard($k);
|
||||
}
|
||||
public function &__get($k)
|
||||
{
|
||||
// function should return a reference, using $nullval to return a reference to null
|
||||
$nullval = null;
|
||||
if (!empty($this->_values) && array_key_exists($k, $this->_values)) {
|
||||
return $this->_values[$k];
|
||||
} else if (!empty($this->_transientValues) && $this->_transientValues->includes($k)) {
|
||||
$class = get_class($this);
|
||||
$attrs = join(', ', array_keys($this->_values));
|
||||
$message = "Stripe Notice: Undefined property of $class instance: $k. "
|
||||
. "HINT: The $k attribute was set in the past, however. "
|
||||
. "It was then wiped when refreshing the object "
|
||||
. "with the result returned by Stripe's API, "
|
||||
. "probably as a result of a save(). The attributes currently "
|
||||
. "available on this object are: $attrs";
|
||||
error_log($message);
|
||||
return $nullval;
|
||||
} else {
|
||||
$class = get_class($this);
|
||||
error_log("Stripe Notice: Undefined property of $class instance: $k");
|
||||
return $nullval;
|
||||
}
|
||||
}
|
||||
|
||||
// ArrayAccess methods
|
||||
public function offsetSet($k, $v)
|
||||
{
|
||||
$this->$k = $v;
|
||||
}
|
||||
|
||||
public function offsetExists($k)
|
||||
{
|
||||
return array_key_exists($k, $this->_values);
|
||||
}
|
||||
|
||||
public function offsetUnset($k)
|
||||
{
|
||||
unset($this->$k);
|
||||
}
|
||||
public function offsetGet($k)
|
||||
{
|
||||
return array_key_exists($k, $this->_values) ? $this->_values[$k] : null;
|
||||
}
|
||||
|
||||
public function keys()
|
||||
{
|
||||
return array_keys($this->_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* This unfortunately needs to be public to be used in Util\Util
|
||||
*
|
||||
* @param array $values
|
||||
* @param array $opts
|
||||
*
|
||||
* @return StripeObject The object constructed from the given values.
|
||||
*/
|
||||
public static function constructFrom($values, $opts)
|
||||
{
|
||||
$obj = new static(isset($values['id']) ? $values['id'] : null);
|
||||
$obj->refreshFrom($values, $opts);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes this object using the provided values.
|
||||
*
|
||||
* @param array $values
|
||||
* @param array|Util\RequestOptions $opts
|
||||
* @param boolean $partial Defaults to false.
|
||||
*/
|
||||
public function refreshFrom($values, $opts, $partial = false)
|
||||
{
|
||||
if (is_array($opts)) {
|
||||
$opts = Util\RequestOptions::parse($opts);
|
||||
}
|
||||
|
||||
$this->_opts = $opts;
|
||||
|
||||
// Wipe old state before setting new. This is useful for e.g. updating a
|
||||
// customer, where there is no persistent card parameter. Mark those values
|
||||
// which don't persist as transient
|
||||
if ($partial) {
|
||||
$removed = new Util\Set();
|
||||
} else {
|
||||
$removed = array_diff(array_keys($this->_values), array_keys($values));
|
||||
}
|
||||
|
||||
foreach ($removed as $k) {
|
||||
if (self::$permanentAttributes->includes($k)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unset($this->$k);
|
||||
}
|
||||
|
||||
foreach ($values as $k => $v) {
|
||||
if (self::$permanentAttributes->includes($k) && isset($this[$k])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (self::$nestedUpdatableAttributes->includes($k) && is_array($v)) {
|
||||
$this->_values[$k] = AttachedObject::constructFrom($v, $opts);
|
||||
} else {
|
||||
$this->_values[$k] = Util\Util::convertToStripeObject($v, $opts);
|
||||
}
|
||||
|
||||
$this->_transientValues->discard($k);
|
||||
$this->_unsavedValues->discard($k);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array A recursive mapping of attributes to values for this object,
|
||||
* including the proper value for deleted attributes.
|
||||
*/
|
||||
public function serializeParameters()
|
||||
{
|
||||
$params = array();
|
||||
if ($this->_unsavedValues) {
|
||||
foreach ($this->_unsavedValues->toArray() as $k) {
|
||||
$v = $this->$k;
|
||||
if ($v === null) {
|
||||
$v = '';
|
||||
}
|
||||
|
||||
$params[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nested updates.
|
||||
foreach (self::$nestedUpdatableAttributes->toArray() as $property) {
|
||||
if (isset($this->$property)) {
|
||||
if ($this->$property instanceof StripeObject) {
|
||||
$serialized = $this->$property->serializeParameters();
|
||||
if ($serialized) {
|
||||
$params[$property] = $serialized;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->__toArray(true);
|
||||
}
|
||||
|
||||
public function __toJSON()
|
||||
{
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this->__toArray(true), JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this->__toArray(true));
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$class = get_class($this);
|
||||
return $class . ' JSON: ' . $this->__toJSON();
|
||||
}
|
||||
|
||||
public function __toArray($recursive = false)
|
||||
{
|
||||
if ($recursive) {
|
||||
return Util\Util::convertStripeObjectToArray($this->_values);
|
||||
} else {
|
||||
return $this->_values;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StripeObject::init();
|
||||
|
||||
@ -5,10 +5,42 @@ namespace Stripe;
|
||||
/**
|
||||
* Class Subscription
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property float $application_fee_percent
|
||||
* @property string $billing
|
||||
* @property bool $cancel_at_period_end
|
||||
* @property int $canceled_at
|
||||
* @property int $created
|
||||
* @property int current_period_end
|
||||
* @property int current_period_start
|
||||
* @property string $customer
|
||||
* @property int $days_until_due
|
||||
* @property mixed $discount
|
||||
* @property int $ended_at
|
||||
* @property Collection $items
|
||||
* @property boolean $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property Plan $plan
|
||||
* @property int $quantity
|
||||
* @property int $start
|
||||
* @property string $status
|
||||
* @property float $tax_percent
|
||||
* @property int $trial_end
|
||||
* @property int $trial_start
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Subscription extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete {
|
||||
delete as protected _delete;
|
||||
}
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* These constants are possible representations of the status field.
|
||||
*
|
||||
@ -20,49 +52,15 @@ class Subscription extends ApiResource
|
||||
const STATUS_TRIALING = 'trialing';
|
||||
const STATUS_UNPAID = 'unpaid';
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the subscription to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Subscription
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
public static function getSavedNestedResources()
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Subscriptions
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Subscription The created subscription.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the subscription to retrieve.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Subscription The updated subscription.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
static $savedNestedResources = null;
|
||||
if ($savedNestedResources === null) {
|
||||
$savedNestedResources = new Util\Set([
|
||||
'source',
|
||||
]);
|
||||
}
|
||||
return $savedNestedResources;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,16 +73,6 @@ class Subscription extends ApiResource
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Subscription The saved subscription.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Subscription The updated subscription.
|
||||
*/
|
||||
@ -92,6 +80,15 @@ class Subscription extends ApiResource
|
||||
{
|
||||
$url = $this->instanceUrl() . '/discount';
|
||||
list($response, $opts) = $this->_request('delete', $url);
|
||||
$this->refreshFrom(array('discount' => null), $opts, true);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,24 @@ namespace Stripe;
|
||||
/**
|
||||
* Class SubscriptionItem
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $created
|
||||
* @property StripeObject $metadata
|
||||
* @property Plan $plan
|
||||
* @property int $quantity
|
||||
* @property string $subscription
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class SubscriptionItem extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Delete;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* This is a special case because the subscription items endpoint has an
|
||||
* underscore in it. The parent `className` function strips underscores.
|
||||
@ -19,70 +33,4 @@ class SubscriptionItem extends ApiResource
|
||||
{
|
||||
return 'subscription_item';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the subscription item to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SubscriptionItem
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of SubscriptionItems
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SubscriptionItem The created subscription item.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the subscription item to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return SubscriptionItem The updated subscription item.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SubscriptionItem The saved subscription item.
|
||||
*/
|
||||
public function save($opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return SubscriptionItem The deleted subscription item.
|
||||
*/
|
||||
public function delete($params = null, $opts = null)
|
||||
{
|
||||
return $this->_delete($params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@ namespace Stripe;
|
||||
|
||||
class ThreeDSecure extends ApiResource
|
||||
{
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
|
||||
/**
|
||||
* @return string The endpoint URL for the given class.
|
||||
*/
|
||||
@ -11,26 +14,4 @@ class ThreeDSecure extends ApiResource
|
||||
{
|
||||
return "/v1/3d_secure";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the 3DS auth to retrieve.
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return ThreeDSecure
|
||||
*/
|
||||
public static function retrieve($id, $options = null)
|
||||
{
|
||||
return self::_retrieve($id, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return ThreeDSecure The created 3D Secure object.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ namespace Stripe;
|
||||
* @property string $object
|
||||
* @property mixed $bank_account
|
||||
* @property mixed $card
|
||||
* @property mixed $client_ip
|
||||
* @property string $client_ip
|
||||
* @property int $created
|
||||
* @property bool $livemode
|
||||
* @property string $type
|
||||
@ -19,25 +19,6 @@ namespace Stripe;
|
||||
*/
|
||||
class Token extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the token to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Token
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Token The created token.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
}
|
||||
|
||||
32
htdocs/includes/stripe/lib/Topup.php
Normal file
32
htdocs/includes/stripe/lib/Topup.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
/**
|
||||
* Class Topup
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $object
|
||||
* @property int $amount
|
||||
* @property string $balance_transaction
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property string $description
|
||||
* @property int $expected_availability_date
|
||||
* @property string $failure_code
|
||||
* @property string $failure_message
|
||||
* @property bool $livemode
|
||||
* @property StripeObject $metadata
|
||||
* @property mixed $source
|
||||
* @property string $statement_descriptor
|
||||
* @property string $status
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Topup extends ApiResource
|
||||
{
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
}
|
||||
@ -12,63 +12,27 @@ namespace Stripe;
|
||||
* @property string $balance_transaction
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property int $date
|
||||
* @property mixed $destination
|
||||
* @property mixed $destination_payment
|
||||
* @property string $destination
|
||||
* @property string $destination_payment
|
||||
* @property bool $livemode
|
||||
* @property mixed $metadata
|
||||
* @property mixed $reversals
|
||||
* @property StripeObject $metadata
|
||||
* @property Collection $reversals
|
||||
* @property bool $reversed
|
||||
* @property mixed $source_transaction
|
||||
* @property string $source_transaction
|
||||
* @property string $source_type
|
||||
* @property string $transfer_group
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class Transfer extends ApiResource
|
||||
{
|
||||
/**
|
||||
* @param string $id The ID of the transfer to retrieve.
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Transfer
|
||||
*/
|
||||
public static function retrieve($id, $opts = null)
|
||||
{
|
||||
return self::_retrieve($id, $opts);
|
||||
}
|
||||
use ApiOperations\All;
|
||||
use ApiOperations\Create;
|
||||
use ApiOperations\NestedResource;
|
||||
use ApiOperations\Retrieve;
|
||||
use ApiOperations\Update;
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Collection of Transfers
|
||||
*/
|
||||
public static function all($params = null, $opts = null)
|
||||
{
|
||||
return self::_all($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Transfer The created transfer.
|
||||
*/
|
||||
public static function create($params = null, $opts = null)
|
||||
{
|
||||
return self::_create($params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The ID of the transfer to update.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $options
|
||||
*
|
||||
* @return Transfer The updated transfer.
|
||||
*/
|
||||
public static function update($id, $params = null, $options = null)
|
||||
{
|
||||
return self::_update($id, $params, $options);
|
||||
}
|
||||
const PATH_REVERSALS = '/reversals';
|
||||
|
||||
/**
|
||||
* @return TransferReversal The created transfer reversal.
|
||||
@ -93,12 +57,52 @@ class Transfer extends ApiResource
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the transfer on which to create the reversal.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return Transfer The saved transfer.
|
||||
* @return TransferReversal
|
||||
*/
|
||||
public function save($opts = null)
|
||||
public static function createReversal($id, $params = null, $opts = null)
|
||||
{
|
||||
return $this->_save($opts);
|
||||
return self::_createNestedResource($id, static::PATH_REVERSALS, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return TransferReversal
|
||||
*/
|
||||
public static function retrieveReversal($id, $reversalId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_retrieveNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|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
|
||||
*
|
||||
* @return TransferReversal
|
||||
*/
|
||||
public static function updateReversal($id, $reversalId, $params = null, $opts = null)
|
||||
{
|
||||
return self::_updateNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $id The ID of the transfer on which to retrieve the reversals.
|
||||
* @param array|null $params
|
||||
* @param array|string|null $opts
|
||||
*
|
||||
* @return TransferReversal
|
||||
*/
|
||||
public static function allReversals($id, $params = null, $opts = null)
|
||||
{
|
||||
return self::_allNestedResources($id, static::PATH_REVERSALS, $params, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,13 +11,17 @@ namespace Stripe;
|
||||
* @property string $balance_transaction
|
||||
* @property int $created
|
||||
* @property string $currency
|
||||
* @property mixed $metadata
|
||||
* @property StripeObject $metadata
|
||||
* @property string $transfer
|
||||
*
|
||||
* @package Stripe
|
||||
*/
|
||||
class TransferReversal extends ApiResource
|
||||
{
|
||||
use ApiOperations\Update {
|
||||
save as protected _save;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The API URL for this Stripe transfer reversal.
|
||||
*/
|
||||
|
||||
40
htdocs/includes/stripe/lib/Webhook.php
Normal file
40
htdocs/includes/stripe/lib/Webhook.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
abstract class Webhook
|
||||
{
|
||||
const DEFAULT_TOLERANCE = 300;
|
||||
|
||||
/**
|
||||
* Returns an Event instance using the provided JSON payload. Throws a
|
||||
* \UnexpectedValueException if the payload is not valid JSON, and a
|
||||
* \Stripe\SignatureVerificationException if the signature verification
|
||||
* fails for any reason.
|
||||
*
|
||||
* @param string $payload the payload sent by Stripe.
|
||||
* @param string $sigHeader the contents of the signature header sent by
|
||||
* Stripe.
|
||||
* @param string $secret secret used to generate the signature.
|
||||
* @param int $tolerance maximum difference allowed between the header's
|
||||
* timestamp and the current time
|
||||
* @return \Stripe\Event the Event instance
|
||||
* @throws \UnexpectedValueException if the payload is not valid JSON,
|
||||
* @throws \Stripe\Error\SignatureVerification if the verification fails.
|
||||
*/
|
||||
public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE)
|
||||
{
|
||||
$data = json_decode($payload, true);
|
||||
$jsonError = json_last_error();
|
||||
if ($data === null && $jsonError !== JSON_ERROR_NONE) {
|
||||
$msg = "Invalid payload: $payload "
|
||||
. "(json_last_error() was $jsonError)";
|
||||
throw new \UnexpectedValueException($msg);
|
||||
}
|
||||
$event = Event::constructFrom($data);
|
||||
|
||||
WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance);
|
||||
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
133
htdocs/includes/stripe/lib/WebhookSignature.php
Normal file
133
htdocs/includes/stripe/lib/WebhookSignature.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Stripe;
|
||||
|
||||
abstract class WebhookSignature
|
||||
{
|
||||
const EXPECTED_SCHEME = "v1";
|
||||
|
||||
/**
|
||||
* Verifies the signature header sent by Stripe. Throws a
|
||||
* SignatureVerification exception if the verification fails for any
|
||||
* reason.
|
||||
*
|
||||
* @param string $payload the payload sent by Stripe.
|
||||
* @param string $header the contents of the signature header sent by
|
||||
* Stripe.
|
||||
* @param string $secret secret used to generate the signature.
|
||||
* @param int $tolerance maximum difference allowed between the header's
|
||||
* timestamp and the current time
|
||||
* @throws \Stripe\Error\SignatureVerification if the verification fails.
|
||||
* @return bool
|
||||
*/
|
||||
public static function verifyHeader($payload, $header, $secret, $tolerance = null)
|
||||
{
|
||||
// Extract timestamp and signatures from header
|
||||
$timestamp = self::getTimestamp($header);
|
||||
$signatures = self::getSignatures($header, self::EXPECTED_SCHEME);
|
||||
if ($timestamp == -1) {
|
||||
throw new Error\SignatureVerification(
|
||||
"Unable to extract timestamp and signatures from header",
|
||||
$header,
|
||||
$payload
|
||||
);
|
||||
}
|
||||
if (empty($signatures)) {
|
||||
throw new Error\SignatureVerification(
|
||||
"No signatures found with expected scheme",
|
||||
$header,
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
// Check if expected signature is found in list of signatures from
|
||||
// header
|
||||
$signedPayload = "$timestamp.$payload";
|
||||
$expectedSignature = self::computeSignature($signedPayload, $secret);
|
||||
$signatureFound = false;
|
||||
foreach ($signatures as $signature) {
|
||||
if (Util\Util::secureCompare($expectedSignature, $signature)) {
|
||||
$signatureFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$signatureFound) {
|
||||
throw new Error\SignatureVerification(
|
||||
"No signatures found matching the expected signature for payload",
|
||||
$header,
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
// Check if timestamp is within tolerance
|
||||
if (($tolerance > 0) && ((time() - $timestamp) > $tolerance)) {
|
||||
throw new Error\SignatureVerification(
|
||||
"Timestamp outside the tolerance zone",
|
||||
$header,
|
||||
$payload
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the timestamp in a signature header.
|
||||
*
|
||||
* @param string $header the signature header
|
||||
* @return int the timestamp contained in the header, or -1 if no valid
|
||||
* timestamp is found
|
||||
*/
|
||||
private static function getTimestamp($header)
|
||||
{
|
||||
$items = explode(",", $header);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$itemParts = explode("=", $item, 2);
|
||||
if ($itemParts[0] == "t") {
|
||||
if (!is_numeric($itemParts[1])) {
|
||||
return -1;
|
||||
}
|
||||
return intval($itemParts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the signatures matching a given scheme in a signature header.
|
||||
*
|
||||
* @param string $header the signature header
|
||||
* @param string $scheme the signature scheme to look for.
|
||||
* @return array the list of signatures matching the provided scheme.
|
||||
*/
|
||||
private static function getSignatures($header, $scheme)
|
||||
{
|
||||
$signatures = [];
|
||||
$items = explode(",", $header);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$itemParts = explode("=", $item, 2);
|
||||
if ($itemParts[0] == $scheme) {
|
||||
array_push($signatures, $itemParts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $signatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the signature for a given payload and secret.
|
||||
*
|
||||
* The current scheme used by Stripe ("v1") is HMAC/SHA-256.
|
||||
*
|
||||
* @param string $payload the payload to sign.
|
||||
* @param string $secret the secret used to generate the signature.
|
||||
* @return string the signature as a string.
|
||||
*/
|
||||
private static function computeSignature($payload, $secret)
|
||||
{
|
||||
return hash_hmac("sha256", $payload, $secret);
|
||||
}
|
||||
}
|
||||
19
htdocs/includes/stripe/update_certs.php
Normal file
19
htdocs/includes/stripe/update_certs.php
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
set_time_limit(0); // unlimited max execution time
|
||||
|
||||
$fp = fopen(dirname(__FILE__) . '/data/ca-certificates.crt', 'w+');
|
||||
|
||||
$options = array(
|
||||
CURLOPT_FILE => $fp,
|
||||
CURLOPT_TIMEOUT => 3600,
|
||||
CURLOPT_URL => 'https://curl.haxx.se/ca/cacert.pem',
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, $options);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
fclose($fp);
|
||||
@ -542,7 +542,7 @@ if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBO
|
||||
{
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning');
|
||||
}
|
||||
if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha')))
|
||||
if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')))
|
||||
{
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
|
||||
}
|
||||
@ -1554,3 +1554,4 @@ htmlPrintOnlinePaymentFooter($mysoc,$langs,1,$suffix,$object);
|
||||
llxFooter('', 'public');
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
985
htdocs/societe/gateway.php
Normal file
985
htdocs/societe/gateway.php
Normal file
@ -0,0 +1,985 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Peter Fontaine <contact@peterfontaine.fr>
|
||||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/societe/rib.php
|
||||
* \ingroup societe
|
||||
* \brief BAN tab for companies
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("commercial");
|
||||
$langs->load("banks");
|
||||
$langs->load("bills");
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid","int");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'societe','','');
|
||||
|
||||
$id=GETPOST("id","int");
|
||||
$source=GETPOST("source","alpha");
|
||||
$ribid=GETPOST("ribid","int");
|
||||
$action=GETPOST("action", 'alpha', 3);
|
||||
|
||||
$object = new Societe($db);
|
||||
$object->fetch($socid);
|
||||
|
||||
$account = new CompanyBankAccount($db);
|
||||
$prelevement = new BonPrelevement($db);
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('thirdpartybancard','globalcard'));
|
||||
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('thirdpartybancard'));
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas);
|
||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($cancel)
|
||||
{
|
||||
$action='';
|
||||
if (! empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'update' && ! $_POST["cancel"])
|
||||
{
|
||||
// Modification
|
||||
if (! GETPOST('label'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$action='edit';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bank'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
|
||||
$action='edit';
|
||||
$error++;
|
||||
}
|
||||
if ($account->needIBAN() == 1)
|
||||
{
|
||||
if (! GETPOST('iban'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
||||
$action='edit';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bic'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
|
||||
$action='edit';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
$account->fetch($id);
|
||||
if (! $error)
|
||||
{
|
||||
$account->socid = $object->id;
|
||||
|
||||
$account->bank = GETPOST('bank','alpha');
|
||||
$account->label = GETPOST('label','alpha');
|
||||
$account->courant = GETPOST('courant','alpha');
|
||||
$account->clos = GETPOST('clos','alpha');
|
||||
$account->code_banque = GETPOST('code_banque','alpha');
|
||||
$account->code_guichet = GETPOST('code_guichet','alpha');
|
||||
$account->number = GETPOST('number','alpha');
|
||||
$account->cle_rib = GETPOST('cle_rib','alpha');
|
||||
$account->bic = GETPOST('bic','alpha');
|
||||
$account->iban = GETPOST('iban','alpha');
|
||||
$account->domiciliation = GETPOST('domiciliation','alpha');
|
||||
$account->proprio = GETPOST('proprio','alpha');
|
||||
$account->owner_address = GETPOST('owner_address','alpha');
|
||||
$account->frstrecur = GETPOST('frstrecur','alpha');
|
||||
$account->rum = GETPOST('rum','alpha');
|
||||
if (empty($account->rum))
|
||||
{
|
||||
$account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id);
|
||||
$account->date_rum = dol_now();
|
||||
}
|
||||
|
||||
$result = $account->update($user);
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
// If this account is the default bank account, we disable others
|
||||
if ($account->default_rib)
|
||||
{
|
||||
$account->setAsDefault($id); // This will make sure there is only one default rib
|
||||
}
|
||||
|
||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'add' && ! $_POST["cancel"])
|
||||
{
|
||||
$error=0;
|
||||
|
||||
if (! GETPOST('label'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bank'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Ajout
|
||||
$account = new CompanyBankAccount($db);
|
||||
|
||||
$account->socid = $object->id;
|
||||
|
||||
$account->bank = GETPOST('bank','alpha');
|
||||
$account->label = GETPOST('label','alpha');
|
||||
$account->courant = GETPOST('courant','alpha');
|
||||
$account->clos = GETPOST('clos','alpha');
|
||||
$account->code_banque = GETPOST('code_banque','alpha');
|
||||
$account->code_guichet = GETPOST('code_guichet','alpha');
|
||||
$account->number = GETPOST('number','alpha');
|
||||
$account->cle_rib = GETPOST('cle_rib','alpha');
|
||||
$account->bic = GETPOST('bic','alpha');
|
||||
$account->iban = GETPOST('iban','alpha');
|
||||
$account->domiciliation = GETPOST('domiciliation','alpha');
|
||||
$account->proprio = GETPOST('proprio','alpha');
|
||||
$account->owner_address = GETPOST('owner_address','alpha');
|
||||
$account->frstrecur = GETPOST('frstrecur');
|
||||
$account->rum = GETPOST('rum','alpha');
|
||||
$account->datec = dol_now();
|
||||
|
||||
$db->begin();
|
||||
|
||||
// This test can be done only once properties were set
|
||||
if ($account->needIBAN() == 1)
|
||||
{
|
||||
if (! GETPOST('iban'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
if (! GETPOST('bic'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result = $account->create($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
$action='create'; // Force chargement page création
|
||||
}
|
||||
|
||||
if (empty($account->rum))
|
||||
{
|
||||
$account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id);
|
||||
$account->date_rum = dol_now();
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result = $account->update($user); // This will set the UMR number.
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setasdefault')
|
||||
{
|
||||
$account = new CompanyBankAccount($db);
|
||||
$res = $account->setAsDefault(GETPOST('ribid','int'));
|
||||
if ($res)
|
||||
{
|
||||
$url=DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id;
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($db->lasterror, null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
|
||||
{
|
||||
$account = new CompanyBankAccount($db);
|
||||
if ($account->fetch($ribid?$ribid:$id))
|
||||
{
|
||||
$result = $account->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$url = $_SERVER['PHP_SELF']."?socid=".$object->id;
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($account->error, $account->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
$savid=$id;
|
||||
|
||||
// Actions to build doc
|
||||
if ($action == 'builddocrib')
|
||||
{
|
||||
$action = 'builddoc';
|
||||
$moreparams = array(
|
||||
'use_companybankid'=>GETPOST('companybankid'),
|
||||
'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id)
|
||||
);
|
||||
$_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid'));
|
||||
$_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid'));
|
||||
}
|
||||
$id = $socid;
|
||||
$upload_dir = $conf->societe->multidir_output[$object->entity];
|
||||
$permissioncreate=$user->rights->societe->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
$id = $savid;
|
||||
}
|
||||
|
||||
$stripeconnect=new StripeConnexion($db);
|
||||
$customer=$stripeconnect->CustomerStripe($socid,$stripeconnect->GetStripeAccount($conf->entity));
|
||||
if ($customer->id) {
|
||||
$cu = \Stripe\Customer::retrieve("".$customer->id."",array("stripe_account" => $stripeconnect->GetStripeAccount($conf->entity)));}
|
||||
$url=DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id;
|
||||
if ($action == 'setasdefault')
|
||||
{
|
||||
$cu->default_source = "$source"; // obtained with Stripe.js
|
||||
$cu->save();
|
||||
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
elseif ($action == 'delete')
|
||||
{
|
||||
$cu->sources->retrieve("$source")->delete();
|
||||
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$head=societe_prepare_head($object);
|
||||
if (! $id)
|
||||
{
|
||||
$account->fetch(0,$object->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$account->fetch($id);
|
||||
}
|
||||
if (empty($account->socid)) $account->socid=$object->id;
|
||||
|
||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
print '<form action="rib.php?socid='.$object->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">';
|
||||
}
|
||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
{
|
||||
print '<form action="rib.php?socid='.$object->id.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
}
|
||||
|
||||
|
||||
// View
|
||||
if ($socid && $action != 'edit' && $action != "create")
|
||||
{
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company');
|
||||
|
||||
// Confirm delete third party
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $account->getRibLabel()), "confirm_delete", '', 0, 1);
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
|
||||
|
||||
if (! (empty($conf->stripe->enabled))){
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('StripeGateways').'</td><td colspan="3">';
|
||||
if ($stripeconnect->GetStripeAccount($conf->entity)) {
|
||||
$customer=$stripeconnect->CustomerStripe($object->id,$stripeconnect->GetStripeAccount($conf->entity));
|
||||
}
|
||||
|
||||
if ($customer->id) {
|
||||
$input=$customer->sources->data;
|
||||
}
|
||||
print '<table class="liste" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left">'.$langs->trans('Type').'</td>';
|
||||
print '<td align="left">'.$langs->trans('Informations').'</td>';
|
||||
print '<td align="left"></td>';
|
||||
print '<td align="center">'.$langs->trans('Default').'</td>';
|
||||
print "<td></td></tr>\n";
|
||||
|
||||
foreach ($input as $src) {
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
if ($src->object=='card'){
|
||||
if ($src->brand == 'Visa') {$brand='cc-visa';}
|
||||
elseif ($src->brand == 'MasterCard') {$brand='cc-mastercard';}
|
||||
elseif ($src->brand == 'American Express') {$brand='cc-amex';}
|
||||
elseif ($src->brand == 'Discover') {$brand='cc-discover';}
|
||||
elseif ($src->brand == 'JCB') {$brand='cc-jcb';}
|
||||
elseif ($src->brand == 'Diners Club') {$brand='cc-diners-club';}
|
||||
else {$brand='credit-card';}
|
||||
print '<span class="fa fa-'.$brand.' fa-3x fa-fw"></span>';
|
||||
}
|
||||
elseif ($src->object=='source' && $src->type=='card'){
|
||||
if ($src->card->brand == 'Visa') {$brand='cc-visa';}
|
||||
elseif ($src->card->brand == 'MasterCard') {$brand='cc-mastercard';}
|
||||
elseif ($src->card->brand == 'American Express') {$brand='cc-amex';}
|
||||
elseif ($src->card->brand == 'Discover') {$brand='cc-discover';}
|
||||
elseif ($src->card->brand == 'JCB') {$brand='cc-jcb';}
|
||||
elseif ($src->card->brand == 'Diners Club') {$brand='cc-diners-club';}
|
||||
else {$brand='credit-card';}
|
||||
|
||||
print '<span class="fa fa-'.$brand.' fa-3x fa-fw"></span>';
|
||||
}
|
||||
elseif ($src->object=='source' && $src->type=='sepa_debit'){
|
||||
print '<span class="fa fa-university fa-3x fa-fw"></span>';
|
||||
}
|
||||
print'</td><td valign="middle">';
|
||||
if ($src->object=='card'){
|
||||
print '**** '.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.'';
|
||||
print '</td><td>';
|
||||
if ($src->country)
|
||||
{
|
||||
$img=picto_from_langcode($src->country);
|
||||
print $img?$img.' ':'';
|
||||
print getCountry($src->country,1);
|
||||
}
|
||||
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
elseif ($src->object=='source' && $src->type=='card'){
|
||||
print $src->owner->name.'<br>**** '.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.'';
|
||||
print '</td><td>';
|
||||
if ($src->card->country)
|
||||
{
|
||||
$img=picto_from_langcode($src->card->country);
|
||||
print $img?$img.' ':'';
|
||||
print getCountry($src->card->country,1);
|
||||
}
|
||||
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
elseif ($src->object=='source' && $src->type=='sepa_debit'){
|
||||
print 'info sepa';
|
||||
print '</td><td>';
|
||||
if ($src->sepa_debit->country)
|
||||
{
|
||||
$img=picto_from_langcode($src->sepa_debit->country);
|
||||
print $img?$img.' ':'';
|
||||
print getCountry($src->sepa_debit->country,1);
|
||||
}
|
||||
else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
|
||||
}
|
||||
print '</td>';
|
||||
// Default
|
||||
print '<td align="center" width="50">';
|
||||
if (($cu->default_source!=$src->id)) {
|
||||
print '<a href="' . DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id.'&source='.$src->id.'&action=setasdefault">';
|
||||
print "<SPAN class='fa fa-circle fa-2x'></SPAN>";
|
||||
print '</a>';
|
||||
} else {
|
||||
print "<SPAN class=' fa fa-check-circle fa-2x'></SPAN>";
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
// print '<a href="' . DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id.'&id='.$src->id.'&action=edit">';
|
||||
// print img_picto($langs->trans("Modify"),'edit');
|
||||
// print '</a>';
|
||||
// print ' ';
|
||||
print '<a href="' . DOL_URL_ROOT.'/societe/gateway.php?socid='.$object->id.'&source='.$src->id.'&action=delete">';
|
||||
print "<SPAN class='fa fa-trash fa-2x'></SPAN>";
|
||||
print '</a>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
if (empty($input))
|
||||
{
|
||||
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("NoSource").'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
|
||||
// List of bank accounts
|
||||
|
||||
$morehtmlright='<a href="rib.php?socid='.$object->id.'&action=create">'.$langs->trans("Add").'</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans("AllRIB"), $morehtmlright, '');
|
||||
|
||||
$rib_list = $object->get_all_rib();
|
||||
$var = false;
|
||||
if (is_array($rib_list))
|
||||
{
|
||||
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="liste" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("LabelRIB");
|
||||
print_liste_field_titre("Bank");
|
||||
print_liste_field_titre("RIB");
|
||||
print_liste_field_titre("IBAN");
|
||||
print_liste_field_titre("BIC");
|
||||
if (! empty($conf->prelevement->enabled))
|
||||
{
|
||||
print print_liste_field_titre("RUM");
|
||||
print print_liste_field_titre("WithdrawMode");
|
||||
}
|
||||
print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"');
|
||||
print_liste_field_titre('', '', '', '', '', 'align="center"');
|
||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
foreach ($rib_list as $rib)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
// Label
|
||||
print '<td>'.$rib->label.'</td>';
|
||||
// Bank name
|
||||
print '<td>'.$rib->bank.'</td>';
|
||||
// Account number
|
||||
print '<td>';
|
||||
$string='';
|
||||
foreach ($rib->getFieldsToShow() as $val) {
|
||||
|
||||
if ($val == 'BankCode') {
|
||||
$string .= $rib->code_banque.' ';
|
||||
} elseif ($val == 'BankAccountNumber') {
|
||||
$string .= $rib->number.' ';
|
||||
} elseif ($val == 'DeskCode') {
|
||||
$string .= $rib->code_guichet.' ';
|
||||
} elseif ($val == 'BankAccountNumberKey') {
|
||||
$string .= $rib->cle_rib.' ';
|
||||
/* Already output after
|
||||
}elseif ($val == 'BIC') {
|
||||
$string .= $rib->bic.' ';
|
||||
}elseif ($val == 'IBAN') {
|
||||
$string .= $rib->iban.' ';*/
|
||||
}
|
||||
}
|
||||
if (! empty($rib->label) && $rib->number) {
|
||||
if (! checkBanForAccount($rib)) {
|
||||
$string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning');
|
||||
} else {
|
||||
$string.= ' '.img_picto($langs->trans("ValueIsValid"),'info');
|
||||
}
|
||||
}
|
||||
|
||||
print $string;
|
||||
print '</td>';
|
||||
// IBAN
|
||||
print '<td>'.$rib->iban;
|
||||
if (! empty($rib->iban)) {
|
||||
if (! checkIbanForAccount($rib)) {
|
||||
print ' '.img_picto($langs->trans("IbanNotValid"),'warning');
|
||||
} else {
|
||||
print ' '.img_picto($langs->trans("IbanValid"),'info');
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
// BIC
|
||||
print '<td>'.$rib->bic;
|
||||
if (! empty($rib->bic)) {
|
||||
if (! checkSwiftForAccount($rib)) {
|
||||
print ' '.img_picto($langs->trans("SwiftNotValid"),'warning');
|
||||
} else {
|
||||
print ' '.img_picto($langs->trans("SwiftValid"),'info');
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
if (! empty($conf->prelevement->enabled))
|
||||
{
|
||||
// RUM
|
||||
//print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>';
|
||||
print '<td>'.$rib->rum.'</td>';
|
||||
|
||||
// FRSTRECUR
|
||||
print '<td>'.$rib->frstrecur.'</td>';
|
||||
}
|
||||
|
||||
// Default
|
||||
print '<td align="center" width="70">';
|
||||
if (!$rib->default_rib) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&ribid='.$rib->id.'&action=setasdefault">';
|
||||
print img_picto($langs->trans("Disabled"),'off');
|
||||
print '</a>';
|
||||
} else {
|
||||
print img_picto($langs->trans("Enabled"),'on');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Generate doc
|
||||
print '<td align="center">';
|
||||
|
||||
$buttonlabel = $langs->trans("BuildDoc");
|
||||
$forname='builddocrib'.$rib->id;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
|
||||
$modellist=ModeleBankAccountDoc::liste_modeles($db);
|
||||
|
||||
$out = '';
|
||||
if (is_array($modellist) && count($modellist))
|
||||
{
|
||||
$out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">';
|
||||
$out.= '<input type="hidden" name="action" value="builddocrib">';
|
||||
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$out.= '<input type="hidden" name="socid" value="'.$object->id.'">';
|
||||
$out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">';
|
||||
|
||||
if (is_array($modellist) && count($modellist) == 1) // If there is only one element
|
||||
{
|
||||
$arraykeys=array_keys($modellist);
|
||||
$modelselected=$arraykeys[0];
|
||||
}
|
||||
if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF;
|
||||
|
||||
$out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
|
||||
$out.= ajax_combobox('modelrib'.$rib->id);
|
||||
|
||||
// Language code (if multilang)
|
||||
if ($conf->global->MAIN_MULTILANGS)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
$formadmin=new FormAdmin($db);
|
||||
$defaultlang=$codelang?$codelang:$langs->getDefaultLang();
|
||||
$morecss='maxwidth150';
|
||||
if (! empty($conf->browser->phone)) $morecss='maxwidth100';
|
||||
$out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss);
|
||||
}
|
||||
// Button
|
||||
$genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
|
||||
$genbutton.= ' type="submit" value="'.$buttonlabel.'"';
|
||||
if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
|
||||
$genbutton.= '>';
|
||||
if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
|
||||
}
|
||||
if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton='';
|
||||
if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton='';
|
||||
$out.= $genbutton;
|
||||
$out.= '</form>';
|
||||
}
|
||||
print $out;
|
||||
print '</td>';
|
||||
|
||||
// Edit/Delete
|
||||
print '<td align="right">';
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=edit">';
|
||||
print img_picto($langs->trans("Modify"),'edit');
|
||||
print '</a>';
|
||||
|
||||
print ' ';
|
||||
|
||||
print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id.'&id='.$rib->id.'&action=delete">';
|
||||
print img_picto($langs->trans("Delete"),'delete');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (count($rib_list) == 0)
|
||||
{
|
||||
$colspan=8;
|
||||
if (! empty($conf->prelevement->enabled)) $colspan+=2;
|
||||
print '<tr '.$bc[0].'><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
/*
|
||||
if ($socid && $action != 'edit' && $action != 'create')
|
||||
{
|
||||
// Barre d'actions
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->societe->creer)
|
||||
{
|
||||
print '<a class="butAction" href="rib.php?socid='.$object->id.'&action=create">'.$langs->trans("Add").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
*/
|
||||
if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
$filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id;
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id;
|
||||
$genallowed=$user->rights->societe->lire;
|
||||
$delallowed=$user->rights->societe->creer;
|
||||
|
||||
$var=true;
|
||||
|
||||
print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
print '</div></div></div>';
|
||||
|
||||
print '<br>';
|
||||
}
|
||||
/*
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php';
|
||||
$modellist=ModeleBankAccountDoc::liste_modeles($db);
|
||||
//print '<td>';
|
||||
if (is_array($modellist) && count($modellist) == 1) // If there is only one element
|
||||
{
|
||||
$arraykeys=array_keys($modellist);
|
||||
$modelselected=$arraykeys[0];
|
||||
}
|
||||
$out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100');
|
||||
$out.= ajax_combobox('model');
|
||||
//print $out;
|
||||
$buttonlabel=$langs->trans("Generate");
|
||||
$genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
|
||||
$genbutton.= ' type="submit" value="'.$buttonlabel.'"';
|
||||
$genbutton.= '>';
|
||||
print $genbutton;
|
||||
//print '</td>'; // TODO Add link to generate doc
|
||||
*/
|
||||
}
|
||||
|
||||
// Edit
|
||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
|
||||
print '<td><input size="30" type="text" name="label" value="'.$account->label.'"></td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
|
||||
print '<td><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
|
||||
|
||||
// Show fields of bank account
|
||||
foreach ($account->getFieldsToShow(1) as $val) {
|
||||
|
||||
$require=false;
|
||||
if ($val == 'BankCode') {
|
||||
$name = 'code_banque';
|
||||
$size = 8;
|
||||
$content = $account->code_banque;
|
||||
} elseif ($val == 'DeskCode') {
|
||||
$name = 'code_guichet';
|
||||
$size = 8;
|
||||
$content = $account->code_guichet;
|
||||
} elseif ($val == 'BankAccountNumber') {
|
||||
$name = 'number';
|
||||
$size = 18;
|
||||
$content = $account->number;
|
||||
} elseif ($val == 'BankAccountNumberKey') {
|
||||
$name = 'cle_rib';
|
||||
$size = 3;
|
||||
$content = $account->cle_rib;
|
||||
} elseif ($val == 'IBAN') {
|
||||
$name = 'iban';
|
||||
$size = 30;
|
||||
$content = $account->iban;
|
||||
if ($account->needIBAN()) $require=true;
|
||||
} elseif ($val == 'BIC') {
|
||||
$name = 'bic';
|
||||
$size = 12;
|
||||
$content = $account->bic;
|
||||
if ($account->needIBAN()) $require=true;
|
||||
}
|
||||
|
||||
print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
|
||||
print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
|
||||
print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">';
|
||||
print $account->domiciliation;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
|
||||
print '<td><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
|
||||
print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">';
|
||||
print $account->owner_address;
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '</table>';
|
||||
|
||||
if ($conf->prelevement->enabled)
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
if (empty($account->rum)) $account->rum = $prelevement->buildRumNumber($object->code_client, $account->datec, $account->id);
|
||||
|
||||
// RUM
|
||||
print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>';
|
||||
print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($account->rum).'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
||||
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
||||
print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur')?GETPOST('frstrecur'):$account->frstrecur), 0);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div align="center">';
|
||||
print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
|
||||
print ' ';
|
||||
print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
// Create
|
||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
{
|
||||
dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
|
||||
|
||||
print '<div class="nofichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>';
|
||||
print '<td><input size="30" type="text" name="label" value="'.GETPOST('label').'"></td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
|
||||
print '<td><input size="30" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
|
||||
|
||||
// Show fields of bank account
|
||||
foreach ($account->getFieldsToShow(1) as $val) {
|
||||
|
||||
$require=false;
|
||||
if ($val == 'BankCode') {
|
||||
$name = 'code_banque';
|
||||
$size = 8;
|
||||
} elseif ($val == 'DeskCode') {
|
||||
$name = 'code_guichet';
|
||||
$size = 8;
|
||||
} elseif ($val == 'BankAccountNumber') {
|
||||
$name = 'number';
|
||||
$size = 18;
|
||||
} elseif ($val == 'BankAccountNumberKey') {
|
||||
$name = 'cle_rib';
|
||||
$size = 3;
|
||||
} elseif ($val == 'IBAN') {
|
||||
$name = 'iban';
|
||||
$size = 30;
|
||||
if ($account->needIBAN()) $require=true;
|
||||
} elseif ($val == 'BIC') {
|
||||
$name = 'bic';
|
||||
$size = 12;
|
||||
if ($account->needIBAN()) $require=true;
|
||||
}
|
||||
|
||||
print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
|
||||
print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
|
||||
print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
|
||||
print GETPOST('domiciliation');
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
|
||||
print '<td><input size="30" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>';
|
||||
print "</td></tr>\n";
|
||||
|
||||
print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
|
||||
print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
|
||||
print GETPOST('owner_address');
|
||||
print "</textarea></td></tr>";
|
||||
|
||||
print '</table>';
|
||||
|
||||
if ($conf->prelevement->enabled)
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// RUM
|
||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>';
|
||||
print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"><br>'.$langs->trans("RUMWillBeGenerated").'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>';
|
||||
$tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR"));
|
||||
print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input class="button" value="'.$langs->trans("Add").'" type="submit">';
|
||||
print ' ';
|
||||
print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
||||
{
|
||||
print '</form>';
|
||||
}
|
||||
if ($socid && $action == 'create' && $user->rights->societe->creer)
|
||||
{
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2017 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2017 Saasprov <saasprov@gmail.com>
|
||||
* Copyright (C) 2018 ptibogxiv <support@ptibogxiv.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -27,6 +28,7 @@ require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/stripe/lib/stripe.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
|
||||
$servicename='Stripe';
|
||||
|
||||
@ -45,20 +47,28 @@ if ($action == 'setvalue' && $user->admin)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=dolibarr_set_const($db, "STRIPE_LIVE",GETPOST('STRIPE_LIVE','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_LIVE",GETPOST('STRIPE_LIVE','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
if (empty($conf->stripeconnect->enabled)) {
|
||||
$result=dolibarr_set_const($db, "STRIPE_TEST_PUBLISHABLE_KEY",GETPOST('STRIPE_TEST_PUBLISHABLE_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_TEST_SECRET_KEY",GETPOST('STRIPE_TEST_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_TEST_WEBHOOK_KEY",GETPOST('STRIPE_TEST_WEBHOOK_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_LIVE_PUBLISHABLE_KEY",GETPOST('STRIPE_LIVE_PUBLISHABLE_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_LIVE_SECRET_KEY",GETPOST('STRIPE_LIVE_SECRET_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_LIVE_WEBHOOK_KEY",GETPOST('STRIPE_LIVE_WEBHOOK_KEY','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
}
|
||||
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('STRIPE_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS",GETPOST('STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS','int'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM",GETPOST('ONLINE_PAYMENT_MESSAGE_FORM','alpha'),'chaine',0,'',$conf->entity);
|
||||
@ -69,6 +79,9 @@ if ($action == 'setvalue' && $user->admin)
|
||||
if (! $result > 0) $error++;
|
||||
$result=dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL",GETPOST('ONLINE_PAYMENT_SENDEMAIL'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
// Stock decrement
|
||||
$result=dolibarr_set_const($db,"ONLINE_PAYMENT_WAREHOUSE",(GETPOST('ONLINE_PAYMENT_WAREHOUSE','alpha') > 0 ? GETPOST('ONLINE_PAYMENT_WAREHOUSE','alpha') : ''),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
// Payment token for URL
|
||||
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN",GETPOST('PAYMENT_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity);
|
||||
if (! $result > 0) $error++;
|
||||
@ -108,16 +121,7 @@ if ($action=="setlive")
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
//$SECRET_TEST_KEY="sk_test_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe test secret key
|
||||
//if (empty($conf->global->STRIPE_TEST_SECRET_KEY)) $conf->global->STRIPE_TEST_SECRET_KEY = $SECRET_TEST_KEY;
|
||||
//$PUBLISHABLE_TEST_KEY="pk_test_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe test publishable key
|
||||
//if (empty($conf->global->STRIPE_TEST_PUBLISHABLE_KEY)) $conf->global->STRIPE_TEST_PUBLISHABLE_KEY = $PUBLISHABLE_TEST_KEY;
|
||||
|
||||
//$SECRET_LIVE_KEY="sk_live_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe live secret key
|
||||
//if (empty($conf->global->STRIPE_LIVE_SECRET_KEY)) $conf->global->STRIPE_LIVE_SECRET_KEY = $SECRET_LIVE_KEY;
|
||||
//$PUBLISHABLE_LIVE_KEY="pk_live_xxxxxxxxxxxxxxxxxxxxxxxx"; // Stripe live publishable key
|
||||
//if (empty($conf->global->STRIPE_LIVE_PUBLISHABLE_KEY)) $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY = $PUBLISHABLE_LIVE_KEY;
|
||||
$formproduct=new FormProduct($db);
|
||||
|
||||
llxHeader('',$langs->trans("StripeSetup"));
|
||||
|
||||
@ -145,18 +149,27 @@ print "</tr>\n";
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="titlefield">';
|
||||
print $langs->trans("StripeLiveEnabled").'</td><td>';
|
||||
if (empty($conf->global->STRIPECONNECT_LIVE) && ! empty($conf->stripeconnect->enabled)) {
|
||||
if (!empty($conf->global->STRIPE_LIVE))
|
||||
print '<A href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print '</A>';
|
||||
}
|
||||
else {
|
||||
if (!empty($conf->global->STRIPE_LIVE))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
|
||||
print '<A href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">';
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">';
|
||||
print '<A href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
}
|
||||
print '</A>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (empty($conf->stripeconnect->enabled)) {
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_PUBLISHABLE_KEY").'</span></td><td>';
|
||||
print '<input class="minwidth300" type="text" name="STRIPE_TEST_PUBLISHABLE_KEY" value="'.$conf->global->STRIPE_TEST_PUBLISHABLE_KEY.'">';
|
||||
@ -167,6 +180,12 @@ print '<tr class="oddeven"><td>';
|
||||
print '<span class="titlefield fieldrequired">'.$langs->trans("STRIPE_TEST_SECRET_KEY").'</span></td><td>';
|
||||
print '<input class="minwidth300" type="text" name="STRIPE_TEST_SECRET_KEY" value="'.$conf->global->STRIPE_TEST_SECRET_KEY.'">';
|
||||
print ' '.$langs->trans("Example").': sk_test_xxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<span class="fieldrequired">'.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").'</span></td><td>';
|
||||
print '<input class="minwidth300" type="text" name="STRIPE_TEST_WEBHOOK_KEY" value="'.$conf->global->STRIPE_TEST_WEBHOOK_KEY.'">';
|
||||
print ' '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
@ -181,6 +200,29 @@ print '<input class="minwidth300" type="text" name="STRIPE_LIVE_SECRET_KEY" valu
|
||||
print ' '.$langs->trans("Example").': sk_live_xxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print '<span class="fieldrequired">'.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").'</span></td><td>';
|
||||
print '<input class="minwidth300" type="text" name="STRIPE_LIVE_WEBHOOK_KEY" value="'.$conf->global->STRIPE_LIVE_WEBHOOK_KEY.'">';
|
||||
print ' '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
print '</td></tr>';
|
||||
} else {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("STRIPECONNECT").'</td>';
|
||||
print '<td>Ce module est configuré en mode marketplace</td></tr>';
|
||||
}
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("BankAccount").'</td><td>';
|
||||
print $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS, 'STRIPE_BANK_ACCOUNT_FOR_PAYMENTS', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("BankAccount").'</td><td>';
|
||||
print $form->select_comptes($conf->global->STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS, 'STRIPE_BANK_ACCOUNT_FOR_BANKTRANSFERS', 0, '', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
@ -235,6 +277,12 @@ print '<input size="32" type="email" name="ONLINE_PAYMENT_SENDEMAIL" value="'.$c
|
||||
print ' '.$langs->trans("Example").': myemail@myserver.com';
|
||||
print '</td></tr>';
|
||||
|
||||
// stock for automatic decrement
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("ONLINE_PAYMENT_WAREHOUSE").'</td><td>';
|
||||
print $formproduct->selectWarehouses($conf->global->ONLINE_PAYMENT_WAREHOUSE,'ONLINE_PAYMENT_WAREHOUSE','',1,$disabled);
|
||||
print '</td></tr>';
|
||||
|
||||
// Payment token for URL
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("SecurityToken").'</td><td>';
|
||||
@ -281,3 +329,4 @@ if (! empty($conf->use_javascript_ajax))
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
|
||||
149
htdocs/stripe/charge
Normal file
149
htdocs/stripe/charge
Normal file
@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017-2018 PtibogXIV <support@ptibogxiv.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("salaries");
|
||||
$langs->load("bills");
|
||||
$langs->load("hrm");
|
||||
$langs->load("stripe");
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid","int");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
//$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$rowid = GETPOST("rowid",'alpha');
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
llxHeader('', $langs->trans("StripeChargeList"));
|
||||
$form = new Form($db);
|
||||
$societestatic = new societe($db);
|
||||
$acc = new Account($db);
|
||||
$stripeconnect=new StripeConnexion($db);
|
||||
if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')))
|
||||
{
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
|
||||
}
|
||||
if (!$rowid){
|
||||
|
||||
print '<FORM method="GET" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<INPUT type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<INPUT type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<INPUT type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<INPUT type="hidden" name="action" value="list">';
|
||||
print '<INPUT type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<INPUT type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<INPUT type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
print_barre_liste($langs->trans("StripeChargeList"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
print '<DIV class="div-table-responsive">';
|
||||
print '<TABLE class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
print '<TR class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Origin",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"","","",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="left"');
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"","","",'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Paid",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
|
||||
print "</TR>\n";
|
||||
|
||||
print "</TR>\n";
|
||||
|
||||
$list=\Stripe\Charge::all(array("limit" => $limit),array("stripe_account" => $stripeconnect->GetStripeAccount($conf->entity)));
|
||||
//print $list;
|
||||
foreach ($list->data as $charge) {
|
||||
print '<TR class="oddeven">';
|
||||
$societestatic->fetch($charge->metadata->idcustomer);
|
||||
$societestatic->id=$charge->metadata->idcustomer;
|
||||
$societestatic->lastname=$obj->lastname;
|
||||
$societestatic->firstname=$obj->firstname;
|
||||
$societestatic->admin=$obj->admin;
|
||||
$societestatic->login=$obj->login;
|
||||
$societestatic->email=$obj->email;
|
||||
$societestatic->societe_id=$obj->fk_soc;
|
||||
// Ref
|
||||
print "<TD><A href='".DOL_URL_ROOT."/stripe/charge.php?rowid=".$charge->id."'>".$charge->id."</A></TD>\n";
|
||||
// Employee
|
||||
print "<TD>".$societestatic->getNomUrl(1)."</TD>\n";
|
||||
// Origine
|
||||
print "<TD>";
|
||||
if ($charge->metadata->source=="order"){
|
||||
$object = new Commande($db);
|
||||
$object->fetch($charge->metadata->idsource);
|
||||
print "<A href='".DOL_URL_ROOT."/commande/card.php?id=".$charge->metadata->idsource."'>".img_picto('', 'object_order')." ".$object->ref."</A>";
|
||||
} elseif ($charge->metadata->source=="invoice"){
|
||||
$object = new Facture($db);
|
||||
$object->fetch($charge->metadata->idsource);
|
||||
print "<A href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$charge->metadata->idsource."'>".img_picto('', 'object_invoice')." ".$object->ref."</A>";
|
||||
}
|
||||
print "</TD>\n";
|
||||
// Date payment
|
||||
print '<TD align="center">'.dol_print_date($charge->created,'%d/%m/%Y %H:%M')."</TD>\n";
|
||||
// Label payment
|
||||
print "<TD>";
|
||||
if ($charge->refunded=='1'){
|
||||
print $langs->trans("refunded");
|
||||
} elseif ($charge->paid=='1'){
|
||||
print $langs->trans("".$charge->status."");
|
||||
} else {
|
||||
$label="Message: ".$charge->failure_message."<BR>";
|
||||
$label.="Réseau: ".$charge->outcome->network_status."<BR>";
|
||||
$label.="Statut: ".$langs->trans("".$charge->outcome->seller_message."");
|
||||
print $form->textwithpicto($langs->trans("".$charge->status.""),$label,1);
|
||||
}
|
||||
print "</TD>\n";
|
||||
// Type
|
||||
print '<TD>';
|
||||
if ($charge->source->type=='card'){
|
||||
print $langs->trans("card");
|
||||
} elseif ($charge->source->type=='three_d_secure'){
|
||||
print $langs->trans("card3DS");
|
||||
}
|
||||
print '</TD>';
|
||||
// Amount
|
||||
print "<TD align=\"right\">".price(($charge->amount-$charge->amount_refunded)/100)."</TD>";
|
||||
print "</TR>\n";
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -33,6 +33,15 @@ global $conf;
|
||||
//use \includes\stripe as stripe;
|
||||
$stripe = array();
|
||||
|
||||
if ((empty($conf->global->STRIPECONNECT_LIVE) && ! (empty($conf->stripeconnect->enabled))) || GETPOST('forcesandbox','alpha'))
|
||||
{
|
||||
$stripe = array(
|
||||
"secret_key" => $conf->global->STRIPE_TEST_SECRET_KEY,
|
||||
"publishable_key" => $conf->global->STRIPE_TEST_PUBLISHABLE_KEY
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))
|
||||
{
|
||||
$stripe = array(
|
||||
@ -47,8 +56,13 @@ else
|
||||
"publishable_key" => $conf->global->STRIPE_LIVE_PUBLISHABLE_KEY
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT."/includes/stripe/lib/Stripe.php";
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
|
||||
\Stripe\Stripe::setApiKey($stripe['secret_key']);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
|
||||
\Stripe\Stripe::setAppInfo("Stripe", "dolibarr version", "https://www.dolibarr.org"); // add dolibarr version
|
||||
|
||||
148
htdocs/stripe/transaction.php
Normal file
148
htdocs/stripe/transaction.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017-2018 PtibogXIV <support@ptibogxiv.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
|
||||
//require_once DOL_DOCUMENT_ROOT.'/core/lib/stripe.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("salaries");
|
||||
$langs->load("bills");
|
||||
$langs->load("hrm");
|
||||
$langs->load("stripe");
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid","int");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
//$result = restrictedArea($user, 'salaries', '', '', '');
|
||||
|
||||
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$rowid = GETPOST("rowid",'alpha');
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
llxHeader('', $langs->trans("StripeTransactionList"));
|
||||
$form = new Form($db);
|
||||
$societestatic = new societe($db);
|
||||
$acc = new Account($db);
|
||||
$stripeconnect=new StripeConnexion($db);
|
||||
if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || empty($conf->global->STRIPECONNECT_LIVE) || GETPOST('forcesandbox','alpha')))
|
||||
{
|
||||
dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning');
|
||||
}
|
||||
if (!$rowid){
|
||||
|
||||
print '<FORM method="GET" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<INPUT type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<INPUT type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<INPUT type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<INPUT type="hidden" name="action" value="list">';
|
||||
print '<INPUT type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<INPUT type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<INPUT type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
print_barre_liste($langs->trans("StripeTransactionList"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
print '<DIV class="div-table-responsive">';
|
||||
print '<TABLE class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
print '<TR class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Origin",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"","","",'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="left"');
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"","","",'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Paid",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Fee",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
|
||||
print "</TR>\n";
|
||||
|
||||
print "</TR>\n";
|
||||
|
||||
$txn=\Stripe\BalanceTransaction::all(array("limit" => $limit), array("stripe_account" => $stripeconnect->GetStripeAccount($conf->entity)));
|
||||
foreach ($txn->data as $txn) {
|
||||
print '<TR class="oddeven">';
|
||||
$societestatic->fetch($charge->metadata->idcustomer);
|
||||
$societestatic->id=$charge->metadata->idcustomer;
|
||||
$societestatic->lastname=$obj->lastname;
|
||||
$societestatic->firstname=$obj->firstname;
|
||||
$societestatic->admin=$obj->admin;
|
||||
$societestatic->login=$obj->login;
|
||||
$societestatic->email=$obj->email;
|
||||
$societestatic->societe_id=$obj->fk_soc;
|
||||
|
||||
// Ref
|
||||
print "<TD><A href='".DOL_URL_ROOT."/stripe/transaction.php?rowid=".$txn->source."'>".$txn->source."</A></TD>\n";
|
||||
// Employee
|
||||
print "<TD>".$societestatic->getNomUrl(1)."</TD>\n";
|
||||
// Origine
|
||||
print "<TD>";
|
||||
if ($charge->metadata->source=="order"){
|
||||
$object = new Commande($db);
|
||||
$object->fetch($charge->metadata->idsource);
|
||||
print "<A href='".DOL_URL_ROOT."/commande/card.php?id=".$txn->metadata->idsource."'>".img_picto('', 'object_order')." ".$object->ref."</A>";
|
||||
} elseif ($txn->metadata->source=="invoice"){
|
||||
$object = new Facture($db);
|
||||
$object->fetch($txn->metadata->idsource);
|
||||
print "<A href='".DOL_URL_ROOT."/compta/facture/card.php?facid=".$txn->metadata->idsource."'>".img_picto('', 'object_invoice')." ".$object->ref."</A>";
|
||||
}
|
||||
print "</TD>\n";
|
||||
// Date payment
|
||||
print '<TD align="center">'.dol_print_date($txn->created,'%d/%m/%Y %H:%M')."</TD>\n";
|
||||
// Label payment
|
||||
print "<TD>";
|
||||
if ($charge->refunded=='1'){
|
||||
print $langs->trans("refunded");
|
||||
} elseif ($charge->paid=='1'){
|
||||
print $langs->trans("".$charge->status."");
|
||||
} else {
|
||||
$label="Message: ".$charge->failure_message."<BR>";
|
||||
$label.="Réseau: ".$charge->outcome->network_status."<BR>";
|
||||
$label.="Statut: ".$langs->trans("".$charge->outcome->seller_message."");
|
||||
print $form->textwithpicto($langs->trans("".$charge->status.""),$label,1);
|
||||
}
|
||||
print "</TD>\n";
|
||||
// Type
|
||||
print '<TD>'.$txn->type.'</TD>';
|
||||
// Amount
|
||||
print "<TD align=\"right\">".price(($txn->amount)/100)."</TD>";
|
||||
print "<TD align=\"right\">".price(($txn->fee)/100)."</TD>";
|
||||
print "</TR>\n";
|
||||
}
|
||||
print "</TABLE>";
|
||||
print '</DIV>';
|
||||
print '</FORM>';
|
||||
}else{
|
||||
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
Loading…
Reference in New Issue
Block a user