67 Commits

Author SHA1 Message Date
Corey Farwell
c4c38d63fc Add string constants for each of the Stripe object names. 2017-04-26 14:20:22 -04:00
Corey Farwell
f057ee1893 Don't require opts param for convert_to_stripe_object. 2017-04-24 18:40:03 -04:00
Remi Jannel
65e8f505d5 Added support for the new Payout and RecipientTransfer objects
The Transfer object used to represent all movements of funds in Stripe. It
split in three resources:
- Transfer: this describes the movement of funds between Stripe accounts
and is specific to Stripe Connect.
- Payout: this describes the movement of funds from a Stripe account to a
bank account, debit card or any future payout method.
- RecipientTransfer: this describes the movement of funds from a Stripe
account to a Recipient's card or Bank Account. This is here for legacy
reasons and can only be accessed from an expanded BalanceTransaction.

This change is behind an API version so old API versions would still use
the Transfer object for everything while new API version would see the
split.

This applies beyond the new object as some properties/methods are removed
from Transfer and other properties are renamed on other objects.
2017-03-31 14:03:56 -04:00
Olivier Bellone
b8e6a385cf Adds support for detaching sources from customers 2017-03-17 16:11:05 +01:00
Brandur
1886d9a625 Move to an alternative system based on StripeClient 2017-02-14 12:17:37 -08:00
Brandur
b5ad0e30d7 Change to hash parameter for now for 1.9 support 2017-02-14 12:17:37 -08:00
Brandur
843ea88219 Add a StripeResponse to objects created by API calls 2017-02-14 12:17:37 -08:00
Brandur
b291bce240 Alphabetize class name list 2017-01-13 12:41:35 -08:00
Feram
f14bf618e5 Fix typo unkown 2016-11-06 05:19:10 +00:00
Brandur
dff2bf10dd Alphabetize class list
This is a pretty pedestrian change, but here we alphabetize the list of
StripeObject class mappings so that it's easier to scan it for
accidental omissions.
2016-10-14 16:31:51 -07:00
Kyle Conroy
c131bcbcac Correctly encode the subscription items array (#467)
* Correctly encode the subscription items array

* Use super

* Handle non-arrays as well

* Also encode items on create
2016-09-27 13:46:57 -07:00
Jacqueline
d2f783df34 Add support for multiplan subscriptions (#466)
* Add support for multiplan subscriptions:
Serialize indexed arrays into hashes with index keys in subscription create, subscription update, and upcoming invoice
Add a SubscriptionItem object that supports creation, deletion, update, listing, and retrieval

* Remove helpers that convert items array to indexed hash
2016-09-21 17:44:00 -07:00
Vijay Singh
7ac03e0a88 Changed from ApplePay::Domain to ApplePayDomain 2016-09-14 18:43:56 -07:00
Vijay Singh
35bbb7a26b Ruby bindings of ApplePayDomain 2016-09-14 18:16:12 -07:00
Brandur
a5a9eb94db Produce an error on bad array of maps
This produces an error when we detect an "array of maps" that cannot be
encoded with `application/x-www-form-urlencoded`; that is to say, one
that does not have each hash starting with a consistent key that will
allow a Rack-compliant server to recognize boundaries.

So for example, this is fine:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' },
    { :type => 'discount', :amount => -10000, :currency => 'cad', :description => 'potato' }
],
```

But this is _not_ okay:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' },
    { :amount => -10000, :currency => 'cad', :description => 'potato', :type => 'discount' }
],
```

(`type` should be moved to the beginning of the array.)

The purpose of this change is to give users better feedback when they
run into an encoding problem like this one. Currently, they just get
something confusing from the server, and someone on support usually
needs to examine a request log to figure out what happened.

CI will fail until the changes in #453 are brought in.
2016-08-25 17:07:56 -07:00
Brandur
d9b6f08ce5 Don't alphabetize encoded maps by key
Alphabetizing maps being encoded by key can cause problems because the
server side Rack relies on the fact that that a new array item will
start with a repeated key.

For example, given this encoding:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' },
    { :type => 'discount', :amount => -10000, :currency => 'cad', :description => 'potato' }
],
```

We need to have `type` appear first so that an array boundary is
recognized. So the encoded form should take:

```
items[][type]=sku&items[][parent]=...&items[][type]=discount&items[][amount]=...
```

But currently `type` gets sorted to the back, so we get something more
like:

```
items[][parent]=...&items[][type]=...&items[][amount]=...&items[][currency]=...&items[][description]=...&items[][type]=potato
```

Which the server will receive as this:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk', :amount => -10000, :currency => 'cad', :description => 'potato' }
    { :type => 'discount' }
],
```

Here we remove the alphabetization to fix the problem and correct a bad
test.
2016-08-25 10:54:08 -07:00
Olivier Bellone
be8c56458f Added support for 3D Secure 2016-07-12 17:01:33 +02:00
Brandur
531e0ff317 Document Util.convert_to_stripe_object
Adds some basic documentation to `Util.convert_to_stripe_object`.
2016-06-09 09:02:23 -07:00
Rasmus Rygaard
dab45737c9 Add order returns. 2016-05-18 17:56:15 -07:00
Remi Jannel
2a6673a8e5 Support AlipayAccount retrieval and deletion 2016-05-17 17:52:00 -04:00
Brandur
8f55baa6ea Fix warnings emitted during tests
I'm not sure exactly what changed here (did we change the `$VERBOSE`
setting?), but I'm not seeing a whole lot of warnings when running the
test suites locally and in CI. For example:

```
Started
........................................./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
............../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
.../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
...
..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
........../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
................./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
.../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
..........
........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
............./home/travis/build/stripe/stripe-ruby/lib/stripe/stripe_object.rb:35: warning: instance variable @values not initialized
./home/travis/build/stripe/stripe-ruby/lib/stripe/stripe_object.rb:35: warning: instance variable @values not initialized
...................../home/travis/build/stripe/stripe-ruby/lib/stripe/transfer.rb:8: warning: instance variable @api_key not initialized
..............
..
Finished in 0.785621037 seconds.
```

Most of these are due to unused or uninitialized variables. This patch
fixes all warnings by fixing offending code.
2016-04-11 15:20:42 -07:00
Ioannis Kolovos
f8532d225e Support for Stripe::CountrySpec 2016-02-06 16:55:29 +02:00
Brandur
216218aeb0 Order hack to make 1.8.7 tests happy
It turns out that the tests had been working ... but mostly by virtue of
luck only. This should stabilize them more permanently.
2015-10-20 12:15:36 -07:00
Brandur
77b1972a72 Use alternate testing approach to satisfy 1.8.7 2015-10-10 12:40:17 -07:00
Brandur
395d16b8c1 Remove sorting hack from parameter encoding
I added this for a regression suite so that 1.8.7 could pass its tests,
but unfortunately this caused a regression in the way that parameters
are encoded for arrays of hashes. This patch reverts the change and adds
tests to detect a future regression.

(And 1.8.7 is expected to fail on this initial commit.)
2015-10-10 12:12:57 -07:00
Brandur
eb8787754c Replace deprecated URI.escape with a customized CGI.escape
Replaces my original attempt in #319 in a way that doesn't depend on
`URI.encode_www_form` which doesn't exist in 1.8.7. This should
hopefully get us the best of all worlds.

Caveats around use of `+` instead of `%20` as detailed in #319 still
apply.

Fixes #286.
2015-10-06 14:46:58 -07:00
Brandur
91262c9042 Sort encoded parameters for stability in 1.8.7 tests 2015-10-06 14:17:51 -07:00
Brandur
a48fd12c70 Add regression suite for testing parameter encoding
Pulls the test suite out of #319 so that we can get some coverage around
parameter encoding. This should prevent any recurrence of #318.

Also includes a little bit of refactoring.
2015-10-06 14:04:02 -07:00
Brandur
d38250d717 Revert "Remove use of deprecated URI.escape" 2015-10-06 13:30:39 -07:00
Brandur
0db40e43fc Remove use of deprecated URI.escape
But we still want to percent-encode entities like spaces, so instead of
using `CGI.escape` we use a utility from WEBrick.

Fixes #286.
2015-09-29 16:33:20 -07:00
Rasmus Rygaard
747dac6ea0 Add Orders. 2015-09-13 20:43:36 -07:00
Rasmus Rygaard
690fd18cb3 Add SKUs, Products 2015-09-13 18:10:47 -07:00
Russell Davis
dc8cbe5bdd Merge pull request #278 from HashNuke/266-return-token-object-on-token-create
Fix #266: Add Token to object classes map
2015-08-03 13:05:10 -07:00
Akash Manohar J
21c7061b5e Fix #266: Add Token to object classes map 2015-08-04 01:26:23 +05:30
Caitlin
eb75ccd7fa Merge pull request #269 from stripe/disputes
Add top level dispute methods.
2015-08-03 11:32:37 -07:00
Andy Cohen
97c9249ab1 extract method 'normalize_id' from 'StripeObject#initialize' & 'ListObject#retrieve' 2015-07-27 15:47:16 -05:00
Chase Lambert
801dd99318 Get requests with arrays of dictionaries to work 2015-07-23 15:03:48 -07:00
Caitlin Johnson
a37912f122 Add top level dispute methods. 2015-07-16 14:19:41 -07:00
Brian Krausz
5883e421c1 Add support for account bank accounts 2015-06-06 12:52:34 -07:00
Bob Long
c269e9bd9b Safer argument parsing (attempt 2) 2015-03-25 15:15:02 +00:00
Brian Krausz
d1bceb0041 Support transfer reversals 2015-02-12 22:24:09 -08:00
Jeff Browning
aeb99cb0d2 Add Account to business objects 2015-02-11 11:14:26 -05:00
Brian Krausz
bf18ae9376 Fix use of 1.9-style hashes 2015-02-09 23:42:23 -08:00
Brian Krausz
4d611c62f7 Support persisted use of Stripe-Account header everywhere
Including implicit use in /v1/accounts/ endpoints
2015-02-09 23:38:34 -08:00
Max Lahey
9f175e070f added BitcoinTransaction 2015-01-20 11:58:43 -08:00
Max Lahey
0e9a88f796 Wired up support for BitcoinReceiver 2015-01-20 11:58:41 -08:00
wangjohn
ad26262a2c Adding support for listing file uploads. 2015-01-12 12:44:46 -08:00
wangjohn
6990bbd798 Include stripe account parameter for setting header. 2014-12-19 11:27:12 -08:00
Kyle Conroy
e3a68bb3b9 Replace api_key with an options hash
For now, only two options are supported: `api_key` and
`idempotency_key`. In the future, we'll be adding support for additional
headers as needed.
2014-12-17 23:23:46 -08:00
Russell Davis
99cb861dbd Merge pull request #172 from westonplatter/rename-internal-var
rename internal variable. rename `new` to `new_hash` so it's not a keyword
2014-11-14 14:31:20 -08:00