793 Commits

Author SHA1 Message Date
Brandur
6ebf6ad92a Whitelist retry exceptions
Right now we are retrying *most* non-HTTP exceptions. This is
problematic because in something like a test context, even a rogue name
error could initiate a retry. It's also bad for production because there
are quite a number of socket errors [1] for which we don't want to
retry.

Fixes #462.

[1] https://ruby-doc.org/stdlib-2.3.0/libdoc/socket/rdoc/Socket.html
2016-08-31 15:23:21 -07:00
Brandur
805b65478c Bump version to 1.53.0 v1.53.0 2016-08-31 08:10:34 -07:00
Brandur
e3dd15273c Merge pull request #460 from stripe/brandur-upgrade-rest-client
Relax rest-client requirements
2016-08-31 08:09:26 -07:00
Brandur
5039d22339 Merge pull request #461 from stripe/brandur-fix-warnings
Fix interpreter warnings
2016-08-31 08:09:19 -07:00
Brandur
6b46b50c1b Fix interpreter warnings
These aren't causing the build to fail or anything, but they do get
spewed out every time our test suite runs.
2016-08-31 07:12:53 -07:00
Brandur
aa12f7e621 Relax rest-client requirements
Our fairly old requirements for rest-client (and therefore mime-types)
are starting to cause some dependency hell problems for some customers.
Try relaxing these constraints and locking 1.9 specifically into
compatible versions.
2016-08-31 06:56:17 -07:00
Brandur
73a1cf33de Bump version to 1.52.0 v1.52.0 2016-08-30 14:48:55 -07:00
Brandur
2da96e4798 Merge pull request #458 from stripe/brandur-generalize-save-nested-resource
Generalize saving nested resources
2016-08-30 14:47:52 -07:00
Brandur
22839df560 Nicen this code up a little bit and add a comment 2016-08-30 13:42:11 -07:00
Brandur
c796958516 Generalize saving nested resources
Since #433, saving API resources nested under other API resources has
not been the default. Instead, any instances where this should occur
have been special cased with specific method implementations that would
set the `#save_with_parent` flag when a field is written.

This ended up causing some problems because as seen in #457, because
places that we need to do this aren't well vetted, some were forgotten.

This makes implementation of new fields that need this behavior simpler
by implementing a `.save_nested_resource` metraprogramming method on the
`APIResource` class. This can be called as necessary by any concrete API
resource implementations.

We replace existing implementatinos and also add one to `Subscription`,
which had previously been suffering from a similar problem where its
`#source` had not received a special case.
2016-08-30 11:52:16 -07:00
Brandur
c15e3953fe Bump version to 1.51.1 v1.51.1 2016-08-30 11:13:56 -07:00
Brandur
41f09a75a3 Merge pull request #457 from stripe/brandur-fix-account-external-account-set
Flag Account#external_account into save_with_parent system
2016-08-30 11:12:57 -07:00
Brandur
1dd5cea24d Fix title of test context 2016-08-30 10:22:17 -07:00
Brandur
67b10a52ca Add deprecated #bank_account=
Add deprecated `#bank_account=` to maintain backwards compatibility.
This would have been broken by #433, so this change keeps the
functionality alive in case someone has not upgraded since.
2016-08-29 13:44:46 -07:00
Brandur
d6514ef633 Flag Account#external_account into save_with_parent system
In #433, we built a framework under which subresources are usually not
persisted, but in certain cases they can be. At the time,
`Customer#source` was the only field that I knew about that had to be
flagged into it.

Issue #456 has raised that we also be doing `Account#external_account`.
This patch adds support for that.

Fixes #456.
2016-08-29 10:34:08 -07:00
Brandur
5573cc73fc Bump version to 1.51.0 v1.51.0 2016-08-26 10:20:29 -07:00
Brandur
d61c1b1211 Merge pull request #455 from stripe/brandur-header-like-headers
Move away from rest-client's "symbol header names"
2016-08-26 10:19:00 -07:00
Brandur
ee03100891 Merge pull request #454 from stripe/brandur-error-on-improper-array-of-maps
Produce an error on bad array of maps
2016-08-26 10:17:22 -07:00
Brandur
6cd72a1eb4 Fix word reversal 2016-08-25 17:11:55 -07:00
Brandur
7df3a4bdd6 One more test case to show that the check is recursive 2016-08-25 17:09:50 -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
fb9fd44dd6 Bump version to 1.50.1 v1.50.1 2016-08-25 14:36:59 -07:00
Brandur
497201aca7 Merge pull request #453 from stripe/brandur-stop-alphabetizing
Don't alphabetize encoded maps by key
2016-08-25 14:34:05 -07:00
Brandur
2a9413e155 Move away from rest-client's "symbol header names"
This moves away from rest-client's convention of using symbols as header
names so as to present less obfuscation as to how these are actually
named when they go over the wire.

Because headers can be injected via the bindings' API I was initially
worried that this change might break something, but upon inspection of
rest-client source, I can see now that headers take precedence as
assigned by their insertion order into the header hash, and are
"stringified" in that same loop [1]. This means that even if a user
injects a symbolized header name (`:idempotency_key`), it will still
correctly overwrite the one generated by stripe-ruby despite that using
the string format (`"Idempotency-Key"`).

[1] https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L603,L625
2016-08-25 11:42:44 -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
Brandur
980fd2bd07 Merge pull request #449 from stripe/brandur-readme-usage
Add usage section to README
2016-08-17 15:24:33 -07:00
Brandur
0ef5c629f9 Add stripe_account in here as well 2016-08-17 13:56:50 -07:00
Brandur
8952860d8e Bump version to 1.50.0 v1.50.0 2016-08-15 13:36:56 -07:00
Brandur
adb8e5307d Merge pull request #450 from stripe/will-add-source-create
Add ability to create sources
2016-08-15 12:09:38 -07:00
Will Bronitsky
6062d27ed8 Add ability to create sources 2016-08-12 09:53:39 -07:00
Brandur
b2d0490a86 Add usage information for using an API key with a list operation 2016-08-10 11:28:52 -07:00
Brandur
af68678895 Add usage section to README
Add a section that contains basic usage information to the README.
2016-08-10 11:00:41 -07:00
Brandur
e7f09c2e68 Bump version to 1.49.0 v1.49.0 2016-07-28 17:35:50 -07:00
Brandur
830e2baf42 Merge pull request #446 from stripe/will-add-source-functionality
Add Source functionality
2016-07-28 17:34:58 -07:00
Will Bronitsky
4a6d70bf14 Add Source functionality 2016-07-28 17:25:06 -07:00
Romain Huet
2026c06242 Update the Travis CI badge 2016-07-12 18:55:38 -07:00
Brandur
d7abd71071 Bump version to 1.48.0 v1.48.0 2016-07-12 10:11:55 -07:00
Brandur
5d31fc1e1b Merge pull request #442 from stripe/ob-3ds
Added support for 3D Secure
2016-07-12 10:11:29 -07:00
Olivier Bellone
be8c56458f Added support for 3D Secure 2016-07-12 17:01:33 +02:00
Brandur
7ed6e48b48 Bump version to 1.47.0 v1.47.0 2016-07-11 16:54:50 -07:00
Brandur
b0f347dcf3 Merge pull request #439 from mikesea/rest-client-version
Relax rest-client version requirements
2016-07-11 16:53:40 -07:00
Mike Chlipala
65bbee4bf8 Relax rest-client version requirements 2016-07-11 16:36:23 -07:00
Brandur
d32a514393 Merge pull request #441 from stripe/brandur-mime-types-workaround-2
Workaround for mime-types related failures on 1.9
2016-07-11 15:48:45 -07:00
Brandur
d250120102 Workaround for mime-types related failures on 1.9 2016-07-11 15:06:56 -07:00
Brandur
d6c73c2b65 Merge pull request #438 from stripe/brandur-remove-restclient-workaround
Remove hack to work around rest-client bug
2016-07-07 11:16:51 -07:00
Brandur
ac49ef0b59 Remove hack to work around rest-client bug
This removes a hack in the code that's designed to work around a
rest-client bug which was added back in 2011. Unfortunately neither
comments nor commit messages bother to tell us what the nature of the
bug actually was, but based on what it's rescuing, it might be
rest-client/rest-client#58, which has been fixed for over five years
now.

Following up on the work done in #436, let's continue to try and simply
the error handling paths by taking this out.
2016-07-07 09:25:48 -07:00
Brandur
660f7725b7 Bump version to 1.46.0 v1.46.0 2016-07-07 09:20:14 -07:00
Brandur
b97e1010c0 Merge pull request #436 from stripe/brandur-retry-conflict
Rework HTTP retry path + retry 409s
2016-07-07 09:19:36 -07:00
Brandur
bf1cc03227 Bump version to 1.45.0 v1.45.0 2016-07-07 09:05:25 -07:00
Brandur
e2499edfa3 Merge pull request #433 from stripe/brandur-serialize-whitelist
Go back to not saving subresources, but exclude `Customer#source=`
2016-07-07 09:04:06 -07:00