766 Commits

Author SHA1 Message Date
remi-stripe
29f321b224
Add support for the SetupAttempt resource and List API (#949)
* Codegen for openapi 3854362

* Fix and add tests
2020-09-29 22:54:58 -07:00
Remi Jannel
0620436d63 Bump version to 5.25.0 2020-09-02 13:57:09 -07:00
remi-stripe
683b10140e
Add support for the Issuing Dispute Submit API (#944)
* Codegen for openapi 474461f

* Add and fix tests for the latest stripe-mock

Some of the tests had to be changed/mocked because stripe-mock has a bug
where the includable sub-lists it returns have the wrong url set.
Because of this, when you call create/list/etc. on one of those sub-lists
the calls fails due to that URL being incorrect.
Moved one test to use charge+refund (auto-expanded) and another used a
mock to have the right URL returned.
2020-09-02 13:56:24 -07:00
Brandur
5d9039731b Bump version to 5.24.0 2020-08-26 13:01:23 -07:00
Joel Taylor
23a0ee2dbe
Extract configurations into separate object (#939)
Adds a `Stripe::StripeConfiguration` object to manage internal and user
supplied configuration options.

This is primarily motivated by #921 in order to provide a way to set
options on for an instance of `StripeClient`.
2020-08-26 12:58:59 -07:00
brchristian
c517a708d5
Fix typo in documentation of stripe_object.rb (#940) 2020-08-16 16:53:15 -07:00
Brandur
8710fcaddc Bump version to 5.23.1 2020-08-05 16:01:36 -07:00
Brandur
3433130c5d
Rename API resource's request method (#936)
As seen in #928, the `refresh` method doesn't work for an event class.
This is because event has a field called `request`, and it ends up
replacing the `request` method that it inherited from being an API
resource, so when `refresh` tries to make a request, it fails because it
tries to invoke it on the accessor added for the event's property.

Here we give `request` a much more unique name so that it will never
conflict with a property field again, and update all internal references
to use the new name. We use `alias` to make the old name available for
backwards compatibility reasons because its been around for so long that
people are probably calling it.

Fixes #928.
2020-08-05 16:00:37 -07:00
Remi Jannel
5573a73337 Bump version to 5.23.0 2020-08-05 12:36:13 -07:00
remi-stripe
cf8b2c5e84
Add support for the PromotionCode resource and APIs (#937)
* Codegen for openapi f71053e

* Add tests
2020-08-05 12:33:47 -07:00
Christopher
9cf59214f3
Adding comment to show which files are generated (#931) 2020-07-22 14:30:18 -07:00
Remi Jannel
403f9b22f6 Bump version to 5.22.0 2020-05-11 17:11:40 -07:00
remi-stripe
cfac8d7fcc
Add support for the LineItem resource and APIs (#918) 2020-05-11 17:10:41 -07:00
Remi Jannel
4c5b67bce0 Bump version to 5.21.0 2020-04-29 12:45:58 -07:00
remi-stripe
622db9d9e7
Add support for the Price resource and APIs (#917)
* Codegen for openapi f75fd88

* Fix test suite
2020-04-29 12:41:35 -07:00
Brandur
07f58cad01 Bump version to 5.20.0 2020-04-27 14:37:36 -07:00
Brandur
58fdde1289
Add new .generate_header method for webhooks (#916)
Adds a new `generate_header` method for the webhooks module, following
up #915. This method doesn't help in any way with webhook verification,
but may be useful to users in their test suites as it allows them to
easily simulate the contents of a header that Stripe might have sent.

We briefly discussed an alternative design here, but this one seems like
the best fit:
https://github.com/stripe/stripe-ruby/pull/915#issuecomment-620164654
2020-04-27 14:36:53 -07:00
Brandur
49477fa250 Bump version to 5.19.0 2020-04-24 10:59:14 -07:00
Brandur
e117c9fb6d
Expose Stripe::Webhook.compute_signature (#915)
Exposes the `.compute_signature` method, which may be useful when
testing webhook signing in test suites.

I change the API slightly so that a caller isn't forced to do as much
string mangling, and to match the one that we already have in stripe-go:

``` go
func ComputeSignature(t time.Time, payload []byte, secret string) []byte {
```

Add basic documentation and test case. I also change a few things around
so that we send `Time` objects around more often where applicable, and
don't change then to Unix integers until the last moment that we need
to.

The one other alternative API I considered is this one, which would
default the timestamp to the current time to allow the method to be
called with one fewer arg:

``` ruby
def self.compute_signature(payload, secret: timestamp: Time.now)
```

I decided against it in the end though because it does remove some
explicitness, and it's not a big deal to just pass in `Time.now`,
especially given that this is not expected to be a commonly used method.

Fixes #912.
2020-04-24 10:58:42 -07:00
Remi Jannel
1b68611edc Bump version to 5.18.0 2020-04-22 12:10:16 -07:00
remi-stripe
b8c01be32d
Add support for BillingPortal namespace and Session resource and APIs (#911) 2020-04-22 12:09:02 -07:00
Brandur
1a20c2476d Bump version to 5.17.0 2020-02-26 16:53:50 -08:00
Brandur
f7923f7b47
Add StripeError#idempotent_replayed? (#907)
Adds an easy accessor on `StripeError` which indicates whether the error
occurred previously, but was replayed on this request because the user
passed the same idempotency key as that original request.

Fixes #905.
2020-02-26 16:53:02 -08:00
Olivier Bellone
de40bbf232
Bump version to 5.16.0 2020-02-26 12:53:11 -08:00
Olivier Bellone
1bd015ea4a
Codegen for openapi 40a20cd (#906) 2020-02-26 12:51:52 -08:00
Brandur
c1520fb208 Bump version to 5.15.0 2020-02-10 14:23:43 -08:00
Brandur
81407b6807
Add request_begin instrumentation callback (#902)
Adds a new instrumentation callback called `request_begin` which, as the
name suggests, is invoked before an HTTP request is dispatched. As
outlined originally in #900, the idea is that this will enable a set of
hooks that can be used for distributed tracing.

The PR also renames the existing `request` callback to `request_end`,
although the old name is still invoked for the time being for backwards
compatibility.

A special `user_data` property is passed to `request_begin` which allows
subscribers to set custom data that will be passed through to
`request_end` for any given request. This allows, for example, a user
assigned ID to be set for the request and recognized on both ends.

I chose the naming `_begin` and `_end` (as opposed to start/finish or
any other combination) based on the naming conventions of Ruby itself.

Fixes #900.
2020-02-10 14:22:58 -08:00
Remi Jannel
c62344a70b Bump version to 5.14.0 2020-01-14 08:20:34 -08:00
remi-stripe
368f534bce
Codegen for openapi d663cdb (#896) 2020-01-14 08:17:44 -08:00
Dennis van der Vliet
9afd73c16f Explicitly pass a parameter as hash to be more ruby 2.7 friendly (#892)
* Tweaks to be ruby 2.7 friendly

* Disable a cop to allow hash passing

* Tidy up rubocop comments and remove .ruby-version

* Use inline disable
2020-01-09 16:29:11 -08:00
Brandur
2a95b62431 Bump version to 5.13.0 2020-01-08 13:11:42 -08:00
Dennis van der Vliet
9c49df7e7b Ruby 2.7 (#891)
* Build against 2.7

* Fix low hanging fruit warnings

* Get rid of some more warnings
2020-01-08 13:10:02 -08:00
Olivier Bellone
ebbfb54c2d
Bump version to 5.12.1 2020-01-06 15:33:24 -08:00
Olivier Bellone
cddd3db2b2
Override API key with client_secret in OAuth.token (#890) 2020-01-06 15:30:32 -08:00
Olivier Bellone
e23ae43850
Bump version to 5.12.0 2020-01-02 15:12:11 -08:00
Olivier Bellone
c5be2f492b
[codegen] Add support for retrieve source transaction API method (#889)
* Codegen for openapi ba4dcd0

* Add tests
2020-01-02 15:11:08 -08:00
Olivier Bellone
824d1f9efe
Bump version to 5.11.0 2019-11-26 13:46:14 -08:00
Olivier Bellone
7aeae42fdc
Add support for CreditNote preview (#885) 2019-11-26 13:44:56 -08:00
Alex Rattray
75b1797771 Bump version to 5.10.0 2019-11-08 16:42:40 -08:00
Alex Rattray (Stripe)
2ded14efe3
Add list_usage_record_summaries and list_source_transactions (#882)
* Add list_usage_record_summaries and list_source_transactions

* Fix lint
2019-11-08 16:24:38 -08:00
Brandur
455d1c163c Bump version to 5.9.0 2019-11-07 14:19:36 -08:00
Bart
26a0964e56 Add simple instrumentation callback (#870)
* Add simple instrumentation callback

We used to insert Faraday::Request::Instrumentation into our Faraday middleware
stack to be able to instrument Stripe calls with StatsD. With Faraday being
removed in version 5, this required some rework. This commit implements a simple
callback system that can be used with any kind of instrumentation system.

* Add a topic to Stripe::Instrumentation notifications

... and a :request topic to subscribe to

* Use a RequestEvent value object instead of positional args in callback

This way the RequestLogContext object doesn't get exposed externally. Since the
same value object can be received by multiple subscribers it is frozen to
prevent accidental mutations across threads.

* Relocate tests for instrumentation and add more tests
2019-11-07 14:18:11 -08:00
Remi Jannel
8d72722cc7 Bump version to 5.8.0 2019-11-05 19:41:29 -08:00
remi-stripe
6b4a0343b3
Add support for Mandate (#879) 2019-11-05 19:36:41 -08:00
Joel Taylor
299e9ea0ab Raise an error when requests params are invalid (#874)
There are two kinds of API operations: collection and element specific.
The signature between the two is slightly different:
  - **collection**: (params, opts)
  - **element specific**: (id, params, opts)

If a user doesn't realize the difference, they may attempt to use the
collection signature when performing an element specific operation like:
```
Stripe::PaymentIntent.cancel('pi_1234', 'sk_test_key')
 # Results in an error: NoMethodError: undefined method `key?' for "sk_test"
```

The resulting error message isn't very useful for debugging.

Instead,this PR adds a message letting the user know what it's expecting:
`request params should be either a Hash or nil (was a String)`
2019-10-31 09:53:19 -07:00
Olivier Bellone
16c05468bc
Bump version to 5.7.1 2019-10-15 17:09:44 -07:00
Brandur
00b60afbf5 Add some documentation on ordering direction 2019-10-10 10:36:32 -07:00
Brandur
15f8304e48 Bump version to 5.7.0 2019-10-10 10:11:58 -07:00
Brandur
e3cc91ded2 Support backwards pagination with list's #auto_paging_each (#865)
* Support backwards pagination with list's `#auto_paging_each`

Previously, `#auto_paging_each` would always try to paginate forward,
even if it was clear based on the list's current filters that the user
had been intending to iterate backwards by specifying an `ending_before`
filter exclusively.

Here we implement backwards iteration by detecting this condition,
reversing the current list data, and making new requests for the
previous page (instead of the next one) as needed, which allows the user
to handle elements in reverse logical order.

Reversing the current page's list is intended as a minor user feature,
but may possibly be contentious. For background, when backwards
iterating in the API, results are still returned in "normal" order. So
if I specifying `ending_before=7`, the next page would look like `[4, 5,
6`] instead of `[6, 5, 4]`. In `#auto_paging_each` I reverse it to `[6,
5, 4]` so it feels to the user like they're handling elements in the
order they're iterating, which I think is okay. The reason it might be
contentious though is that it could be a tad confusing to someone who
already understands the normal `ending_before` ordering in the API.

Fixes #864.

* Allow `ending_before` and `starting_after` to remain in hydrated list object
2019-10-10 10:11:12 -07:00
Brandur
c206a3cc09 Bump version to 5.6.0 2019-10-04 13:16:35 -07:00