551 Commits

Author SHA1 Message Date
Brandur
61ba47d619 Allow the CA bundle to be configured
As requested in #370, this will allow advanced users to configure a
certificate bundle that is expected to be more up-to-date than what
we've managed to include with the gem.
2016-01-26 14:19:07 -08:00
Rasmus Rygaard
8d8fb67aae Support deleting SKUs and products. 2016-01-25 10:32:49 -08:00
Yogesh Khater
4fe8474279 Forward parameters passed to charge.refund
fixes #365
2016-01-21 12:00:42 +05:30
Brandur
13cba9f29a Remove deprecations 2016-01-19 15:31:44 -08:00
Brandur
cd9d2bc71e Also re-implement Charge#refund to use our new endpoint
This was already done for `ApplicationFee`.
2016-01-15 10:36:42 -08:00
Brandur
8a20ab8972 Deprecate #refund helpers on Charge and ApplicationFee
As discussed previously in #354 and alluded to in #363, this patch
deprecates the `#refund` helpers on `Charge` and `ApplicationFee` in
favor of the resource-centric approach (i.e. `charge.refunds.create`).

We do this for a few reasons:

1. The new approach is far preferred and uses our modern endpoints. It's
   also been the mechanism suggested by the documentation for ages now.
2. The old approach is somewhat risky in that a forgotten "s" can lead
   to an accidental refund (i.e. `charge.refund` instead of
   `charge.refunds`).

Follows up #354. Fixes #363.
2016-01-14 18:16:56 -08:00
Brandur
6fca0e63d9 Merge pull request #361 from stripe/brandur-init-original-values
Always initialize `original_values` ivar in `StripeObject`
2016-01-07 10:46:32 -07:00
Michael Bianco
2255dd73a8 Adding nil customer value to mock bitcoin receiver hash 2016-01-06 21:47:32 -05:00
Brandur
2564990aa2 Always initialize original_values ivar in StripeObject
This is kind of a weird one because it'll only cause a failure when
serializing a subobject or hash of a `StripeObject`, but it's good
practice to initialize instance variables anyway.

Fixes #360.
2016-01-06 14:40:52 -07:00
Brandur
d5f5efb77d Merge pull request #354 from stripe/brandur-refund-url-correction-2
Update application fee refunds (round 2)
2015-12-03 17:37:36 -08:00
Nate Brustein
a31986fa6e feat(request): optionally retry all requests that fail on a network failure 2015-11-23 14:30:54 -05:00
Brandur
c7e515ba7b Use refunds.create + maintain backward compatibility 2015-11-19 14:10:33 -08:00
Brandur
bc66a38cd4 Update application fee refunds (round 2)
Follows up the patch in #351, which I now believe is wrong. The trouble
is that we were mutating the application fee object, when in reality an
application fee refund is actually a completely new resource (see
[creating a refund][create-refund]). This patch edits the original
attempt to cut a new object and updates tests accordingly.

Once again, related to stripe/stripe-php#208.

[create-refund]: https://stripe.com/docs/api#create_fee_refund
2015-11-18 12:25:52 -08:00
Brandur
c7fd5b6baa Correct URL used for refunding application fees
This uses the new endpoint instead of the deprecated one.

Related to stripe/stripe-php#208.
2015-11-16 11:07:32 -08:00
Brandur
03b64a059d Remove test hacks introduced to work around Ruby 1.8 limitations 2015-11-04 16:41:59 -08:00
Brandur
159335078c For completeness, add a test case with an empty string 2015-11-03 13:38:59 -08:00
Brandur
5769eb7c1e More consistent spacing 2015-11-03 09:31:21 -08:00
Michael Bianco
7cd161dd03 Tests for BankAccount#verify 2015-10-29 15:01:53 -04:00
Brandur
ae4bb64c5a Call serialization of a changed array of hashes undefined for now 2015-10-27 11:53:36 -07:00
Brandur
431ef3b1f2 Special case the serialization of account's additional_owners
We attempt to do a special encoding trick when serializing
`additional_owners` under an account: when updating a value, we actually
send the update parameters up as an integer-indexed hash rather than an
array. So instead of this:

    field[]=item1&field[]=item2&field[]=item3

We send this:

    field[0]=item1&field[1]=item2&field[2]=item3

The trouble is that this had previously been built into the core library
as the default handling for all arrays. Because of this, it was
impossible to resize a non-`additional_owners` array as described in
more detail in #340.

This patch special cases `additional_owners` and brings sane behavior
back to normal arrays along with a test suite so that we try to build
some better guarantees around both the general and non-general cases.
2015-10-27 09:07:41 -07: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
7dabbd444a Revert "Tweak faulty test logic"
This reverts commit eac89a1af140600904b8e723b20b9755545b6a6e.
2015-10-20 12:15:20 -07:00
Brandur
eac89a1af1 Tweak faulty test logic 2015-10-20 12:11:28 -07:00
Brandur
a014d505bc Correct internal usage of #update_attributes
Unfortunately usage of `#update_attributes` had rolled over from a time
where `#update_attributes_with_options` was still in use and `opts` were
being passed in as an optional argument which had the result of further
nesting the hash internally (i.e. `:opts => { :opts => ... } }`).

This patch fixes that problem, adds a regression test to prevent it from
reappearing, and banishes the unused `#update_attributes_with_options`.

Fixes #334.
2015-10-12 12:08:44 -07:00
Brandur
77b1972a72 Use alternate testing approach to satisfy 1.8.7 2015-10-10 12:40:17 -07:00
Brandur
ca8b49e5fd Use array as input instead of hash (for 1.8.7 tests) 2015-10-10 12:12:57 -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
daf2789ad7 Pass through all paging filters to descendent pages
When additional filters were provided for pagination like an expansion
or a predicate, they would not propagate to any call after the first.
This patch addresses that issue by storing all filters and moving them
to any new page objects being created.

Fixes #331.
2015-10-09 13:58:23 -07:00
Brandur
900fa4b5dc Add StripeObject#deleted?
Adds a special helper to `StripeObject` that helps a developer to
determine whether or not an object is deleted.

As described originally in #257, this is a bit of a special case because
a non-deleted object does not respond with `deleted` as part of its
representation, so while a deleted object would have this accessor
available automatically, non-deleted objects would not. This made use of
the SDK awkward because the presence of the method was not guaranteed.

Fixes #257 (again, heh).
2015-10-09 10:16:59 -07:00
Brandur
b3912c1712 Merge branch 'brandur-deprecate-refresh-from'
Conflicts:
	lib/stripe/stripe_object.rb
2015-10-08 17:49:27 -07:00
Brandur
d09093fca1 Add some tests just to make sure everything is working as we expect 2015-10-08 17:43:20 -07:00
Brandur
1a96d7cf8e Use Gem:: deprecation method instead of a custom one 2015-10-08 17:24:59 -07:00
Brandur
11dd870900 Have StripeObject#update_attributes reflect behavior of accessors
This dials down the safety of `StripeObject`'s `#update_attributes`
method so that it allows properties to be assigned that it doesn't yet
know about. We're doing this for a few reasons:

1. To reflect the current behavior of accessors (i.e. `obj.name = ...`)
   through `method_missing`.
2. To allow `#update_attributes` to assign properties on new projects
   that don't yet know their schema from an API call.

Fixes #324.
2015-10-08 14:04:11 -07:00
Brandur
3468698ce9 Make 1.8 happy 2015-10-08 10:03:18 -07:00
Brandur
8b255c7005 Deprecate StripeObject#refresh_from
As discussed in #325, this deprecates the public visibility of
`#refresh_from` (by renaming it). It also adds some deprecation
infrastructure to produce warnings when it's used.
2015-10-08 09:57:16 -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
5853fd47dd Add one more set of tests for #url_encode 2015-10-06 14:38:14 -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
42ea34b969 Pagination
Usage on a top-level collection:

```
Stripe::Customer.list.auto_paging_each do |customer|
  puts customer
end
```

Usage on a subcollection:

``` ruby
customer.invoices.auto_paging_each do |invoice|
  puts invoice
end
```

We've also renamed `#all` to `#list` to prevent confusion ("all" implies
that all resources are being returned, and in Stripe's paginated API
this was not the case). An alias has been provided for backward API
compatibility.

Fixes #167.

Replaces #211 and #248.
2015-10-05 12:15:09 -07:00
Kyle Conroy
8287904c00 Merge pull request #316 from stripe/apt-file-uploads-retrieve-url
Use correct URL for file upload retrieval
2015-10-05 11:36:30 -07:00
Jieren Chen
7d28eaab64 Merge pull request #310 from stripe/drj/t5176-legal-entity-override
Disallow directly overriding legal_entity
2015-10-02 12:12:09 -07:00
Andrew Thorp
841a34385a Use correct URL for file upload retrieval 2015-10-01 17:36:51 -07:00
Brandur
b57cd5aca4 Support Ruby 1.8.7 2015-10-01 16:59:56 -07:00
Brandur
e23b57628f Add attribute mass assignment and use it in #save
As detailed in issue #119, we've somewhat unfortunately been allowing
object attributes to be passed in during a #save because we mix any
arguments directly into the serialized hash (it seems that this was
originally intended to be used more for meta parameters that go to the
request).

As also noted in #119, this use causes problems when certain types of
parameters (like subobjects) are used. We're now left in the somewhat
awkward position of either:

1. Removing this functionality on #save and breaking what may be
   behavior that people depend on.
2. Fully support this mass assignment.

This patch takes the second path by extracting a new #update_attributes
method and using it from #save. It's still far from a perfect approach
because keys that have the same name as certain options (e.g. `req_url`)
are not going to work, but it should capture the behavior that most
people want.

Fixes #119.
2015-10-01 16:21:34 -07:00
Jieren Chen
e451e3d3e2 Fix test 2015-10-01 13:51:55 -07:00
Jieren Chen
797478786d Disallow directly overriding legal_entity 2015-10-01 13:39:11 -07:00
Brandur
df2e36287d Merge pull request #309 from stripe/brandur-boolean-accessors
Add question mark helpers (e.g. #paid?) for boolean object values
2015-09-30 14:36:23 -07:00
Brandur
a88b062beb Merge pull request #300 from stripe/brandur-upsert
Create if #save is called on a new object
2015-09-30 13:54:20 -07:00
Brandur
c301c6c0f6 Add question mark helpers (e.g. #paid?) for boolean object values
This patch adds question marks helpers (e.g. #paid?) for any values in a
StripeObject that are a boolean. This is fairly idiomatic Ruby in that
it behaves similarly to other libraries like ActiveRecord.

Note that a caveat here is that nullable booleans will not get a helper
added for them if their current value is null. For this reason, we
should eventually prefer to derive these methods from some sort of
programmatic API manifest.

Replaces #257 and #274.
2015-09-30 13:48:59 -07:00