1027 Commits

Author SHA1 Message Date
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
Brandur
3984246514 Rework HTTP retry path + retry 409s
Two changes:

1. The HTTP retry path has been refactored to make retries on errors
that are not RestClient exceptions possible by bringing the logic up a
level. This also has the effect of somewhat simplifying the exception
handling logic which can be somewhat difficult to reason about right
now.

2. Retry on `RestClient::Conflict` (a 409 from the API) as discussed in
issue #431.

Fixes #431.
2016-07-05 12:37:39 -07:00
Brandur
6a41234406 Additional commentary on #source= method and implementation 2016-07-01 15:54:38 -07:00
Brandur
6560cfaf4b Don't talk about "default source" here 2016-07-01 15:54:38 -07:00
Brandur
2a4a50da8e Introduce #save_with_parent flag
Introduce a `#save_with_parent` flag that allows the default behavior of
never saving API resources nested under a parent to be overridden, a
feature that we so far only know to need for updating a source under a
customer.
2016-07-01 15:54:38 -07:00
Brandur
d0a3493144 Revert "Remove check that prevents API resource subobjects from being serialized"
This reverts commit 7bbc6ef2e59006cc6d9410a92a09d8c5c68d2893.
2016-07-01 15:54:38 -07:00
Brandur
be8466b47b Merge pull request #434 from stripe/brandur-fix-ci
Fix Gem builds in CI
2016-07-01 15:54:18 -07:00
Brandur
1e166d9be7 Fix Gem builds in CI
CI is failing for a number of Ruby versions because shoulda is pulling
in should-matchers, which then pulls in activesupport. activesupport's
new 5.0.0 version is being picked up, and that requires at least Ruby
2.2.2.

Luckily the solution is easy, we're not using shoulda-matchers, only
shoulda-context, so just tighten up our dependencies a little and the
problem goes away.
2016-07-01 15:44:32 -07:00
Brandur
774e885334 Clean up comments around exponential backoff 2016-06-30 10:44:08 -07:00
Kyle Conroy
8377a9f941 Bump version to 1.44.0 v1.44.0 2016-06-29 14:35:07 -07:00
Kyle Conroy
732a494ac4 Add update class method to API resources (#426)
* Rename the `Update` operation to `Save`
* Add the `update` class method to all saveable resources
* Add tests for update method
* Add tests for plans, invoice items, and application fees
2016-06-29 14:13:42 -07:00
Brandur
cb8917b7a3 Merge pull request #432 from Edouard-chin/req_url_doc_fix
Removed a forgotten line of doc [ci skip]:
2016-06-29 07:23:07 -07:00
Edouard CHIN
d288be358a Removed a forgotten line of doc [ci skip]:
- This removes the doc about `req_url` while saving a StripeObject, this options was removed in `e226ef`
2016-06-29 02:11:56 -04:00
Brandur
f2aa8c1e58 Bump version to 1.43.1 v1.43.1 2016-06-17 14:48:07 -07:00
Brandur
ea06b1ba67 Merge pull request #428 from stripe/rasmus-fix_order_return_object
Convert return_order response to OrderReturn.
2016-06-17 14:47:14 -07:00
Rasmus Rygaard
f37a1f2f9f Convert return_order response to OrderReturn. 2016-06-17 11:03:56 -07:00
Brandur
3b06b2c880 Merge pull request #424 from JuanitoFatas/fix/gemspec-homepage
Fix homepage for Ruby docs in gemspec
2016-06-13 09:07:40 -07:00