Plugin Directory

Changeset 1725154


Ignore:
Timestamp:
09/05/2017 08:01:48 PM (9 years ago)
Author:
nickyoung87
Message:

Committing 2.0.0

Location:
stripe/trunk
Files:
303 added
18 deleted
56 edited

Legend:

Unmodified
Added
Removed
  • stripe/trunk/readme.txt

    r1625278 r1725154  
    22Contributors: moonstonemedia, pderksen, nickyoung87, nekojira
    33Tags: stripe, payments, credit card, stripe payments, stripe checkout
    4 Requires at least: 4.3
    5 Tested up to: 4.7
    6 Stable tag: 1.6.0
     4Requires at least: 4.7
     5Tested up to: 4.8
     6Stable tag: 2.0.0
     7Requires PHP: 5.3
    78License: GPLv2 or later
    89
     
    2526That's it. **No other plugins required.**
    2627
    27 >**[Check out our demos & PRO version](https://wpsimplepay.com/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)**
    28 
    29 SSL note: Stripe requires that any page hosting a live checkout form be SSL (they should start with `https://`). [See system requirements.](https://wpsimplepay.com/docs/getting-started/system-requirements/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)
     28>**[Check out our demos & Pro version](https://demo.wpsimplepay.com/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)**
     29
     30SSL note: Stripe requires that any page hosting a live checkout form be SSL (they should start with `https://`). [See system requirements.](https://docs.wpsimplepay.com/articles/system-requirements-wp-simple-pay-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)
    3031
    3132= LITE VERSION FEATURES =
     
    3435* Mobile responsive Stripe Checkout overlay
    3536* Display brand or product image in overlay
    36 * Optionally collect customer billing address
     37* Optionally collect customer billing & addresses
    3738* Optionally verify zip/postal code without address
    38 * Support for 12 languages, 25 countries and 139 currencies
     39* Support for 12 languages, 25 countries and 135+ currencies
     40* Bitcoin payment option
    3941* Translation ready
    40 * Bitcoin and Alipay payment options
    4142* Multiple Stripe API key support
    4243* [AffiliateWP](https://affiliatewp.com/) integration
    4344* Specify payment success & failure pages
    4445* Live/Test mode toggle
    45 * Filters, hooks and [code snippets](https://github.com/moonstonemedia/WP-Simple-Pay-Snippet-Library) for developers
     46* [Code snippets](https://github.com/moonstonemedia/WP-Simple-Pay-Snippet-Library/) & [hook reference](https://docs.wpsimplepay.com/articles/action-filter-hooks/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description) for developers
    4647
    4748= PRO VERSION FEATURES =
    4849
    4950* *Everything in Lite plus...*
     51* Drag & drop form design controls
    5052* Custom fields to capture additional data
    51 * Custom amounts - let customers enter amount to pay
     53* Custom amounts - let customers enter an amount to pay
    5254* Coupon code support
     55* Tax rate support
    5356* Stripe Subscription support
    5457* Subscription installment plans
     
    5659* Subscription trial periods
    5760* [Easy Pricing Tables](https://fatcatapps.com/easypricingtables/) integration
    58 * Optionally collect customer shipping address
    5961* Priority email support with a 24-hour response time during business days
    6062
    61 >**[Get More with WP Simple Pay PRO for Stripe](https://wpsimplepay.com/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)**
     63>**[Get More with WP Simple Pay Pro](https://wpsimplepay.com/lite-vs-pro/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)**
    6264
    6365== Installation ==
    6466
    65 [Plugin installation instructions](https://wpsimplepay.com/docs/getting-started/installing-stripe-checkout-lite/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=installation)
     67The easiest way to install WP Simple Pay is to search for it via your site’s Dashboard.
     68
     69= Step-by-step instructions =
     70
     711. Log in to your site’s dashboard (e.g. www.yourdomain.com/wp-admin).
     722. Click on the “Plugins” tab in the left panel, then click “Add New”.
     733. Search for “Stripe” or “WP Simple Pay” and find our plugin near the top. Look for the author “Moonstone Media”.
     744. Install it by clicking the “Install Now” link.
     755. When installation finishes, click “Activate Plugin”.
     766. A new menu item “Simple Pay Lite” should appear in your dashboard.
     77
     78If you prefer installing manually you can [download the plugin ZIP file here](https://downloads.wordpress.org/plugin/stripe.latest-stable.zip).
     79
     80Additional documentation at [docs.wpsimplepay.com](https://docs.wpsimplepay.com/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=installation).
    6681
    6782== Frequently Asked Questions ==
     
    6984= Where's your plugin documentation? =
    7085
    71 Find our docs at [wpsimplepay.com/docs](https://wpsimplepay.com/docs/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=faq)
    72 
    73 = What are the system requirements? =
    74 
    75 SSL is required on live checkout pages, and we recommend staying current with both PHP and WP for security reasons and PCI-DSS compliance. [See system requirements.](https://wpsimplepay.com/docs/getting-started/system-requirements/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=description)
     86Find our docs at [docs.wpsimplepay.com](https://docs.wpsimplepay.com/?utm_source=wordpress.org&utm_medium=link&utm_campaign=simple-pay-lite-readme&utm_content=faq).
    7687
    7788= Can I get notified by email of new releases? =
     
    7990[Subscribe here](https://www.getdrip.com/forms/6606935/submissions/new) to be notified by email of major features or updates.
    8091
    81 = How do I contribute to WP Simple Pay Lite? =
     92= How do I contribute to WP Simple Pay? =
    8293
    8394We'd love your help! Here's a few things you can do:
    8495
    85 * [Rate our plugin](https://wordpress.org/support/view/plugin-reviews/stripe?postform#postform) and help spread the word!
     96* [Rate our plugin](https://wordpress.org/support/plugin/stripe/reviews/#new-post) and help spread the word!
    8697* Help answer questions in our [community support forum](https://wordpress.org/support/plugin/stripe).
    8798* Report bugs (with steps to reproduce) or submit pull requests [on GitHub](https://github.com/moonstonemedia/WP-Simple-Pay-Lite-for-Stripe).
     
    90101== Screenshots ==
    91102
    92 1. Desktop checkout overlay
    93 2. Mobile checkout overlay
     1031. Desktop checkout overlay example
     1042. Mobile checkout overlay example
    941053. Settings: Stripe keys
    951064. Settings: Site-wide defaults
     1075. Settings: Payment confirmation details
     1086. Payment forms listing
     1097. Payment form settings: One-time amount
     1108. Payment form settings: Payment button
     1119. Payment form settings: Stripe Checkout overlay display
    96112
    97113== Changelog ==
     114
     115= 2.0.0 - September 5, 2017 =
     116
     117* Feature: Payment form settings overhauled to match WP Simple Pay Pro v3 update.
     118* Feature: Payment forms can be optionally saved as drafts and previewed.
     119* Feature: Button added to post editor for quickly adding payment forms to pages.
     120* Feature: Shortcodes for payment forms have been notably simplified.
     121* Feature: Shipping information can now be captured in the Stripe Checkout overlay.
     122* Feature: Added currency formatting options to settings.
     123* Feature: Payment details can now be edited using the standard post editor.
     124* Feature: Admin bar now indicates if in test mode.
     125* Fix: Removed support for Alipay since it is no longer supported through Stripe Checkout.
     126* Dev: Removed POT file since WordPress has better ways of handling translations now.
     127* Dev: Now using custom post type to hold individual form settings and to match Pro v3 update.
     128* Dev: Add official PHP version requirement check from wordpress.org to readme.txt header.
     129* Dev: Tested up to WordPress 4.8.
     130* Dev: Updated to Stripe PHP library v5.2.0.
    98131
    99132= 1.6.0 - March 29, 2017 =
     
    346379
    347380* Initial release.
     381
     382== Upgrade Notice ==
     383
     384= 2.0.0 =
     385
     386The payment form builder has been completely redone, but should be much simpler.
     387
     388Your existing payment forms using the legacy <code>[stripe]</code> shortcode should continue to work, but it is highly recommended to use the new settings going forward.
  • stripe/trunk/uninstall.php

    r1516951 r1725154  
    11<?php
    22
    3 /**
    4  * Fired when the plugin is uninstalled.
    5  */
    6 
    7 // If uninstall, not called from WordPress, then exit.
     3// Exit if not uninstalling from WordPress.
    84if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    95    exit;
    106}
    117
     8global $wpdb;
     9
     10$general = get_option( 'simpay_settings_general' );
     11
     12// Check save settings option before removing everything
     13if ( ! isset( $general['general_misc']['save_settings'] ) ) {
     14
     15
     16    // First remove the payment confirmation pages
     17    $success_page = $general['general']['success_page'];
     18    $failure_page = $general['general']['failure_page'];
     19
     20    wp_delete_post( $success_page, true );
     21    wp_delete_post( $failure_page, true );
     22
     23    // Remove main options
     24    delete_option( 'simpay_settings' );
     25
     26    // Remove misc options
     27    delete_option( 'simpay_dismiss_ssl' );
     28    delete_option( 'simpay_preview_form_id' );
     29
     30    // Remove settings options
     31    delete_option( 'simpay_settings_general' );
     32    delete_option( 'simpay_settings_keys' );
     33    delete_option( 'simpay_settings_display' );
     34    delete_option( 'simpay_settings_shipping_billing' );
     35
     36    // Delete form posts.
     37    $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'simple-pay' );" );
     38
     39    // Delete forms postmeta.
     40    $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
     41
     42}
     43
     44// Check if we need to remove legacy settings
    1245$settings = get_option( 'sc_settings' );
    1346
  • stripe/trunk/vendor/stripe/stripe-php/CHANGELOG.md

    r1625278 r1725154  
     1### 5.2.0 2017-08-29
     2
     3* Add support for `InvalidClient` OAuth error
     4
     5### 5.1.3 2017-08-14
     6
     7* Allow `address_kana` and `address_kanji` to be updated for custom accounts
     8
     9### 5.1.2 2017-08-01
     10
     11* Fix documented return type of `autoPagingIterator()` (was missing namespace)
     12
     13### 5.1.1 2017-07-03
     14
     15* Fix order returns to use the right URL `/v1/order_returns`
     16
     17### 5.1.0 2017-06-30
     18
     19* Add support for OAuth
     20
     21### 5.0.0 2017-06-27
     22
     23* `pay` on invoice now takes params as well as opts
     24
     25### 4.13.0 2017-06-19
     26
     27* Add support for ephemeral keys
     28
     29### 4.12.0 2017-06-05
     30
     31* Clients can implement `getUserAgentInfo()` to add additional user agent information
     32
     33### 4.11.0 2017-06-05
     34
     35* Implement `Countable` for `AttachedObject` (`metadata` and `additional_owners`)
     36
     37### 4.10.0 2017-05-25
     38
     39* Add support for login links
     40
     41### 4.9.1 2017-05-10
     42
     43* Fix docs to include arrays on `$id` parameter for retrieve methods
     44
     45### 4.9.0 2017-04-28
     46
     47* Support for checking webhook signatures
     48
     49### 4.8.1 2017-04-24
     50
     51* Allow nested field `payout_schedule` to be updated
     52
     53### 4.8.0 2017-04-20
     54
     55* Add `\Stripe\Stripe::setLogger()` to support an external PSR-3 compatible logger
     56
     57### 4.7.0 2017-04-10
     58
     59* Add support for payouts and recipient transfers
     60
     61### 4.6.0 2017-04-06
     62
     63* Please see 4.7.0 instead (no-op release) 
     64
    165### 4.5.1 2017-03-22
    266
  • stripe/trunk/vendor/stripe/stripe-php/README.md

    r1625278 r1725154  
    6767```php
    6868Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249');
    69 $myCard = array('number' => '4242424242424242', 'exp_month' => 8, 'exp_year' => 2018);
    70 $charge = Stripe_Charge::create(array('card' => $myCard, 'amount' => 2000, 'currency' => 'usd'));
     69$charge = Stripe_Charge::create(array('source' => 'tok_XXXXXXXX', 'amount' => 2000, 'currency' => 'usd'));
    7170echo $charge;
    7271```
     
    105104
    106105Alternately, 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.
     106
     107### Configuring a Logger
     108
     109The library does minimal logging, but it can be configured
     110with a [`PSR-3` compatible logger][psr3] so that messages
     111end up there instead of `error_log`:
     112
     113```php
     114\Stripe\Stripe::setLogger($logger);
     115```
    107116
    108117### SSL / TLS compatibility issues
     
    152161
    153162See 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`.
     163
     164[psr3]: http://www.php-fig.org/psr/psr-3/
  • stripe/trunk/vendor/stripe/stripe-php/VERSION

    r1625278 r1725154  
    1 4.5.1
     15.2.0
  • stripe/trunk/vendor/stripe/stripe-php/init.php

    r1519517 r1725154  
    66// Utilities
    77require(dirname(__FILE__) . '/lib/Util/AutoPagingIterator.php');
     8require(dirname(__FILE__) . '/lib/Util/LoggerInterface.php');
     9require(dirname(__FILE__) . '/lib/Util/DefaultLogger.php');
    810require(dirname(__FILE__) . '/lib/Util/RequestOptions.php');
    911require(dirname(__FILE__) . '/lib/Util/Set.php');
     
    2325require(dirname(__FILE__) . '/lib/Error/Permission.php');
    2426require(dirname(__FILE__) . '/lib/Error/RateLimit.php');
     27require(dirname(__FILE__) . '/lib/Error/SignatureVerification.php');
     28
     29// OAuth errors
     30require(dirname(__FILE__) . '/lib/Error/OAuth/OAuthBase.php');
     31require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidClient.php');
     32require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidGrant.php');
     33require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidRequest.php');
     34require(dirname(__FILE__) . '/lib/Error/OAuth/InvalidScope.php');
     35require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedGrantType.php');
     36require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedResponseType.php');
    2537
    2638// Plumbing
     
    5264require(dirname(__FILE__) . '/lib/Customer.php');
    5365require(dirname(__FILE__) . '/lib/Dispute.php');
     66require(dirname(__FILE__) . '/lib/EphemeralKey.php');
    5467require(dirname(__FILE__) . '/lib/Event.php');
    5568require(dirname(__FILE__) . '/lib/FileUpload.php');
    5669require(dirname(__FILE__) . '/lib/Invoice.php');
    5770require(dirname(__FILE__) . '/lib/InvoiceItem.php');
     71require(dirname(__FILE__) . '/lib/LoginLink.php');
    5872require(dirname(__FILE__) . '/lib/Order.php');
    5973require(dirname(__FILE__) . '/lib/OrderReturn.php');
     74require(dirname(__FILE__) . '/lib/Payout.php');
    6075require(dirname(__FILE__) . '/lib/Plan.php');
    6176require(dirname(__FILE__) . '/lib/Product.php');
    6277require(dirname(__FILE__) . '/lib/Recipient.php');
     78require(dirname(__FILE__) . '/lib/RecipientTransfer.php');
    6379require(dirname(__FILE__) . '/lib/Refund.php');
    6480require(dirname(__FILE__) . '/lib/SKU.php');
     
    7086require(dirname(__FILE__) . '/lib/Transfer.php');
    7187require(dirname(__FILE__) . '/lib/TransferReversal.php');
     88
     89// OAuth
     90require(dirname(__FILE__) . '/lib/OAuth.php');
     91
     92// Webhooks
     93require(dirname(__FILE__) . '/lib/Webhook.php');
     94require(dirname(__FILE__) . '/lib/WebhookSignature.php');
  • stripe/trunk/vendor/stripe/stripe-php/lib/Account.php

    r1463408 r1725154  
    2222 * @property mixed $legal_entity
    2323 * @property bool $managed
     24 * @property mixed $payout_schedule
     25 * @property mixed $payout_statement_descriptor
     26 * @property bool $payouts_enabled
    2427 * @property mixed $product_description
    2528 * @property mixed $statement_descriptor
     
    2831 * @property string $timezone
    2932 * @property mixed $tos_acceptance
    30  * @property mixed $transfer_schedule
    31  * @property bool $transfers_enabled
    3233 * @property mixed $verification
    3334 * @property mixed $keys
     
    4748
    4849    /**
    49      * @param string|null $id
     50     * @param array|string|null $id The ID of the account to retrieve, or an
     51     *     options array containing an `id` key.
    5052     * @param array|string|null $opts
    5153     *
     
    129131        return self::_all($params, $opts);
    130132    }
     133
     134    public function deauthorize($clientId = null, $opts = null)
     135    {
     136        $params = array(
     137            'client_id' => $clientId,
     138            'stripe_user_id' => $this->id,
     139        );
     140        OAuth::deauthorize($params, $opts);
     141    }
    131142}
  • stripe/trunk/vendor/stripe/stripe-php/lib/ApiRequestor.php

    r1625278 r1725154  
    8585     * @throws Error\Api otherwise.
    8686     */
    87     public function handleApiError($rbody, $rcode, $rheaders, $resp)
     87    public function handleErrorResponse($rbody, $rcode, $rheaders, $resp)
    8888    {
    8989        if (!is_array($resp) || !isset($resp['error'])) {
     
    9393        }
    9494
    95         $error = $resp['error'];
    96         $msg = isset($error['message']) ? $error['message'] : null;
    97         $param = isset($error['param']) ? $error['param'] : null;
    98         $code = isset($error['code']) ? $error['code'] : null;
     95        $errorData = $resp['error'];
     96
     97        $error = null;
     98        if (is_string($errorData)) {
     99            $error = self::_specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorData);
     100        }
     101        if (!$error) {
     102            $error = self::_specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData);
     103        }
     104
     105        throw $error;
     106    }
     107
     108    private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData)
     109    {
     110        $msg = isset($errorData['message']) ? $errorData['message'] : null;
     111        $param = isset($errorData['param']) ? $errorData['param'] : null;
     112        $code = isset($errorData['code']) ? $errorData['code'] : null;
    99113
    100114        switch ($rcode) {
     
    103117                // for API versions earlier than 2015-09-08
    104118                if ($code == 'rate_limit') {
    105                     throw new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
     119                    return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
    106120                }
    107121
    108122                // intentional fall-through
    109123            case 404:
    110                 throw new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
     124                return new Error\InvalidRequest($msg, $param, $rcode, $rbody, $resp, $rheaders);
    111125            case 401:
    112                 throw new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
     126                return new Error\Authentication($msg, $rcode, $rbody, $resp, $rheaders);
    113127            case 402:
    114                 throw new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
     128                return new Error\Card($msg, $param, $code, $rcode, $rbody, $resp, $rheaders);
    115129            case 403:
    116                 throw new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
     130                return new Error\Permission($msg, $rcode, $rbody, $resp, $rheaders);
    117131            case 429:
    118                 throw new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
     132                return new Error\RateLimit($msg, $param, $rcode, $rbody, $resp, $rheaders);
    119133            default:
    120                 throw new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
    121         }
     134                return new Error\Api($msg, $rcode, $rbody, $resp, $rheaders);
     135        }
     136    }
     137
     138    private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode)
     139    {
     140        $description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode;
     141
     142        switch ($errorCode) {
     143            case 'invalid_client':
     144                return new Error\OAuth\InvalidClient($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
     145            case 'invalid_grant':
     146                return new Error\OAuth\InvalidGrant($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
     147            case 'invalid_request':
     148                return new Error\OAuth\InvalidRequest($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
     149            case 'invalid_scope':
     150                return new Error\OAuth\InvalidScope($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
     151            case 'unsupported_grant_type':
     152                return new Error\OAuth\UnsupportedGrantType($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
     153            case 'unsupported_response_type':
     154                return new Error\OAuth\UnsupportedResponseType($errorCode, $description, $rcode, $rbody, $resp, $rheaders);
     155        }
     156
     157        return null;
    122158    }
    123159
     
    138174    }
    139175
    140     private static function _defaultHeaders($apiKey)
    141     {
    142         $appInfo = Stripe::getAppInfo();
    143 
     176    private static function _defaultHeaders($apiKey, $clientInfo = null)
     177    {
    144178        $uaString = 'Stripe/v1 PhpBindings/' . Stripe::VERSION;
    145179
    146180        $langVersion = phpversion();
    147181        $uname = php_uname();
    148 
    149         $httplib = 'unknown';
    150         $ssllib = 'unknown';
    151 
    152         if (function_exists('curl_version')) {
    153             $curlVersion = curl_version();
    154             $httplib = 'curl ' . $curlVersion['version'];
    155             $ssllib = $curlVersion['ssl_version'];
    156         }
    157182
    158183        $appInfo = Stripe::getAppInfo();
     
    163188            'publisher' => 'stripe',
    164189            'uname' => $uname,
    165             'httplib' => $httplib,
    166             'ssllib' => $ssllib,
    167190        );
     191        if ($clientInfo) {
     192            $ua = array_merge($clientInfo, $ua);
     193        }
    168194        if ($appInfo !== null) {
    169195            $uaString .= ' ' . self::_formatAppInfo($appInfo);
     
    194220        }
    195221
     222        // Clients can supply arbitrary additional keys to be included in the
     223        // X-Stripe-Client-User-Agent header via the optional getUserAgentInfo()
     224        // method
     225        $clientUAInfo = null;
     226        if (method_exists($this->httpClient(), 'getUserAgentInfo')) {
     227            $clientUAInfo = $this->httpClient()->getUserAgentInfo();
     228        }
     229
    196230        $absUrl = $this->_apiBase.$url;
    197231        $params = self::_encodeObjects($params);
    198         $defaultHeaders = $this->_defaultHeaders($myApiKey);
     232        $defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo);
    199233        if (Stripe::$apiVersion) {
    200234            $defaultHeaders['Stripe-Version'] = Stripe::$apiVersion;
     
    273307
    274308        if ($rcode < 200 || $rcode >= 300) {
    275             $this->handleApiError($rbody, $rcode, $rheaders, $resp);
     309            $this->handleErrorResponse($rbody, $rcode, $rheaders, $resp);
    276310        }
    277311        return $resp;
  • stripe/trunk/vendor/stripe/stripe-php/lib/ApiResource.php

    r1625278 r1725154  
    100100               . "method calls.  (HINT: an example call to create a charge "
    101101               . "would be: \"Stripe\\Charge::create(array('amount' => 100, "
    102                . "'currency' => 'usd', 'card' => array('number' => "
    103                . "4242424242424242, 'exp_month' => 5, 'exp_year' => 2015)))\")";
     102               . "'currency' => 'usd', 'source' => 'tok_1234'))\")";
    104103            throw new Error\Api($message);
    105104        }
  • stripe/trunk/vendor/stripe/stripe-php/lib/ApplePayDomain.php

    r1516951 r1725154  
    2121
    2222    /**
    23      * @param string $id The ID of the domain to retrieve.
     23     * @param array|string $id The ID of the domain to retrieve, or an options
     24     *     array containing an `id` key.
    2425     * @param array|string|null $opts
    2526     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/ApplicationFee.php

    r1463408 r1725154  
    2222
    2323    /**
    24      * @param string $id The ID of the application fee to retrieve.
     24     * @param array|string $id The ID of the application fee to retrieve, or an
     25     *     options array containing an `id` key.
    2526     * @param array|string|null $opts
    2627     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/AttachedObject.php

    r1463408 r1725154  
    22
    33namespace Stripe;
     4
     5use Countable;
    46
    57/**
     
    1012 * @package Stripe
    1113 */
    12 class AttachedObject extends StripeObject
     14class AttachedObject extends StripeObject implements Countable
    1315{
    1416    /**
     
    2931        }
    3032    }
     33
     34    /**
     35     * Counts the number of elements in the AttachedObject instance.
     36     *
     37     * @return int the number of elements
     38     */
     39    public function count()
     40    {
     41        return count($this->_values);
     42    }
    3143}
  • stripe/trunk/vendor/stripe/stripe-php/lib/BalanceTransaction.php

    r1463408 r1725154  
    3535
    3636    /**
    37      * @param string $id The ID of the balance transaction to retrieve.
     37     * @param array|string $id The ID of the balance transaction to retrieve,
     38     *     or an options array containing an `id` key.
    3839     * @param array|string|null $opts
    3940     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/BitcoinReceiver.php

    r1463408 r1725154  
    3838
    3939    /**
    40      * @param string $id The ID of the Bitcoin Receiver to retrieve.
     40     * @param array|string $id The ID of the bitcoin receiver to retrieve, or
     41     *     an options array containing an `id` key.
    4142     * @param array|string|null $opts
    4243     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Charge.php

    r1625278 r1725154  
    4242{
    4343    /**
    44      * @param string $id The ID of the charge to retrieve.
     44     * @param array|string $id The ID of the charge to retrieve, or an options
     45     *     array containing an `id` key.
    4546     * @param array|string|null $options
    4647     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Collection.php

    r1519517 r1725154  
    5757
    5858    /**
    59      * @return AutoPagingIterator An iterator that can be used to iterate
     59     * @return Util\AutoPagingIterator An iterator that can be used to iterate
    6060     *    across all objects across all pages. As page boundaries are
    6161     *    encountered, the next page will be fetched automatically for
  • stripe/trunk/vendor/stripe/stripe-php/lib/CountrySpec.php

    r1463408 r1725154  
    2222
    2323    /**
    24      * @param string $country The ISO country code of the country we retrieve the CountrySpec for.
     24     * @param array|string $country The ISO country code of the country we
     25     *     retrieve the country specfication for, or an options array
     26     *     containing an `id` containing that code.
    2527     * @param array|string|null $opts
    2628     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Coupon.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the coupon to retrieve.
     13     * @param array|string $id The ID of the coupon to retrieve, or an options
     14     *     array containing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Customer.php

    r1463408 r1725154  
    2828{
    2929    /**
    30      * @param string $id The ID of the customer to retrieve.
     30     * @param array|string $id The ID of the customer to retrieve, or an
     31     *     options array containing an `id` key.
    3132     * @param array|string|null $opts
    3233     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Dispute.php

    r1463408 r1725154  
    2626{
    2727    /**
    28      * @param string $id The ID of the dispute to retrieve.
     28     * @param array|string $id The ID of the dispute to retrieve, or an options
     29     *     array containing an `id` key.
    2930     * @param array|string|null $options
    3031     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Event.php

    r1463408 r1725154  
    2121{
    2222    /**
    23      * @param string $id The ID of the event to retrieve.
     23     * @param array|string $id The ID of the event to retrieve, or an options
     24     *     array containing an `id` key.
    2425     * @param array|string|null $opts
    2526     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/FileUpload.php

    r1463408 r1725154  
    2828
    2929    /**
    30      * @param string $id The ID of the file upload to retrieve.
     30     * @param array|string $id The ID of the file upload to retrieve, or an
     31     *     options array containing an `id key.
    3132     * @param array|string|null $opts
    3233     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/HttpClient/ClientInterface.php

    r1365533 r1725154  
    1212     * @param boolean $hasFile Whether or not $params references a file (via an @ prefix or
    1313     *                         CurlFile)
    14      * @throws Error\Api & Error\ApiConnection
     14     * @throws \Stripe\Error\Api & \Stripe\Error\ApiConnection
    1515     * @return array($rawBody, $httpStatusCode, $httpHeader)
    1616     */
  • stripe/trunk/vendor/stripe/stripe-php/lib/HttpClient/CurlClient.php

    r1516951 r1725154  
    3636
    3737    protected $defaultOptions;
     38
     39    protected $userAgentInfo;
    3840
    3941    /**
     
    5355    {
    5456        $this->defaultOptions = $defaultOptions;
     57        $this->initUserAgentInfo();
     58    }
     59
     60    public function initUserAgentInfo()
     61    {
     62        $curlVersion = curl_version();
     63        $this->userAgentInfo = array(
     64            'httplib' =>  'curl ' . $curlVersion['version'],
     65            'ssllib' => $curlVersion['ssl_version'],
     66        );
    5567    }
    5668
     
    5870    {
    5971        return $this->defaultOptions;
     72    }
     73
     74    public function getUserAgentInfo()
     75    {
     76        return $this->userAgentInfo;
    6077    }
    6178
     
    115132            $opts[CURLOPT_HTTPGET] = 1;
    116133            if (count($params) > 0) {
    117                 $encoded = self::encode($params);
     134                $encoded = Util\Util::urlEncode($params);
    118135                $absUrl = "$absUrl?$encoded";
    119136            }
    120137        } elseif ($method == 'post') {
    121138            $opts[CURLOPT_POST] = 1;
    122             $opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : self::encode($params);
     139            $opts[CURLOPT_POSTFIELDS] = $hasFile ? $params : Util\Util::urlEncode($params);
    123140        } elseif ($method == 'delete') {
    124141            $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
    125142            if (count($params) > 0) {
    126                 $encoded = self::encode($params);
     143                $encoded = Util\Util::urlEncode($params);
    127144                $absUrl = "$absUrl?$encoded";
    128145            }
     
    239256        return dirname(__FILE__) . '/../../data/ca-certificates.crt';
    240257    }
    241 
    242     /**
    243      * @param array $arr An map of param keys to values.
    244      * @param string|null $prefix
    245      *
    246      * Only public for testability, should not be called outside of CurlClient
    247      *
    248      * @return string A querystring, essentially.
    249      */
    250     public static function encode($arr, $prefix = null)
    251     {
    252         if (!is_array($arr)) {
    253             return $arr;
    254         }
    255 
    256         $r = array();
    257         foreach ($arr as $k => $v) {
    258             if (is_null($v)) {
    259                 continue;
    260             }
    261 
    262             if ($prefix) {
    263                 if ($k !== null && (!is_int($k) || is_array($v))) {
    264                     $k = $prefix."[".$k."]";
    265                 } else {
    266                     $k = $prefix."[]";
    267                 }
    268             }
    269 
    270             if (is_array($v)) {
    271                 $enc = self::encode($v, $k);
    272                 if ($enc) {
    273                     $r[] = $enc;
    274                 }
    275             } else {
    276                 $r[] = urlencode($k)."=".urlencode($v);
    277             }
    278         }
    279 
    280         return implode("&", $r);
    281     }
    282258}
  • stripe/trunk/vendor/stripe/stripe-php/lib/Invoice.php

    r1463408 r1725154  
    2222
    2323    /**
    24      * @param string $id The ID of the invoice to retrieve.
     24     * @param array|string $id The ID of the invoice to retrieve, or an options
     25     *     array containing an `id` key.
    2526     * @param array|string|null $opts
    2627     *
     
    8384     * @return Invoice The paid invoice.
    8485     */
    85     public function pay($opts = null)
     86    public function pay($params = null, $opts = null)
    8687    {
    8788        $url = $this->instanceUrl() . '/pay';
    88         list($response, $opts) = $this->_request('post', $url, null, $opts);
     89        list($response, $opts) = $this->_request('post', $url, $params, $opts);
    8990        $this->refreshFrom($response, $opts);
    9091        return $this;
  • stripe/trunk/vendor/stripe/stripe-php/lib/InvoiceItem.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the invoice item to retrieve.
     13     * @param array|string $id The ID of the invoice item to retrieve, or an
     14     *     options array containing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Order.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the Order to retrieve.
     13     * @param array|string $id The ID of the order to retrieve, or an options
     14     *     array containing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/OrderReturn.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the OrderReturn to retrieve.
     13     * This is a special case because the order returns endpoint has an
     14     *    underscore in it. The parent `className` function strips underscores.
     15     *
     16     * @return string The name of the class.
     17     */
     18    public static function className()
     19    {
     20        return 'order_return';
     21    }
     22
     23    /**
     24     * @param array|string $id The ID of the order return to retrieve, or an
     25     *     options array containing an `id` field.
    1426     * @param array|string|null $opts
    1527     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Plan.php

    r1519517 r1725154  
    2424{
    2525    /**
    26      * @param string $id The ID of the plan to retrieve.
     26     * @param array|string $id The ID of the plan to retrieve, or an options
     27     *     array containing an `id` key.
    2728     * @param array|string|null $opts
    2829     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Product.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the Product to retrieve.
     13     * @param array|string $id The ID of the product to retrieve, or an options
     14     *     array contianing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Recipient.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the recipient to retrieve.
     13     * @param array|string $id The ID of the recipient to retrieve, or an
     14     *     options array containing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Refund.php

    r1463408 r1725154  
    2424
    2525    /**
    26      * @param string $id The ID of the refund to retrieve.
     26     * @param array|string $id The ID of the refund to retrieve, or an options
     27     *     array containing an `id` key.
    2728     * @param array|string|null $options
    2829     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/SKU.php

    r1463408 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the SKU to retrieve.
     13     * @param array|string $id The ID of the SKU to retrieve, or an options
     14     *     array containing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Source.php

    r1625278 r1725154  
    1111{
    1212    /**
    13      * @param string $id The ID of the Source to retrieve.
     13     * @param array|string $id The ID of the source to retrieve, or an options
     14     *     array containing an `id` key.
    1415     * @param array|string|null $opts
    1516     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Stripe.php

    r1625278 r1725154  
    1313    public static $apiKey;
    1414
     15    // @var string The Stripe client_id to be used for Connect requests.
     16    public static $clientId;
     17
    1518    // @var string The base URL for the Stripe API.
    1619    public static $apiBase = 'https://api.stripe.com';
     20
     21    // @var string The base URL for the OAuth API.
     22    public static $connectBase = 'https://connect.stripe.com';
    1723
    1824    // @var string The base URL for the Stripe API uploads endpoint.
     
    3137    public static $appInfo = null;
    3238
    33     const VERSION = '4.5.1';
     39    // @var Util\LoggerInterface|null The logger to which the library will
     40    //   produce messages.
     41    public static $logger = null;
     42
     43    const VERSION = '5.2.0';
    3444
    3545    /**
     
    4252
    4353    /**
     54     * @return string The client_id used for Connect requests.
     55     */
     56    public static function getClientId()
     57    {
     58        return self::$clientId;
     59    }
     60
     61    /**
     62     * @return Util\LoggerInterface The logger to which the library will
     63     *   produce messages.
     64     */
     65    public static function getLogger()
     66    {
     67        if (self::$logger == null) {
     68            return new Util\DefaultLogger();
     69        }
     70        return self::$logger;
     71    }
     72
     73    /**
     74     * @param Util\LoggerInterface $logger The logger to which the library
     75     *   will produce messages.
     76     */
     77    public static function setLogger($logger)
     78    {
     79        self::$logger = $logger;
     80    }
     81
     82    /**
    4483     * Sets the API key to be used for requests.
    4584     *
     
    4988    {
    5089        self::$apiKey = $apiKey;
     90    }
     91
     92    /**
     93     * Sets the client_id to be used for Connect requests.
     94     *
     95     * @param string $clientId
     96     */
     97    public static function setClientId($clientId)
     98    {
     99        self::$clientId = $clientId;
    51100    }
    52101
  • stripe/trunk/vendor/stripe/stripe-php/lib/StripeObject.php

    r1625278 r1725154  
    2828        self::$permanentAttributes = new Util\Set(array('_opts', 'id'));
    2929        self::$nestedUpdatableAttributes = new Util\Set(array(
    30             'metadata', 'legal_entity', 'address', 'dob', 'transfer_schedule', 'verification',
    31             'tos_acceptance', 'personal_address',
     30            'metadata', 'legal_entity', 'address', 'dob', 'payout_schedule', 'transfer_schedule', 'verification',
     31            'tos_acceptance', 'personal_address', 'address_kana', 'address_kanji',
    3232            // will make the array into an AttachedObject: weird, but works for now
    3333            'additional_owners', 0, 1, 2, 3, 4, // Max 3, but leave the 4th so errors work properly
     
    132132                    . "probably as a result of a save(). The attributes currently "
    133133                    . "available on this object are: $attrs";
    134             error_log($message);
     134            Stripe::getLogger()->error($message);
    135135            return $nullval;
    136136        } else {
    137137            $class = get_class($this);
    138             error_log("Stripe Notice: Undefined property of $class instance: $k");
     138            Stripe::getLogger()->error("Stripe Notice: Undefined property of $class instance: $k");
    139139            return $nullval;
    140140        }
  • stripe/trunk/vendor/stripe/stripe-php/lib/Subscription.php

    r1463408 r1725154  
    2222
    2323    /**
    24      * @param string $id The ID of the subscription to retrieve.
     24     * @param array|string $id The ID of the subscription to retrieve, or an
     25     *     options array containing an `id` key.
    2526     * @param array|string|null $opts
    2627     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/SubscriptionItem.php

    r1516951 r1725154  
    2222
    2323    /**
    24      * @param string $id The ID of the subscription item to retrieve.
     24     * @param array|string $id The ID of the subscription item to retrieve, or
     25     *     an options array containing an `id` key.
    2526     * @param array|string|null $opts
    2627     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/ThreeDSecure.php

    r1549989 r1725154  
    1414
    1515    /**
    16      * @param string $id The ID of the 3DS auth to retrieve.
     16     * @param array|string $id The ID of the 3DS auth to retrieve, or an
     17     *     options array contianing an `id` key.
    1718     * @param array|string|null $options
    1819     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Token.php

    r1463408 r1725154  
    2121{
    2222    /**
    23      * @param string $id The ID of the token to retrieve.
     23     * @param array|string $id The ID of the token to retrieve, or an options
     24     *     array containing an `id` key.
    2425     * @param array|string|null $opts
    2526     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Transfer.php

    r1463408 r1725154  
    1010 * @property int $amount
    1111 * @property int $amount_reversed
    12  * @property mixed $application_fee
    1312 * @property string $balance_transaction
    1413 * @property int $created
    1514 * @property string $currency
    1615 * @property int $date
    17  * @property mixed $description
    1816 * @property mixed $destination
    1917 * @property mixed $destination_payment
    20  * @property mixed $failure_code
    21  * @property mixed $failure_message
    22  * @property mixed $fraud_details
    23  * @property mixed $invoice
    2418 * @property bool $livemode
    2519 * @property mixed $metadata
    26  * @property mixed $recipient
    2720 * @property mixed $reversals
    2821 * @property bool $reversed
    2922 * @property mixed $source_transaction
    30  * @property string $source_type
    31  * @property mixed $statement_descriptor
    32  * @property string $status
    33  * @property string $type
    3423 *
    3524 * @package Stripe
     
    3827{
    3928    /**
    40      * @param string $id The ID of the transfer to retrieve.
     29     * @param array|string $id The ID of the transfer to retrieve, or an
     30     *     options array containing an `id` key.
    4131     * @param array|string|null $opts
    4232     *
  • stripe/trunk/vendor/stripe/stripe-php/lib/Util/Util.php

    r1519517 r1725154  
    88{
    99    private static $isMbstringAvailable = null;
     10    private static $isHashEqualsAvailable = null;
    1011
    1112    /**
     
    7677            'customer' => 'Stripe\\Customer',
    7778            'dispute' => 'Stripe\\Dispute',
     79            'ephemeral_key' => 'Stripe\\EphemeralKey',
    7880            'list' => 'Stripe\\Collection',
     81            'login_link' => 'Stripe\\LoginLink',
    7982            'invoice' => 'Stripe\\Invoice',
    8083            'invoiceitem' => 'Stripe\\InvoiceItem',
     
    8689            'order' => 'Stripe\\Order',
    8790            'order_return' => 'Stripe\\OrderReturn',
     91            'payout' => 'Stripe\\Payout',
    8892            'plan' => 'Stripe\\Plan',
    8993            'product' => 'Stripe\\Product',
    9094            'recipient' => 'Stripe\\Recipient',
     95            'recipient_transfer' => 'Stripe\\RecipientTransfer',
    9196            'refund' => 'Stripe\\Refund',
    9297            'sku' => 'Stripe\\SKU',
     
    142147        }
    143148    }
     149
     150    /**
     151     * Compares two strings for equality. The time taken is independent of the
     152     * number of characters that match.
     153     *
     154     * @param string $a one of the strings to compare.
     155     * @param string $b the other string to compare.
     156     * @return bool true if the strings are equal, false otherwise.
     157     */
     158    public static function secureCompare($a, $b)
     159    {
     160        if (self::$isHashEqualsAvailable === null) {
     161            self::$isHashEqualsAvailable = function_exists('hash_equals');
     162        }
     163
     164        if (self::$isHashEqualsAvailable) {
     165            return hash_equals($a, $b);
     166        } else {
     167            if (strlen($a) != strlen($b)) {
     168                return false;
     169            }
     170
     171            $result = 0;
     172            for ($i = 0; $i < strlen($a); $i++) {
     173                $result |= ord($a[$i]) ^ ord($b[$i]);
     174            }
     175            return ($result == 0);
     176        }
     177    }
     178
     179    /**
     180     * @param array $arr A map of param keys to values.
     181     * @param string|null $prefix
     182     *
     183     * @return string A querystring, essentially.
     184     */
     185    public static function urlEncode($arr, $prefix = null)
     186    {
     187        if (!is_array($arr)) {
     188            return $arr;
     189        }
     190
     191        $r = array();
     192        foreach ($arr as $k => $v) {
     193            if (is_null($v)) {
     194                continue;
     195            }
     196
     197            if ($prefix) {
     198                if ($k !== null && (!is_int($k) || is_array($v))) {
     199                    $k = $prefix."[".$k."]";
     200                } else {
     201                    $k = $prefix."[]";
     202                }
     203            }
     204
     205            if (is_array($v)) {
     206                $enc = self::urlEncode($v, $k);
     207                if ($enc) {
     208                    $r[] = $enc;
     209                }
     210            } else {
     211                $r[] = urlencode($k)."=".urlencode($v);
     212            }
     213        }
     214
     215        return implode("&", $r);
     216    }
    144217}
  • stripe/trunk/vendor/stripe/stripe-php/tests/AccountTest.php

    r1463408 r1725154  
    296296        $account->legal_entity->additional_owners[1] = array('first_name' => 'Jane');
    297297        $account->save();
     298        $this->assertSame(2, count($account->legal_entity->additional_owners));
    298299        $this->assertSame('Jane', $account->legal_entity->additional_owners[1]->first_name);
    299300    }
     301
     302    public function testLoginLinkCreation()
     303    {
     304        $accountId = 'acct_EXPRESS';
     305        $mockExpress = array(
     306            'id' => $accountId,
     307            'object' => 'account',
     308            'login_links' => array(
     309                'object' => 'list',
     310                'data' => array(),
     311                'has_more' => false,
     312                'url' =>  "/v1/accounts/$accountId/login_links"
     313            )
     314        );
     315
     316        $this->mockRequest('GET', "/v1/accounts/$accountId", array(), $mockExpress);
     317
     318        $mockLoginLink = array(
     319            'object' => 'login_link',
     320            'created' => 1493820886,
     321            'url' => "https://connect.stripe.com/$accountId/AAAAAAAA"
     322        );
     323
     324        $this->mockRequest('POST', "/v1/accounts/$accountId/login_links", array(), $mockLoginLink);
     325
     326        $account = Account::retrieve($accountId);
     327        $loginLink = $account->login_links->create();
     328        $this->assertSame('login_link', $loginLink->object);
     329        $this->assertSame('Stripe\LoginLink', get_class($loginLink));
     330    }
     331
     332    public function testDeauthorize()
     333    {
     334        Stripe::setClientId('ca_test');
     335
     336        $accountId = 'acct_test_deauth';
     337        $mockAccount = array(
     338            'id' => $accountId,
     339            'object' => 'account',
     340        );
     341
     342        $this->mockRequest('GET', "/v1/accounts/$accountId", array(), $mockAccount);
     343
     344        $this->mockRequest(
     345            'POST',
     346            '/oauth/deauthorize',
     347            array(
     348                'client_id' => 'ca_test',
     349                'stripe_user_id' => $accountId,
     350            ),
     351            array(
     352                'stripe_user_id' => $accountId,
     353            ),
     354            200,
     355            Stripe::$connectBase
     356        );
     357
     358        $account = Account::retrieve($accountId);
     359        $account->deauthorize();
     360
     361        Stripe::setClientId(null);
     362    }
    300363}
  • stripe/trunk/vendor/stripe/stripe-php/tests/ApiRequestorTest.php

    r1495935 r1725154  
    5151        Stripe::setAppInfo('MyTestApp', '1.2.34', 'https://mytestapp.example');
    5252        $apiKey = 'sk_test_notarealkey';
    53 
    54         $headers = $method->invoke(null, $apiKey);
     53        $clientInfo = array('httplib' => 'testlib 0.1.2');
     54
     55        $headers = $method->invoke(null, $apiKey, $clientInfo);
    5556
    5657        $ua = json_decode($headers['X-Stripe-Client-User-Agent']);
     
    5960        $this->assertSame($ua->application->url, 'https://mytestapp.example');
    6061
     62        $this->assertSame($ua->httplib, 'testlib 0.1.2');
     63
    6164        $this->assertSame(
    6265            $headers['User-Agent'],
     
    6669        $this->assertSame($headers['Authorization'], 'Bearer ' . $apiKey);
    6770    }
     71
     72    public function testErrorInvalidRequest()
     73    {
     74        $this->mockRequest(
     75            'POST',
     76            '/v1/charges',
     77            array(),
     78            array(
     79                'error' => array(
     80                    'type' => 'invalid_request_error',
     81                    'message' => 'Missing id',
     82                    'param' => 'id',
     83                ),
     84            ),
     85            400
     86        );
     87
     88        try {
     89            Charge::create();
     90            $this->fail("Did not raise error");
     91        } catch (Error\InvalidRequest $e) {
     92            $this->assertSame('Missing id', $e->getMessage());
     93            $this->assertSame('id', $e->getStripeParam());
     94        } catch (\Exception $e) {
     95            $this->fail("Unexpected exception: " . get_class($e));
     96        }
     97    }
     98
     99    public function testErrorAuthentication()
     100    {
     101        $this->mockRequest(
     102            'POST',
     103            '/v1/charges',
     104            array(),
     105            array(
     106                'error' => array(
     107                    'type' => 'invalid_request_error',
     108                    'message' => 'You did not provide an API key.',
     109                ),
     110            ),
     111            401
     112        );
     113
     114        try {
     115            Charge::create();
     116            $this->fail("Did not raise error");
     117        } catch (Error\Authentication $e) {
     118            $this->assertSame('You did not provide an API key.', $e->getMessage());
     119        } catch (\Exception $e) {
     120            $this->fail("Unexpected exception: " . get_class($e));
     121        }
     122    }
     123
     124    public function testErrorCard()
     125    {
     126        $this->mockRequest(
     127            'POST',
     128            '/v1/charges',
     129            array(),
     130            array(
     131                'error' => array(
     132                    'type' => 'card_error',
     133                    'message' => 'Your card was declined.',
     134                    'code' => 'card_declined',
     135                    'decline_code' => 'generic_decline',
     136                    'charge' => 'ch_declined_charge',
     137                ),
     138            ),
     139            402
     140        );
     141
     142        try {
     143            Charge::create();
     144            $this->fail("Did not raise error");
     145        } catch (Error\Card $e) {
     146            $this->assertSame('Your card was declined.', $e->getMessage());
     147            $this->assertSame('card_declined', $e->getStripeCode());
     148            $this->assertSame('generic_decline', $e->getDeclineCode());
     149        } catch (\Exception $e) {
     150            $this->fail("Unexpected exception: " . get_class($e));
     151        }
     152    }
     153
     154    public function testErrorOAuthInvalidRequest()
     155    {
     156        $this->mockRequest(
     157            'POST',
     158            '/oauth/token',
     159            array(),
     160            array(
     161                'error' => 'invalid_request',
     162                'error_description' => 'No grant type specified',
     163            ),
     164            400,
     165            Stripe::$connectBase
     166        );
     167
     168        try {
     169            OAuth::token();
     170            $this->fail("Did not raise error");
     171        } catch (Error\OAuth\InvalidRequest $e) {
     172            $this->assertSame('invalid_request', $e->getErrorCode());
     173            $this->assertSame('No grant type specified', $e->getMessage());
     174        } catch (\Exception $e) {
     175            $this->fail("Unexpected exception: " . get_class($e));
     176        }
     177    }
     178
     179    public function testErrorOAuthInvalidClient()
     180    {
     181        $this->mockRequest(
     182            'POST',
     183            '/oauth/token',
     184            array(),
     185            array(
     186                'error' => 'invalid_client',
     187                'error_description' => 'No authentication was provided. Send your secret API key using the Authorization header, or as a client_secret POST parameter.',
     188            ),
     189            401,
     190            Stripe::$connectBase
     191        );
     192
     193        try {
     194            OAuth::token();
     195            $this->fail("Did not raise error");
     196        } catch (Error\OAuth\InvalidClient $e) {
     197            $this->assertSame('invalid_client', $e->getErrorCode());
     198            $this->assertSame('No authentication was provided. Send your secret API key using the Authorization header, or as a client_secret POST parameter.', $e->getMessage());
     199        } catch (\Exception $e) {
     200            $this->fail("Unexpected exception: " . get_class($e));
     201        }
     202    }
     203
     204    public function testErrorOAuthInvalidGrant()
     205    {
     206        $this->mockRequest(
     207            'POST',
     208            '/oauth/token',
     209            array(),
     210            array(
     211                'error' => 'invalid_grant',
     212                'error_description' => 'This authorization code has already been used. All tokens issued with this code have been revoked.',
     213            ),
     214            400,
     215            Stripe::$connectBase
     216        );
     217
     218        try {
     219            OAuth::token();
     220            $this->fail("Did not raise error");
     221        } catch (Error\OAuth\InvalidGrant $e) {
     222            $this->assertSame('invalid_grant', $e->getErrorCode());
     223            $this->assertSame('This authorization code has already been used. All tokens issued with this code have been revoked.', $e->getMessage());
     224        } catch (\Exception $e) {
     225            $this->fail("Unexpected exception: " . get_class($e));
     226        }
     227    }
    68228}
  • stripe/trunk/vendor/stripe/stripe-php/tests/CardErrorTest.php

    r1625278 r1725154  
    99        self::authorizeFromEnv();
    1010
    11         $card = array(
    12             'number' => '4000000000000002',
    13             'exp_month' => '3',
    14             'exp_year' => '2020'
    15         );
    16 
    1711        $charge = array(
    1812            'amount' => 100,
    1913            'currency' => 'usd',
    20             'card' => $card
     14            'source' => 'tok_chargeDeclined'
    2115        );
    2216
  • stripe/trunk/vendor/stripe/stripe-php/tests/ChargeTest.php

    r1365533 r1725154  
    1616        self::authorizeFromEnv();
    1717
    18         $card = array(
    19             'number' => '4242424242424242',
    20             'exp_month' => 5,
    21             'exp_year' => date('Y') + 1
    22         );
    23 
    2418        $c = Charge::create(
    2519            array(
    2620                'amount' => 100,
    2721                'currency' => 'usd',
    28                 'card' => $card
     22                'card' => 'tok_visa'
    2923            )
    3024        );
     
    3731        self::authorizeFromEnv();
    3832
    39         $card = array(
    40             'number' => '4242424242424242',
    41             'exp_month' => 5,
    42             'exp_year' => date('Y') + 1
    43         );
    44 
    4533        $c = Charge::create(
    4634            array(
    4735                'amount' => 100,
    4836                'currency' => 'usd',
    49                 'card' => $card
     37                'card' => 'tok_visa'
    5038            ),
    5139            array(
     
    6250        self::authorizeFromEnv();
    6351
    64         $card = array(
    65             'number' => '4242424242424242',
    66             'exp_month' => 5,
    67             'exp_year' => date('Y') + 1
    68         );
    69 
    7052        $c = Charge::create(
    7153            array(
    7254                'amount' => 100,
    7355                'currency' => 'usd',
    74                 'card' => $card
     56                'card' => 'tok_visa'
    7557            )
    7658        );
     
    8466        self::authorizeFromEnv();
    8567
    86         $card = array(
    87             'number' => '4242424242424242',
    88             'exp_month' => 5,
    89             'exp_year' => date('Y') + 1
    90         );
    91 
    9268        $charge = Charge::create(
    9369            array(
    9470                'amount' => 100,
    9571                'currency' => 'usd',
    96                 'card' => $card
     72                'card' => 'tok_visa'
    9773            )
    9874        );
     
    10985        self::authorizeFromEnv();
    11086
    111         $card = array(
    112             'number' => '4242424242424242',
    113             'exp_month' => 5,
    114             'exp_year' => date('Y') + 1
    115         );
    116 
    11787        $charge = Charge::create(
    11888            array(
    11989                'amount' => 100,
    12090                'currency' => 'usd',
    121                 'card' => $card
     91                'card' => 'tok_visa'
    12292            )
    12393        );
     
    135105        self::authorizeFromEnv();
    136106
    137         $card = array(
    138             'number' => '4242424242424242',
    139             'exp_month' => 5,
    140             'exp_year' => date('Y') + 1
    141         );
    142 
    143107        $charge = Charge::create(
    144108            array(
    145109                'amount' => 100,
    146110                'currency' => 'usd',
    147                 'card' => $card
     111                'card' => 'tok_visa'
    148112            )
    149113        );
     
    183147        self::authorizeFromEnv();
    184148
    185         $card = array(
    186             'number' => '4242424242424242',
    187             'exp_month' => 5,
    188             'exp_year' => date('Y') + 1
    189         );
    190 
    191149        $charge = Charge::create(
    192150            array(
    193151                'amount' => 100,
    194152                'currency' => 'usd',
    195                 'card' => $card
     153                'card' => 'tok_visa'
    196154            )
    197155        );
  • stripe/trunk/vendor/stripe/stripe-php/tests/CurlClientTest.php

    r1516951 r1725154  
    2222        $this->assertSame(0, $curl->getTimeout());
    2323        $this->assertSame(0, $curl->getConnectTimeout());
     24    }
     25
     26    public function testUserAgentInfo()
     27    {
     28        $curl = new CurlClient();
     29        $uaInfo = $curl->getUserAgentInfo();
     30        $this->assertNotNull($uaInfo);
     31        $this->assertNotNull($uaInfo['httplib']);
     32        $this->assertNotNull($uaInfo['ssllib']);
    2433    }
    2534
     
    4958    }
    5059
    51     public function testEncode()
    52     {
    53         $a = array(
    54             'my' => 'value',
    55             'that' => array('your' => 'example'),
    56             'bar' => 1,
    57             'baz' => null
    58         );
    59 
    60         $enc = CurlClient::encode($a);
    61         $this->assertSame('my=value&that%5Byour%5D=example&bar=1', $enc);
    62 
    63         $a = array('that' => array('your' => 'example', 'foo' => null));
    64         $enc = CurlClient::encode($a);
    65         $this->assertSame('that%5Byour%5D=example', $enc);
    66 
    67         $a = array('that' => 'example', 'foo' => array('bar', 'baz'));
    68         $enc = CurlClient::encode($a);
    69         $this->assertSame('that=example&foo%5B%5D=bar&foo%5B%5D=baz', $enc);
    70 
    71         $a = array(
    72             'my' => 'value',
    73             'that' => array('your' => array('cheese', 'whiz', null)),
    74             'bar' => 1,
    75             'baz' => null
    76         );
    77 
    78         $enc = CurlClient::encode($a);
    79         $expected = 'my=value&that%5Byour%5D%5B%5D=cheese'
    80               . '&that%5Byour%5D%5B%5D=whiz&bar=1';
    81         $this->assertSame($expected, $enc);
    82 
    83         // Ignores an empty array
    84         $enc = CurlClient::encode(array('foo' => array(), 'bar' => 'baz'));
    85         $expected = 'bar=baz';
    86         $this->assertSame($expected, $enc);
    87 
    88         $a = array('foo' => array(array('bar' => 'baz'), array('bar' => 'bin')));
    89         $enc = CurlClient::encode($a);
    90         $this->assertSame('foo%5B0%5D%5Bbar%5D=baz&foo%5B1%5D%5Bbar%5D=bin', $enc);
    91     }
    92 
    9360    public function testSslOption()
    9461    {
  • stripe/trunk/vendor/stripe/stripe-php/tests/CustomerTest.php

    r1463408 r1725154  
    6969        $customer = self::createTestCustomer();
    7070
    71         $customer->metadata['test'] = 'foo bar';
    72         $customer->save();
    73 
    74         $updatedCustomer = Customer::retrieve($customer->id);
    75         $this->assertSame('foo bar', $updatedCustomer->metadata['test']);
     71        $customer->metadata['test1'] = 'foo';
     72        $customer->metadata['test2'] = 'bar';
     73        $customer->save();
     74
     75        $updatedCustomer = Customer::retrieve($customer->id);
     76        $this->assertSame(2, count($updatedCustomer->metadata));
     77        $this->assertSame('foo', $updatedCustomer->metadata['test1']);
     78        $this->assertSame('bar', $updatedCustomer->metadata['test2']);
    7679    }
    7780
     
    8487
    8588        $updatedCustomer = Customer::retrieve($customer->id);
    86         $this->assertSame(0, count($updatedCustomer->metadata->keys()));
     89        $this->assertSame(0, count($updatedCustomer->metadata));
    8790    }
    8891
     
    147150    public function testCustomerAddCard()
    148151    {
    149         $token = Token::create(
    150             array("card" => array(
    151                 "number" => "4242424242424242",
    152                 "exp_month" => 5,
    153                 "exp_year" => date('Y') + 3,
    154                 "cvc" => "314"
    155             ))
    156         );
    157 
    158         $customer = $this->createTestCustomer();
    159         $createdCard = $customer->sources->create(array("card" => $token->id));
     152        $customer = $this->createTestCustomer();
     153        $createdCard = $customer->sources->create(array("card" => 'tok_visa'));
    160154        $customer->save();
    161155
     
    184178    public function testCustomerDeleteCard()
    185179    {
    186         $token = Token::create(
    187             array("card" => array(
    188                 "number" => "4242424242424242",
    189                 "exp_month" => 5,
    190                 "exp_year" => date('Y') + 3,
    191                 "cvc" => "314"
    192             ))
    193         );
    194 
    195         $customer = $this->createTestCustomer();
    196         $createdCard = $customer->sources->create(array("card" => $token->id));
     180        $customer = $this->createTestCustomer();
     181        $createdCard = $customer->sources->create(array("card" => 'tok_visa'));
    197182        $customer->save();
    198183
     
    213198    {
    214199        self::authorizeFromEnv();
    215         $token = Token::create(
    216             array("card" => array(
    217                 "number" => "4242424242424242",
    218                 "exp_month" => 5,
    219                 "exp_year" => date('Y') + 3,
    220                 "cvc" => "314"
    221             ))
    222         );
    223 
    224         $customer = $this->createTestCustomer();
    225         $createdSource = $customer->sources->create(array("source" => $token->id));
     200
     201        $customer = $this->createTestCustomer();
     202        $createdSource = $customer->sources->create(array("source" => 'tok_visa'));
    226203        $customer->save();
    227204
     
    251228    {
    252229        self::authorizeFromEnv();
    253         $token = Token::create(
    254             array("card" => array(
    255                 "number" => "4242424242424242",
    256                 "exp_month" => 5,
    257                 "exp_year" => date('Y') + 3,
    258                 "cvc" => "314"
    259             ))
    260         );
    261 
    262         $customer = $this->createTestCustomer();
    263         $createdSource = $customer->sources->create(array("source" => $token->id));
     230
     231        $customer = $this->createTestCustomer();
     232        $createdSource = $customer->sources->create(array("source" => 'tok_visa'));
    264233        $customer->save();
    265234
  • stripe/trunk/vendor/stripe/stripe-php/tests/DisputeTest.php

    r1625278 r1725154  
    1414    private function createDisputedCharge()
    1515    {
    16         $card = array(
    17             'number' => '4000000000000259',
    18             'exp_month' => 5,
    19             'exp_year' => date('Y') + 1
    20         );
    21 
    2216        $c = Charge::create(
    2317            array(
    2418                'amount' => 100,
    2519                'currency' => 'usd',
    26                 'card' => $card
     20                'source' => 'tok_createDispute'
    2721            )
    2822        );
  • stripe/trunk/vendor/stripe/stripe-php/tests/InvoiceTest.php

    r1625278 r1725154  
    5454        $this->assertGreaterThan(0, count($invoices));
    5555    }
     56
     57    public function testPay()
     58    {
     59        $response = array(
     60            'id' => 'in_foo',
     61            'object' => 'invoice',
     62            'paid' => false,
     63        );
     64        $this->mockRequest(
     65            'GET',
     66            '/v1/invoices/in_foo',
     67            array(),
     68            $response
     69        );
     70
     71        $response['paid'] = true;
     72        $this->mockRequest(
     73            'POST',
     74            '/v1/invoices/in_foo/pay',
     75            array('source' => 'src_bar'),
     76            $response
     77        );
     78
     79        $invoice = Invoice::retrieve('in_foo');
     80        $invoice->pay(array('source' => 'src_bar'));
     81        $this->assertTrue($invoice->paid);
     82    }
    5683}
  • stripe/trunk/vendor/stripe/stripe-php/tests/ProductTest.php

    r1439283 r1725154  
    143143        $this->assertSame($order->metadata->foo, "bar");
    144144
    145         $order->pay(array(
    146             'source' => array(
    147                 'object' => 'card',
    148                 'number' => '4242424242424242',
    149                 'exp_month' => '05',
    150                 'exp_year' => '2017'
    151             ),
    152         ));
     145        $order->pay(array('source' => 'tok_visa'));
    153146        $this->assertSame($order->status, 'paid');
    154147
  • stripe/trunk/vendor/stripe/stripe-php/tests/RecipientTest.php

    r1365533 r1725154  
    3737    public function testRecipientAddCard()
    3838    {
    39         $token = Token::create(
    40             array("card" => array(
    41                 "number" => "4000056655665556",
    42                 "exp_month" => 5,
    43                 "exp_year" => date('Y') + 3,
    44                 "cvc" => "314"
    45             ))
    46         );
    47 
    4839        $recipient = $this->createTestRecipient();
    49         $createdCard = $recipient->cards->create(array("card" => $token->id));
     40        $createdCard = $recipient->cards->create(array("card" => 'tok_visa_debit'));
    5041        $recipient->save();
    5142
     
    5748    public function testRecipientUpdateCard()
    5849    {
    59         $token = Token::create(
    60             array("card" => array(
    61                 "number" => "4000056655665556",
    62                 "exp_month" => 5,
    63                 "exp_year" => date('Y') + 3,
    64                 "cvc" => "314"
    65             ))
    66         );
    67 
    6850        $recipient = $this->createTestRecipient();
    69         $createdCard = $recipient->cards->create(array("card" => $token->id));
     51        $createdCard = $recipient->cards->create(array("card" => 'tok_visa_debit'));
    7052        $recipient->save();
    7153
     
    8466    public function testRecipientDeleteCard()
    8567    {
    86         $token = Token::create(
    87             array("card" => array(
    88                 "number" => "4000056655665556",
    89                 "exp_month" => 5,
    90                 "exp_year" => date('Y') + 3,
    91                 "cvc" => "314"
    92             ))
    93         );
    94 
    9568        $recipient = $this->createTestRecipient();
    96         $createdCard = $recipient->cards->create(array("card" => $token->id));
     69        $createdCard = $recipient->cards->create(array("card" => 'tok_visa_debit'));
    9770        $recipient->save();
    9871
  • stripe/trunk/vendor/stripe/stripe-php/tests/TestCase.php

    r1365533 r1725154  
    2626    {
    2727        ApiRequestor::setHttpClient(HttpClient\CurlClient::instance());
     28
     29        // Peg the API version so that it can be varied independently of the
     30        // one set on the test account.
     31        Stripe::setApiVersion('2017-04-06');
     32
    2833        $this->mock = null;
    2934        $this->call = 0;
    3035    }
    3136
    32     protected function mockRequest($method, $path, $params = array(), $return = array('id' => 'myId'), $rcode = 200)
     37    protected function mockRequest($method, $path, $params = array(), $return = array('id' => 'myId'), $rcode = 200, $base = 'https://api.stripe.com')
    3338    {
    3439        $mock = $this->setUpMockRequest();
    3540        $mock->expects($this->at($this->call++))
    3641             ->method('request')
    37              ->with(strtolower($method), 'https://api.stripe.com' . $path, $this->anything(), $params, false)
     42             ->with(strtolower($method), $base . $path, $this->anything(), $params, false)
    3843             ->willReturn(array(json_encode($return), $rcode, array()));
    3944    }
     
    6166                'currency' => 'usd',
    6267                'description' => 'Charge for test@example.com',
    63                 'card' => array(
    64                     'number' => '4242424242424242',
    65                     'exp_month' => 5,
    66                     'exp_year' => date('Y') + 3,
    67                 ),
    68             )
    69         );
    70     }
    71 
    72     /**
    73      * Create a valid test charge.
    74      */
    75     protected static function createTestTransfer(array $attributes = array())
     68                'card' => 'tok_visa',
     69            )
     70        );
     71    }
     72
     73    /**
     74     * Create a valid test transfer.
     75     */
     76    protected static function createTestTransfer(array $attributes = array(), $opts = null)
    7677    {
    7778        self::authorizeFromEnv();
     
    8586                'description' => 'Transfer to test@example.com',
    8687                'recipient' => $recipient->id
    87             )
     88            ),
     89            $opts
    8890        );
    8991    }
     
    98100        return Customer::create(
    99101            $attributes + array(
    100                 'card' => array(
    101                     'number' => '4242424242424242',
    102                     'exp_month' => 5,
    103                     'exp_year' => date('Y') + 3,
    104                 ),
     102                'card' => 'tok_visa',
    105103            )
    106104        );
     
    120118                'tax_id' => '000000000',
    121119                'bank_account' => array(
    122                     'country'    => 'US',
     120                    'country' => 'US',
    123121                    'routing_number' => '110000000',
    124                     'account_number'  => '000123456789'
     122                    'account_number' => '000123456789'
    125123                ),
    126124            )
     
    140138                'country' => 'US',
    141139                'email' => self::generateRandomEmail(),
     140            )
     141        );
     142    }
     143
     144    /**
     145     * Create a test account
     146     */
     147    protected static function createTestManagedAccount(array $attributes = array())
     148    {
     149        self::authorizeFromEnv();
     150
     151        return Account::create(
     152            $attributes + array(
     153                'managed' => true,
     154                'country' => 'US',
     155                'external_account' => array(
     156                    'object' => 'bank_account',
     157                    'country' => 'US',
     158                    'currency' => 'usd',
     159                    'routing_number' => '110000000',
     160                    'account_number' => '000123456789'
     161                ),
     162                'legal_entity' => array(
     163                    'type'               => 'individual',
     164                    'personal_id_number' => '000000000',
     165                    'type'               => 'individual',
     166                    'dob'                => array('year' => '1980', 'month' => '01', 'day' => '01'),
     167                    'first_name'         => 'John',
     168                    'last_name'          => 'Doe',
     169                    'address'            => array(
     170                        'line1'          => '1234 Main Street',
     171                        'postal_code'    => '94110',
     172                        'city'           => 'San Francisco'
     173                    ),
     174                    'personal_address'   => array(
     175                        'line1'          => '1234 Main Street',
     176                        'postal_code'    => '94110',
     177                        'city'           => 'San Francisco'
     178                    )
     179                ),
     180                'tos_acceptance' => array('date' => time(), 'ip' => '127.0.0.1')
    142181            )
    143182        );
     
    189228
    190229    /**
    191      * Genereate a semi-random string
     230     * Generate a semi-random string
    192231     */
    193232    protected static function generateRandomString($length = 24)
     
    205244     * Generate a semi-random email.
    206245     */
    207     protected static function generateRandomEmail($domain = 'bar.com')
    208     {
    209         return self::generateRandomString().'@'.$domain;
     246    protected static function generateRandomEmail()
     247    {
     248        return 'dev-platform-bots+php-'.self::generateRandomString(12).'@stripe.com';
    210249    }
    211250
  • stripe/trunk/vendor/stripe/stripe-php/tests/TransferReversalTest.php

    r1365533 r1725154  
    55class TransferReversalTest extends TestCase
    66{
     7    // The resource that was traditionally called "transfer" became a "payout"
     8    // in API version 2017-04-06. We're testing traditional transfers here, so
     9    // we force the API version just prior anywhere that we need to.
     10    private $opts = array('stripe_version' => '2017-02-14');
    711
    812    public function testList()
    913    {
    10         $transfer = self::createTestTransfer();
     14        $transfer = self::createTestTransfer(array(), $this->opts);
    1115        $all = $transfer->reversals->all();
    1216        $this->assertSame(false, $all['has_more']);
  • stripe/trunk/vendor/stripe/stripe-php/tests/TransferTest.php

    r1365533 r1725154  
    55class TransferTest extends TestCase
    66{
     7    // The resource that was traditionally called "transfer" became a "payout"
     8    // in API version 2017-04-06. We're testing traditional transfers here, so
     9    // we force the API version just prior anywhere that we need to.
     10    private $opts = array('stripe_version' => '2017-02-14');
     11
    712    public function testCreate()
    813    {
    9         $recipient = self::createTestRecipient();
    10 
    11         self::authorizeFromEnv();
    12         $transfer = Transfer::create(array(
    13             'amount' => 100,
    14             'currency' => 'usd',
    15             'recipient' => $recipient->id
    16         ));
    17         $this->assertSame('pending', $transfer->status);
     14        $transfer = self::createTestTransfer(array(), $this->opts);
     15        $this->assertSame('transfer', $transfer->object);
    1816    }
    1917
    2018    public function testRetrieve()
    2119    {
    22         $recipient = self::createTestRecipient();
    23 
    24         self::authorizeFromEnv();
    25         $transfer = Transfer::create(array(
    26             'amount' => 100,
    27             'currency' => 'usd',
    28             'recipient' => $recipient->id
    29         ));
    30         $reloaded = Transfer::retrieve($transfer->id);
     20        $transfer = self::createTestTransfer(array(), $this->opts);
     21        $reloaded = Transfer::retrieve($transfer->id, $this->opts);
    3122        $this->assertSame($reloaded->id, $transfer->id);
    32     }
    33 
    34     /**
    35      * @expectedException Stripe\Error\InvalidRequest
    36      */
    37     public function testCancel()
    38     {
    39         $recipient = self::createTestRecipient();
    40 
    41         self::authorizeFromEnv();
    42         $transfer = Transfer::create(array(
    43             'amount' => 100,
    44             'currency' => 'usd',
    45             'recipient' => $recipient->id
    46         ));
    47         $reloaded = Transfer::retrieve($transfer->id);
    48         $this->assertSame($reloaded->id, $transfer->id);
    49 
    50         $reloaded->cancel();
    5123    }
    5224
    5325    public function testTransferUpdateMetadata()
    5426    {
    55         $recipient = self::createTestRecipient();
    56 
    57         self::authorizeFromEnv();
    58         $transfer = Transfer::create(array(
    59             'amount' => 100,
    60             'currency' => 'usd',
    61             'recipient' => $recipient->id
    62         ));
     27        $transfer = self::createTestTransfer(array(), $this->opts);
    6328
    6429        $transfer->metadata['test'] = 'foo bar';
    6530        $transfer->save();
    6631
    67         $updatedTransfer = Transfer::retrieve($transfer->id);
     32        $updatedTransfer = Transfer::retrieve($transfer->id, $this->opts);
    6833        $this->assertSame('foo bar', $updatedTransfer->metadata['test']);
    6934    }
     
    7136    public function testTransferUpdateMetadataAll()
    7237    {
    73         $recipient = self::createTestRecipient();
    74 
    75         self::authorizeFromEnv();
    76         $transfer = Transfer::create(array(
    77             'amount' => 100,
    78             'currency' => 'usd',
    79             'recipient' => $recipient->id
    80         ));
     38        $transfer = self::createTestTransfer(array(), $this->opts);
    8139
    8240        $transfer->metadata = array('test' => 'foo bar');
    8341        $transfer->save();
    8442
    85         $updatedTransfer = Transfer::retrieve($transfer->id);
     43        $updatedTransfer = Transfer::retrieve($transfer->id, $this->opts);
    8644        $this->assertSame('foo bar', $updatedTransfer->metadata['test']);
    8745    }
    88 
    89     public function testRecipientUpdateMetadata()
    90     {
    91         $recipient = self::createTestRecipient();
    92 
    93         $recipient->metadata['test'] = 'foo bar';
    94         $recipient->save();
    95 
    96         $updatedRecipient = Recipient::retrieve($recipient->id);
    97         $this->assertSame('foo bar', $updatedRecipient->metadata['test']);
    98     }
    99 
    100     public function testRecipientUpdateMetadataAll()
    101     {
    102         $recipient = self::createTestRecipient();
    103 
    104         $recipient->metadata = array('test' => 'foo bar');
    105         $recipient->save();
    106 
    107         $updatedRecipient = Recipient::retrieve($recipient->id);
    108         $this->assertSame('foo bar', $updatedRecipient->metadata['test']);
    109     }
    11046}
  • stripe/trunk/vendor/stripe/stripe-php/tests/UtilTest.php

    r1365533 r1725154  
    4343        $this->assertSame(Util\Util::utf8($x), $x);
    4444    }
     45
     46    public function testUrlEncode()
     47    {
     48        $a = array(
     49            'my' => 'value',
     50            'that' => array('your' => 'example'),
     51            'bar' => 1,
     52            'baz' => null
     53        );
     54
     55        $enc = Util\Util::urlEncode($a);
     56        $this->assertSame('my=value&that%5Byour%5D=example&bar=1', $enc);
     57
     58        $a = array('that' => array('your' => 'example', 'foo' => null));
     59        $enc = Util\Util::urlEncode($a);
     60        $this->assertSame('that%5Byour%5D=example', $enc);
     61
     62        $a = array('that' => 'example', 'foo' => array('bar', 'baz'));
     63        $enc = Util\Util::urlEncode($a);
     64        $this->assertSame('that=example&foo%5B%5D=bar&foo%5B%5D=baz', $enc);
     65
     66        $a = array(
     67            'my' => 'value',
     68            'that' => array('your' => array('cheese', 'whiz', null)),
     69            'bar' => 1,
     70            'baz' => null
     71        );
     72
     73        $enc = Util\Util::urlEncode($a);
     74        $expected = 'my=value&that%5Byour%5D%5B%5D=cheese'
     75              . '&that%5Byour%5D%5B%5D=whiz&bar=1';
     76        $this->assertSame($expected, $enc);
     77
     78        // Ignores an empty array
     79        $enc = Util\Util::urlEncode(array('foo' => array(), 'bar' => 'baz'));
     80        $expected = 'bar=baz';
     81        $this->assertSame($expected, $enc);
     82
     83        $a = array('foo' => array(array('bar' => 'baz'), array('bar' => 'bin')));
     84        $enc = Util\Util::urlEncode($a);
     85        $this->assertSame('foo%5B0%5D%5Bbar%5D=baz&foo%5B1%5D%5Bbar%5D=bin', $enc);
     86    }
    4587}
Note: See TracChangeset for help on using the changeset viewer.