@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
···11+=== 1.16.0 2014-06-17
22+33+* Add metadata for refunds and disputes
44+55+=== 1.15.0 2014-05-28
66+77+* Support canceling transfers
88+99+=== 1.14.1 2014-05-21
1010+1111+* Support cards for recipients.
1212+1313+=== 1.13.1 2014-05-15
1414+1515+* Fix bug in account resource where `id` wasn't in the result
1616+1717+=== 1.13.0 2014-04-10
1818+1919+* Add support for certificate blacklisting
2020+* Update ca bundle
2121+* Drop support for HHVM (Temporarily)
2222+2323+=== 1.12.0 2014-04-01
2424+2525+* Add Stripe_RateLimitError for catching rate limit errors.
2626+* Update to Zend coding style (thanks, @jpiasetz)
2727+2828+=== 1.11.0 2014-01-29
2929+3030+* Add support for multiple subscriptions per customer
3131+3232+=== 1.10.1 2013-12-02
3333+3434+* Add new ApplicationFee
3535+3636+=== 1.9.1 2013-11-08
3737+3838+* Fix a bug where a null nestable object causes warnings to fire.
3939+4040+=== 1.9.0 2013-10-16
4141+4242+* Add support for metadata API.
4343+4444+=== 1.8.4 2013-09-18
4545+4646+* Add support for closing disputes.
4747+4848+=== 1.8.3 2013-08-13
4949+5050+* Add new Balance and BalanceTransaction
5151+5252+=== 1.8.2 2013-08-12
5353+5454+* Add support for unsetting attributes by updating to NULL.
5555+ Setting properties to a blank string is now an error.
5656+5757+=== 1.8.1 2013-07-12
5858+5959+* Add support for multiple cards API (Stripe API version 2013-07-12: https://stripe.com/docs/upgrades#2013-07-05)
6060+6161+=== 1.8.0 2013-04-11
6262+6363+* Allow Transfers to be creatable
6464+* Add new Recipient resource
6565+6666+=== 1.7.15 2013-02-21
6767+6868+* Add 'id' to the list of permanent object attributes
6969+7070+=== 1.7.14 2013-02-20
7171+7272+* Don't re-encode strings that are already encoded in UTF-8. If you
7373+ were previously using plan or coupon objects with UTF-8 IDs, they
7474+ may have been treated as ISO-8859-1 (Latin-1) and encoded to UTF-8 a
7575+ 2nd time. You may now need to pass the IDs to utf8_encode before
7676+ passing them to Stripe_Plan::retrieve or Stripe_Coupon::retrieve.
7777+* Ensure that all input is encoded in UTF-8 before submitting it to
7878+ Stripe's servers. (github issue #27)
7979+8080+=== 1.7.13 2013-02-01
8181+8282+* Add support for passing options when retrieving Stripe objects
8383+ e.g., Stripe_Charge::retrieve(array("id"=>"foo", "expand" => array("customer")))
8484+ Stripe_Charge::retrieve("foo") will continue to work
8585+8686+=== 1.7.12 2013-01-15
8787+8888+* Add support for setting a Stripe API version override
8989+9090+=== 1.7.11 2012-12-30
9191+9292+* Version bump to cleanup constants and such (github issue #26)
9393+9494+=== 1.7.10 2012-11-08
9595+9696+* Add support for updating charge disputes.
9797+* Fix bug preventing retrieval of null attributes
9898+9999+=== 1.7.9 2012-11-08
100100+101101+* Fix usage under autoloaders such as the one generated by composer
102102+ (github issue #22)
103103+104104+=== 1.7.8 2012-10-30
105105+* Add support for creating invoices.
106106+* Add support for new invoice lines return format
107107+* Add support for new list objects
108108+109109+=== 1.7.7 2012-09-14
110110+111111+* Get all of the various version numbers in the repo in sync (no other
112112+ changes)
113113+114114+=== 1.7.6 2012-08-31
115115+116116+* Add update and pay methods to Invoice resource
117117+118118+=== 1.7.5 2012-08-23
119119+120120+* Change internal function names so that Stripe_SingletonApiRequest is
121121+ E_STRICT-clean (github issue #16)
122122+123123+=== 1.7.4 2012-08-21
124124+125125+* Bugfix so that Stripe objects (e.g. Customer, Charge objects) used
126126+ in API calls are transparently converted to their object IDs
127127+128128+=== 1.7.3 2012-08-15
129129+130130+* Add new Account resource
131131+132132+=== 1.7.2 2012-06-26
133133+134134+* Make clearer that you should be including lib/Stripe.php, not
135135+ test/Stripe.php (github issue #14)
136136+137137+=== 1.7.1 2012-05-24
138138+139139+* Add missing argument to Stripe_InvalidRequestError constructor in
140140+ Stripe_ApiResource::instanceUrl. Fixes a warning when
141141+ Stripe_ApiResource::instanceUrl is called on a resource with no ID
142142+ (github issue #12)
143143+144144+=== 1.7.0 2012-05-17
145145+146146+* Support Composer and Packagist (github issue #9)
147147+148148+* Add new deleteDiscount method to Stripe_Customer
149149+150150+* Add new Transfer resource
151151+152152+* Switch from using HTTP Basic auth to Bearer auth. (Note: Stripe will
153153+ support Basic auth for the indefinite future, but recommends Bearer
154154+ auth when possible going forward)
155155+156156+* Numerous test suite improvements
+1-1
externals/stripe-php/LICENSE
···11The MIT License
2233-Copyright (c) 2010 Stripe
33+Copyright (c) 2010-2014 Stripe
4455Permission is hereby granted, free of charge, to any person obtaining a copy
66of this software and associated documentation files (the "Software"), to deal
+50-3
externals/stripe-php/README.rdoc
···11-= Installation
11+= Stripe PHP bindings
22+{<img src="https://travis-ci.org/stripe/stripe-php.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/stripe/stripe-php]
33+{<img src="https://poser.pugx.org/stripe/stripe-php/v/stable.svg" alt="Latest Stable Version" />}[https://packagist.org/packages/stripe/stripe-php]
44+{<img src="https://poser.pugx.org/stripe/stripe-php/downloads.svg" alt="Total Downloads" />}[https://packagist.org/packages/stripe/stripe-php]
55+{<img src="https://poser.pugx.org/stripe/stripe-php/license.svg" alt="License" />}[https://packagist.org/packages/stripe/stripe-php]
66+77+You can sign up for a Stripe account at https://stripe.com.
88+99+== Requirements
1010+1111+PHP 5.2 and later.
1212+1313+== Composer
1414+1515+You can install the bindings via Composer[http://getcomposer.org/]. Add this to your +composer.json+:
1616+1717+ {
1818+ "require": {
1919+ "stripe/stripe-php": "1.*"
2020+ }
2121+ }
2222+2323+Then install via:
2424+2525+ composer.phar install
2626+2727+To use the bindings, either user Composer's autoload[https://getcomposer.org/doc/00-intro.md#autoloading]:
2828+2929+ require_once('vendor/autoload.php');
3030+3131+Or manually:
3232+3333+ require_once('/path/to/vendor/stripe/stripe-php/lib/Stripe.php');
3434+3535+== Manual Installation
236337Obtain the latest version of the Stripe PHP bindings with:
438539 git clone https://github.com/stripe/stripe-php
64077-To get started, add the following to your PHP script:
4141+To use the bindings, add the following to your PHP script:
842943 require_once("/path/to/stripe-php/lib/Stripe.php");
4444+4545+== Getting Started
10461147Simple usage looks like:
1248···1551 $charge = Stripe_Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd'));
1652 echo $charge;
17531818-= Documentation
5454+== Documentation
19552056Please see https://stripe.com/api for up-to-date documentation.
5757+5858+== Tests
5959+6060+In order to run tests you have to install SimpleTest[http://packagist.org/packages/simpletest/simpletest] via Composer[http://getcomposer.org/] (recommended way):
6161+6262+ composer.phar update --dev
6363+6464+Run test suite:
6565+6666+ php ./test/Stripe.php
6767+
···11+<?php
22+33+// e.g. metadata on Stripe objects.
44+class Stripe_AttachedObject extends Stripe_Object
55+{
66+ /**
77+ * Updates this object.
88+ *
99+ * @param array $properties A mapping of properties to update on this object.
1010+ */
1111+ public function replaceWith($properties)
1212+ {
1313+ $removed = array_diff(array_keys($this->_values), array_keys($properties));
1414+ // Don't unset, but rather set to null so we send up '' for deletion.
1515+ foreach ($removed as $k) {
1616+ $this->$k = null;
1717+ }
1818+1919+ foreach ($properties as $k => $v) {
2020+ $this->$k = $v;
2121+ }
2222+ }
2323+}
···2233class Stripe_Object implements ArrayAccess
44{
55- public static $_permanentAttributes;
55+ /**
66+ * @var Stripe_Util_Set Attributes that should not be sent to the API because
77+ * they're not updatable (e.g. API key, ID).
88+ */
99+ public static $permanentAttributes;
1010+ /**
1111+ * @var Stripe_Util_Set Attributes that are nested but still updatable from
1212+ * the parent class's URL (e.g. metadata).
1313+ */
1414+ public static $nestedUpdatableAttributes;
615716 public static function init()
817 {
99- self::$_permanentAttributes = new Stripe_Util_Set(array('_apiKey'));
1818+ self::$permanentAttributes = new Stripe_Util_Set(array('_apiKey', 'id'));
1919+ self::$nestedUpdatableAttributes = new Stripe_Util_Set(array('metadata'));
1020 }
11211222 protected $_apiKey;
1323 protected $_values;
1424 protected $_unsavedValues;
1525 protected $_transientValues;
2626+ protected $_retrieveOptions;
16271728 public function __construct($id=null, $apiKey=null)
1829 {
···2031 $this->_values = array();
2132 $this->_unsavedValues = new Stripe_Util_Set();
2233 $this->_transientValues = new Stripe_Util_Set();
2323- if ($id)
3434+3535+ $this->_retrieveOptions = array();
3636+ if (is_array($id)) {
3737+ foreach ($id as $key => $value) {
3838+ if ($key != 'id') {
3939+ $this->_retrieveOptions[$key] = $value;
4040+ }
4141+ }
4242+ $id = $id['id'];
4343+ }
4444+4545+ if ($id !== null) {
2446 $this->id = $id;
4747+ }
2548 }
26492750 // Standard accessor magic methods
2851 public function __set($k, $v)
2952 {
3030- // TODO: may want to clear from $_transientValues. (Won't be user-visible.)
3131- $this->_values[$k] = $v;
3232- if (!self::$_permanentAttributes->includes($k))
5353+ if ($v === "") {
5454+ throw new InvalidArgumentException(
5555+ 'You cannot set \''.$k.'\'to an empty string. '
5656+ .'We interpret empty strings as NULL in requests. '
5757+ .'You may set obj->'.$k.' = NULL to delete the property'
5858+ );
5959+ }
6060+6161+ if (self::$nestedUpdatableAttributes->includes($k)
6262+ && isset($this->$k) && is_array($v)) {
6363+ $this->$k->replaceWith($v);
6464+ } else {
6565+ // TODO: may want to clear from $_transientValues (Won't be user-visible).
6666+ $this->_values[$k] = $v;
6767+ }
6868+ if (!self::$permanentAttributes->includes($k))
3369 $this->_unsavedValues->add($k);
3470 }
3571 public function __isset($k)
···4480 }
4581 public function __get($k)
4682 {
4747- if (isset($this->_values[$k])) {
8383+ if (array_key_exists($k, $this->_values)) {
4884 return $this->_values[$k];
4985 } else if ($this->_transientValues->includes($k)) {
5086 $class = get_class($this);
5187 $attrs = join(', ', array_keys($this->_values));
5252- error_log("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");
8888+ $message = "Stripe Notice: Undefined property of $class instance: $k. "
8989+ . "HINT: The $k attribute was set in the past, however. "
9090+ . "It was then wiped when refreshing the object "
9191+ . "with the result returned by Stripe's API, "
9292+ . "probably as a result of a save(). The attributes currently "
9393+ . "available on this object are: $attrs";
9494+ error_log($message);
5395 return null;
5496 } else {
5597 $class = get_class($this);
···63105 {
64106 $this->$k = $v;
65107 }
108108+66109 public function offsetExists($k)
67110 {
6868- return isset($this->$k);
111111+ return array_key_exists($k, $this->_values);
69112 }
113113+70114 public function offsetUnset($k)
71115 {
72116 unset($this->$k);
73117 }
74118 public function offsetGet($k)
75119 {
7676- return isset($this->_values[$k]) ? $this->_values[$k] : null;
120120+ return array_key_exists($k, $this->_values) ? $this->_values[$k] : null;
77121 }
781227979- // This unfortunately needs to be public to be used in Util.php
123123+ public function keys()
124124+ {
125125+ return array_keys($this->_values);
126126+ }
127127+128128+ /**
129129+ * This unfortunately needs to be public to be used in Util.php
130130+ *
131131+ * @param string $class
132132+ * @param array $values
133133+ * @param string|null $apiKey
134134+ *
135135+ * @return Stripe_Object The object constructed from the given values.
136136+ */
80137 public static function scopedConstructFrom($class, $values, $apiKey=null)
81138 {
82139 $obj = new $class(isset($values['id']) ? $values['id'] : null, $apiKey);
···84141 return $obj;
85142 }
86143144144+ /**
145145+ * @param array $values
146146+ * @param string|null $apiKey
147147+ *
148148+ * @return Stripe_Object The object of the same class as $this constructed
149149+ * from the given values.
150150+ */
87151 public static function constructFrom($values, $apiKey=null)
88152 {
8989- $class = get_class();
9090- return self::scopedConstructFrom($class, $values, $apiKey);
153153+ return self::scopedConstructFrom(__CLASS__, $values, $apiKey);
91154 }
92155156156+ /**
157157+ * Refreshes this object using the provided values.
158158+ *
159159+ * @param array $values
160160+ * @param string $apiKey
161161+ * @param boolean $partial Defaults to false.
162162+ */
93163 public function refreshFrom($values, $apiKey, $partial=false)
94164 {
95165 $this->_apiKey = $apiKey;
166166+96167 // Wipe old state before setting new. This is useful for e.g. updating a
97168 // customer, where there is no persistent card parameter. Mark those values
98169 // which don't persist as transient
9999- if ($partial)
170170+ if ($partial) {
100171 $removed = new Stripe_Util_Set();
101101- else
172172+ } else {
102173 $removed = array_diff(array_keys($this->_values), array_keys($values));
174174+ }
103175104176 foreach ($removed as $k) {
105105- if (self::$_permanentAttributes->includes($k))
177177+ if (self::$permanentAttributes->includes($k))
106178 continue;
107179 unset($this->$k);
108180 }
109181110182 foreach ($values as $k => $v) {
111111- if (self::$_permanentAttributes->includes($k))
183183+ if (self::$permanentAttributes->includes($k) && isset($this[$k]))
112184 continue;
113113- $this->_values[$k] = Stripe_Util::convertToStripeObject($v, $apiKey);
185185+186186+ if (self::$nestedUpdatableAttributes->includes($k) && is_array($v)) {
187187+ $this->_values[$k] = Stripe_Object::scopedConstructFrom(
188188+ 'Stripe_AttachedObject', $v, $apiKey
189189+ );
190190+ } else {
191191+ $this->_values[$k] = Stripe_Util::convertToStripeObject($v, $apiKey);
192192+ }
193193+114194 $this->_transientValues->discard($k);
115195 $this->_unsavedValues->discard($k);
116196 }
117197 }
118198199199+ /**
200200+ * @return array A recursive mapping of attributes to values for this object,
201201+ * including the proper value for deleted attributes.
202202+ */
203203+ public function serializeParameters()
204204+ {
205205+ $params = array();
206206+ if ($this->_unsavedValues) {
207207+ foreach ($this->_unsavedValues->toArray() as $k) {
208208+ $v = $this->$k;
209209+ if ($v === NULL) {
210210+ $v = '';
211211+ }
212212+ $params[$k] = $v;
213213+ }
214214+ }
215215+216216+ // Get nested updates.
217217+ foreach (self::$nestedUpdatableAttributes->toArray() as $property) {
218218+ if (isset($this->$property)
219219+ && $this->$property instanceOf Stripe_Object) {
220220+ $params[$property] = $this->$property->serializeParameters();
221221+ }
222222+ }
223223+ return $params;
224224+ }
225225+226226+ // Pretend to have late static bindings, even in PHP 5.2
227227+ protected function _lsb($method)
228228+ {
229229+ $class = get_class($this);
230230+ $args = array_slice(func_get_args(), 1);
231231+ return call_user_func_array(array($class, $method), $args);
232232+ }
233233+ protected static function _scopedLsb($class, $method)
234234+ {
235235+ $args = array_slice(func_get_args(), 2);
236236+ return call_user_func_array(array($class, $method), $args);
237237+ }
238238+119239 public function __toJSON()
120240 {
121121- if (defined('JSON_PRETTY_PRINT'))
241241+ if (defined('JSON_PRETTY_PRINT')) {
122242 return json_encode($this->__toArray(true), JSON_PRETTY_PRINT);
123123- else
243243+ } else {
124244 return json_encode($this->__toArray(true));
245245+ }
125246 }
126247127248 public function __toString()
···131252132253 public function __toArray($recursive=false)
133254 {
134134- if ($recursive)
255255+ if ($recursive) {
135256 return Stripe_Util::convertStripeObjectToArray($this->_values);
136136- else
257257+ } else {
137258 return $this->_values;
259259+ }
138260 }
139261}
140262
+26-6
externals/stripe-php/lib/Stripe/Plan.php
···2233class Stripe_Plan extends Stripe_ApiResource
44{
55- public static function constructFrom($values, $apiKey=null)
66- {
77- $class = get_class();
88- return self::scopedConstructFrom($class, $values, $apiKey);
99- }
1010-55+ /**
66+ * @param string $id The ID of the plan to retrieve.
77+ * @param string|null $apiKey
88+ *
99+ * @return Stripe_Plan
1010+ */
1111 public static function retrieve($id, $apiKey=null)
1212 {
1313 $class = get_class();
1414 return self::_scopedRetrieve($class, $id, $apiKey);
1515 }
16161717+ /**
1818+ * @param array|null $params
1919+ * @param string|null $apiKey
2020+ *
2121+ * @return Stripe_Plan The created plan.
2222+ */
1723 public static function create($params=null, $apiKey=null)
1824 {
1925 $class = get_class();
2026 return self::_scopedCreate($class, $params, $apiKey);
2127 }
22282929+ /**
3030+ * @param array|null $params
3131+ *
3232+ * @return Stripe_Plan The deleted plan.
3333+ */
2334 public function delete($params=null)
2435 {
2536 $class = get_class();
2637 return self::_scopedDelete($class, $params);
2738 }
28394040+ /**
4141+ * @return Stripe_Plan The saved plan.
4242+ */
2943 public function save()
3044 {
3145 $class = get_class();
3246 return self::_scopedSave($class);
3347 }
34484949+ /**
5050+ * @param array|null $params
5151+ * @param string|null $apiKey
5252+ *
5353+ * @return array An array of Stripe_Plans.
5454+ */
3555 public static function all($params=null, $apiKey=null)
3656 {
3757 $class = get_class();
···11+<?php
22+33+abstract class Stripe_SingletonApiResource extends Stripe_ApiResource
44+{
55+ protected static function _scopedSingletonRetrieve($class, $apiKey=null)
66+ {
77+ $instance = new $class(null, $apiKey);
88+ $instance->refresh();
99+ return $instance;
1010+ }
1111+1212+ /**
1313+ * @param Stripe_SingletonApiResource $class
1414+ * @return string The endpoint associated with this singleton class.
1515+ */
1616+ public static function classUrl($class)
1717+ {
1818+ $base = self::className($class);
1919+ return "/v1/${base}";
2020+ }
2121+2222+ /**
2323+ * @return string The endpoint associated with this singleton API resource.
2424+ */
2525+ public function instanceUrl()
2626+ {
2727+ $class = get_class($this);
2828+ $base = self::classUrl($class);
2929+ return "$base";
3030+ }
3131+}
+73
externals/stripe-php/lib/Stripe/Stripe.php
···11+<?php
22+33+abstract class Stripe
44+{
55+ /**
66+ * @var string The Stripe API key to be used for requests.
77+ */
88+ public static $apiKey;
99+ /**
1010+ * @var string The base URL for the Stripe API.
1111+ */
1212+ public static $apiBase = 'https://api.stripe.com';
1313+ /**
1414+ * @var string|null The version of the Stripe API to use for requests.
1515+ */
1616+ public static $apiVersion = null;
1717+ /**
1818+ * @var boolean Defaults to true.
1919+ */
2020+ public static $verifySslCerts = true;
2121+ const VERSION = '1.16.0';
2222+2323+ /**
2424+ * @return string The API key used for requests.
2525+ */
2626+ public static function getApiKey()
2727+ {
2828+ return self::$apiKey;
2929+ }
3030+3131+ /**
3232+ * Sets the API key to be used for requests.
3333+ *
3434+ * @param string $apiKey
3535+ */
3636+ public static function setApiKey($apiKey)
3737+ {
3838+ self::$apiKey = $apiKey;
3939+ }
4040+4141+ /**
4242+ * @return string The API version used for requests. null if we're using the
4343+ * latest version.
4444+ */
4545+ public static function getApiVersion()
4646+ {
4747+ return self::$apiVersion;
4848+ }
4949+5050+ /**
5151+ * @param string $apiVersion The API version to use for requests.
5252+ */
5353+ public static function setApiVersion($apiVersion)
5454+ {
5555+ self::$apiVersion = $apiVersion;
5656+ }
5757+5858+ /**
5959+ * @return boolean
6060+ */
6161+ public static function getVerifySslCerts()
6262+ {
6363+ return self::$verifySslCerts;
6464+ }
6565+6666+ /**
6767+ * @param boolean $verify
6868+ */
6969+ public static function setVerifySslCerts($verify)
7070+ {
7171+ self::$verifySslCerts = $verify;
7272+ }
7373+}
+57
externals/stripe-php/lib/Stripe/Subscription.php
···11+<?php
22+33+class Stripe_Subscription extends Stripe_ApiResource
44+{
55+ /**
66+ * @return string The API URL for this Stripe subscription.
77+ */
88+ public function instanceUrl()
99+ {
1010+ $id = $this['id'];
1111+ $customer = $this['customer'];
1212+ if (!$id) {
1313+ throw new Stripe_InvalidRequestError(
1414+ "Could not determine which URL to request: " .
1515+ "class instance has invalid ID: $id",
1616+ null
1717+ );
1818+ }
1919+ $id = Stripe_ApiRequestor::utf8($id);
2020+ $customer = Stripe_ApiRequestor::utf8($customer);
2121+2222+ $base = self::classUrl('Stripe_Customer');
2323+ $customerExtn = urlencode($customer);
2424+ $extn = urlencode($id);
2525+ return "$base/$customerExtn/subscriptions/$extn";
2626+ }
2727+2828+ /**
2929+ * @param array|null $params
3030+ * @return Stripe_Subscription The deleted subscription.
3131+ */
3232+ public function cancel($params=null)
3333+ {
3434+ $class = get_class();
3535+ return self::_scopedDelete($class, $params);
3636+ }
3737+3838+ /**
3939+ * @return Stripe_Subscription The saved subscription.
4040+ */
4141+ public function save()
4242+ {
4343+ $class = get_class();
4444+ return self::_scopedSave($class);
4545+ }
4646+4747+ /**
4848+ * @return Stripe_Subscription The updated subscription.
4949+ */
5050+ public function deleteDiscount()
5151+ {
5252+ $requestor = new Stripe_ApiRequestor($this->_apiKey);
5353+ $url = $this->instanceUrl() . '/discount';
5454+ list($response, $apiKey) = $requestor->request('delete', $url);
5555+ $this->refreshFrom(array('discount' => null), $apiKey, true);
5656+ }
5757+}
+12-6
externals/stripe-php/lib/Stripe/Token.php
···2233class Stripe_Token extends Stripe_ApiResource
44{
55- public static function constructFrom($values, $apiKey=null)
66- {
77- $class = get_class();
88- return self::scopedConstructFrom($class, $values, $apiKey);
99- }
1010-55+ /**
66+ * @param string $id The ID of the token to retrieve.
77+ * @param string|null $apiKey
88+ *
99+ * @return Stripe_Token
1010+ */
1111 public static function retrieve($id, $apiKey=null)
1212 {
1313 $class = get_class();
1414 return self::_scopedRetrieve($class, $id, $apiKey);
1515 }
16161717+ /**
1818+ * @param array|null $params
1919+ * @param string|null $apiKey
2020+ *
2121+ * @return Stripe_Coupon The created token.
2222+ */
1723 public static function create($params=null, $apiKey=null)
1824 {
1925 $class = get_class();
+62
externals/stripe-php/lib/Stripe/Transfer.php
···11+<?php
22+33+class Stripe_Transfer extends Stripe_ApiResource
44+{
55+ /**
66+ * @param string $id The ID of the transfer to retrieve.
77+ * @param string|null $apiKey
88+ *
99+ * @return Stripe_Transfer
1010+ */
1111+ public static function retrieve($id, $apiKey=null)
1212+ {
1313+ $class = get_class();
1414+ return self::_scopedRetrieve($class, $id, $apiKey);
1515+ }
1616+1717+ /**
1818+ * @param array|null $params
1919+ * @param string|null $apiKey
2020+ *
2121+ * @return array An array of Stripe_Transfers.
2222+ */
2323+ public static function all($params=null, $apiKey=null)
2424+ {
2525+ $class = get_class();
2626+ return self::_scopedAll($class, $params, $apiKey);
2727+ }
2828+2929+ /**
3030+ * @param array|null $params
3131+ * @param string|null $apiKey
3232+ *
3333+ * @return Stripe_Transfer The created transfer.
3434+ */
3535+ public static function create($params=null, $apiKey=null)
3636+ {
3737+ $class = get_class();
3838+ return self::_scopedCreate($class, $params, $apiKey);
3939+ }
4040+4141+ /**
4242+ * @return Stripe_Transfer The canceled transfer.
4343+ */
4444+ public function cancel()
4545+ {
4646+ $requestor = new Stripe_ApiRequestor($this->_apiKey);
4747+ $url = $this->instanceUrl() . '/cancel';
4848+ list($response, $apiKey) = $requestor->request('post', $url);
4949+ $this->refreshFrom($response, $apiKey);
5050+ return $this;
5151+ }
5252+5353+ /**
5454+ * @return Stripe_Transfer The saved transfer.
5555+ */
5656+ public function save()
5757+ {
5858+ $class = get_class();
5959+ return self::_scopedSave($class);
6060+ }
6161+6262+}
+43-12
externals/stripe-php/lib/Stripe/Util.php
···2233abstract class Stripe_Util
44{
55+ /**
66+ * Whether the provided array (or other) is a list rather than a dictionary.
77+ *
88+ * @param array|mixed $array
99+ * @return boolean True if the given object is a list.
1010+ */
511 public static function isList($array)
612 {
713 if (!is_array($array))
814 return false;
99- // TODO: this isn't actually correct in general, but it's correct given Stripe's responses
1515+1616+ // TODO: generally incorrect, but it's correct given Stripe's response
1017 foreach (array_keys($array) as $k) {
1118 if (!is_numeric($k))
1219 return false;
···1421 return true;
1522 }
16232424+ /**
2525+ * Recursively converts the PHP Stripe object to an array.
2626+ *
2727+ * @param array $values The PHP Stripe object to convert.
2828+ * @return array
2929+ */
1730 public static function convertStripeObjectToArray($values)
1831 {
1932 $results = array();
2033 foreach ($values as $k => $v) {
2134 // FIXME: this is an encapsulation violation
2222- if (Stripe_Object::$_permanentAttributes->includes($k)) {
3535+ if ($k[0] == '_') {
2336 continue;
2437 }
2538 if ($v instanceof Stripe_Object) {
2639 $results[$k] = $v->__toArray(true);
2727- }
2828- else if (is_array($v)) {
4040+ } else if (is_array($v)) {
2941 $results[$k] = self::convertStripeObjectToArray($v);
3030- }
3131- else {
4242+ } else {
3243 $results[$k] = $v;
3344 }
3445 }
3546 return $results;
3647 }
37484949+ /**
5050+ * Converts a response from the Stripe API to the corresponding PHP object.
5151+ *
5252+ * @param array $resp The response from the Stripe API.
5353+ * @param string $apiKey
5454+ * @return Stripe_Object|array
5555+ */
3856 public static function convertToStripeObject($resp, $apiKey)
3957 {
4040- $types = array('charge' => 'Stripe_Charge',
4141- 'customer' => 'Stripe_Customer',
4242- 'invoice' => 'Stripe_Invoice',
4343- 'invoiceitem' => 'Stripe_InvoiceItem', 'event' => 'Stripe_Event');
5858+ $types = array(
5959+ 'card' => 'Stripe_Card',
6060+ 'charge' => 'Stripe_Charge',
6161+ 'customer' => 'Stripe_Customer',
6262+ 'list' => 'Stripe_List',
6363+ 'invoice' => 'Stripe_Invoice',
6464+ 'invoiceitem' => 'Stripe_InvoiceItem',
6565+ 'event' => 'Stripe_Event',
6666+ 'transfer' => 'Stripe_Transfer',
6767+ 'plan' => 'Stripe_Plan',
6868+ 'recipient' => 'Stripe_Recipient',
6969+ 'refund' => 'Stripe_Refund',
7070+ 'subscription' => 'Stripe_Subscription'
7171+ );
4472 if (self::isList($resp)) {
4573 $mapped = array();
4674 foreach ($resp as $i)
4775 array_push($mapped, self::convertToStripeObject($i, $apiKey));
4876 return $mapped;
4977 } else if (is_array($resp)) {
5050- if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']]))
7878+ if (isset($resp['object'])
7979+ && is_string($resp['object'])
8080+ && isset($types[$resp['object']])) {
5181 $class = $types[$resp['object']];
5252- else
8282+ } else {
5383 $class = 'Stripe_Object';
8484+ }
5485 return Stripe_Object::scopedConstructFrom($class, $resp, $apiKey);
5586 } else {
5687 return $resp;