532 Commits

Author SHA1 Message Date
pakrym-stripe
60d51f2c0a
API Updates (#1041) 2022-03-29 15:37:58 -07:00
pakrym-stripe
90fae49d64
API Updates (#1040) 2022-03-28 12:42:32 -07:00
pakrym-stripe
fc480cdb6c
Add supporting classes for test helper generation (#1034) 2022-03-28 08:00:54 -07:00
Susindaran Elangovan
ba38dc9d24
Add support for Search API (#992) 2022-03-17 09:50:15 -07:00
Richard Marmorstein
1f8b6bf3e1
Codegen for openapi 1707cb8 (#1035) 2022-03-01 15:01:51 -05:00
Richard Marmorstein
c641c3ab19
Codegen for openapi a285624 (#1032) 2022-02-15 17:50:41 -05:00
Richard Marmorstein
917e512c10
API Updates (#1031)
* Codegen for openapi 4d2f301
2022-01-20 11:22:53 -05:00
Dominic Charley-Roy
234a9611a6
Add connection manager logging and include object IDs in logging. (#1022) 2021-12-13 12:55:40 -05:00
yejia-stripe
d4d282d14d
API Updates (#1017) 2021-11-16 10:04:38 -05:00
Richard Marmorstein
3db855d309
Codegen for openapi 21065d4 (#1015) 2021-11-11 15:55:13 -05:00
Dominic Charley-Roy
9774447859
Add tests for child resources. (#1013) 2021-10-13 11:30:44 -04:00
Dominic Charley-Roy
3e2665fb11
Add tests for namespaced resources. (#1012) 2021-10-12 14:38:30 -04:00
Richard Marmorstein
4c36bacd41
API Updates (#1010) 2021-10-11 10:58:59 -04:00
Dominic Charley-Roy
e534c876b3
Add generated test suite. (#1009) 2021-10-07 18:11:34 -04:00
DJ Patterson
85c7f52c3a
Add request_id to RequestEndEvent (#993)
Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>
2021-08-09 19:47:46 -04:00
Richard Marmorstein
cbecb42185
API Updates (#988) 2021-07-14 12:14:41 -04:00
Dominic Charley-Roy
d8b3ddf595
API Updates (#987) 2021-07-09 15:36:24 -04:00
Dominic Charley-Roy
90223fa06b
Update normalize_opts to use dup instead of clone. (#985) 2021-06-29 17:04:56 -04:00
Richard Marmorstein
19da5510df
Deprecate travis (#982) 2021-06-24 12:01:53 -04:00
Dominic Charley-Roy
59eb8d06cf
Add support for making a request and receiving the response as a stream. (#983) 2021-06-24 10:24:11 -04:00
Richard Marmorstein
faf84198c6
API Updates (#981) 2021-06-04 12:35:25 -04:00
Richard Marmorstein
0ba9307bdb
API Updates (#979) 2021-05-19 10:13:22 -04:00
Brandur Leach
16a094cf34
Rename Stripe.configuration to Stripe.config (#972)
This is just a cosmetic change that renames `Stripe.configuration` to
just `Stripe.config`. We use the shorter "config" in most other places
including `StripeClient#config`, so I feel that this is overall more
consistent.

This change is backwards compatible because the new accessor came in
with #968, and that hasn't been given a formal release yet.

I've left the class name as `StripeConfiguration` which IMO is fine. The
class uses the expanded form of the name while vars and accessors use
the shorter `config`. Also, `StripeConfiguration` has been around a
little bit longer, so renaming it is somewhat backwards incompatible
too.
2021-04-02 13:24:37 -07:00
Brandur
3e26570fcd
On config change, only clear connection managers for changed config (#971)
Follows up #968.

As a relic from when we had global configuration, anytime any config
value is changed on any client, we still clear all connection managers
everywhere on every thread, even though this is not necessary. This
means that we lose all open connections, etc.

Here, we make changes so that if a configuration is changed, we only
clear the configuration managers pertaining to that one particular
configuration, thus conserving resources globally.

Co-authored-by: Brandur <brandur@brandur.org>
2021-04-02 13:13:26 -07:00
Brandur Leach
b9c7afd5fe
Reserve some critical field names when adding StripeObject accessors (#970)
When populating `StripeObject`s, we add accessors to them so that people
can access fields like `obj.currency`.

This was probably only meant to apply to API resources, but through
what might have been an accident of history, we've also traditionally
unmarshaled any hash that comes back from the API as a `StripeObject`,
including `metadata` fields. This allows some convenience because users
can access values like `obj.metadata.my_field`, but is also obviously a
minefield for potential problems.

In issue #969, what's essentially happening is that because there's a
metadata field named `class`, we've overwritten the object's normal
`class` method with our own custom one that accesses the metadata value.
Amazingly, the object can still marshal/unmarshal mostly properly, but
fails on this line as we try to access `obj.class` and that turns out to
be a metadata value instead of a class:

``` ruby
when StripeObject
  obj.class.construct_from(
    ...
```

Here I solve the problem by banning accessors added with the name
`class`. This has a slight risk of backward incompatibility in that
users that previously had metadata named "class" will now have to use
square bracket accessors instead like `obj.metadata[:class]`, but
honestly, I just can't see anything good in allowing "class" to be used
as an accessor.

An alternative solution might be to alias `class` in `StripeObject` and
then make sure we always use that in places like `initialize_from` and
`deep_copy`.

The best long term solution would be to stop add accessors to metadata
objects. This just seems like a bad idea given that there are still
myriads of Ruby built-ins that could potentially be overwritten. This is
definitely a considerably-sized breaking change though, so we'd have to
do it on a major.
2021-04-02 11:08:56 -07:00
Joel Taylor
21643f0716
Allow StripeClient to be configured per instance (#968)
This changes allows for each instance of StripeClient to have its own
configuration object instead of relying on the global config. Each
instance can be configured to override any global config values
previously set.
2021-04-01 14:19:38 -07:00
Richard Marmorstein
f864e68bf7
CI: github actions (#967) 2021-03-10 14:48:48 -05:00
Richard Marmorstein
f59ba8cae0
Add billing portal configuration (#965) 2021-02-19 20:32:33 -05:00
Brandur
c28ee66a14
Fix return value of Customer#delete_discount (#964)
`Customer#delete_discount` has been broken for some time in that it
tries to re-initialize `self` (which is a customer) with a received
discount response. This is incorrect and leads to various problems.

Here, we redefine the return value of `delete_discount` as a discount,
and have it no longer mutate the object on which is was called. We add a
comment as well just to help flag some of the behavior which could
potentially be confusing.

Fixes #963.
2021-02-09 09:50:07 -08:00
Bart de Water
085e08142d
Allow setting write_timeout for connections on Ruby 2.6+ (#950) 2020-10-14 11:43:32 -07:00
remi-stripe
db24334b9e
Add support for the Payout Reverse API (#951)
* Codegen for openapi 4bd4c01

* Add test
2020-10-14 07:51:16 -07:00
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-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
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
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
Joel Taylor
f240405810
Update minimum stripe-mock version to 0.94.0 (#935)
The params for AccountLink changed in `v0.93.0`, which will cause the
test suite to fail unless `stripe-mock` is pinned to an earlier version.

Fixes #934
2020-07-31 16:44:01 -07:00
remi-stripe
cfac8d7fcc
Add support for the LineItem resource and APIs (#918) 2020-05-11 17:10:41 -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
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
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-stripe
b8c01be32d
Add support for BillingPortal namespace and Session resource and APIs (#911) 2020-04-22 12:09:02 -07: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
Brandur
554f18b850
Upgrade to Rubocop 0.80 (#903)
Just noticed that a new version of Rubocop came out today. The upgrade
seemed relatively painless, so just went for it.
2020-02-18 10:41:55 -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-stripe
368f534bce
Codegen for openapi d663cdb (#896) 2020-01-14 08:17:44 -08:00
Brandur
fd71c5f50f Clean up test output by capturing $stderr when we expect warnings (#894)
I just noticed while running tests that we produce some accidental
output because both of `Source#source_transactions` and
`SubscriptionItem#usage_record_summaries` are considered deprecated and
have warnings attached.

Here we capture output to `$stderr` and assert on it from the test cases
that call these deprecated methods -- this pattern is already well
established elsewhere in the test suite.
2020-01-09 16:57:39 -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
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
cddd3db2b2
Override API key with client_secret in OAuth.token (#890) 2020-01-06 15:30:32 -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