107 Commits

Author SHA1 Message Date
anniel-stripe
46eca72f79
Do not run Coveralls if secret token is not available (#1137) 2022-10-24 14:34:46 -07:00
Annie Li
dc93d96cb9 Change check to 3.1. 2022-08-24 11:01:48 -07:00
Annie Li
f647412789 Add comment and change to starts_with 2022-08-24 10:56:47 -07:00
Annie Li
2076cfd42e Add coveralls 2022-08-24 09:56:47 -07:00
Dominic Charley-Roy
d8b3ddf595
API Updates (#987) 2021-07-09 15:36:24 -04:00
Richard Marmorstein
19da5510df
Deprecate travis (#982) 2021-06-24 12:01:53 -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
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
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
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
remi-stripe
b8c01be32d
Add support for BillingPortal namespace and Session resource and APIs (#911) 2020-04-22 12:09:02 -07:00
remi-stripe
368f534bce
Codegen for openapi d663cdb (#896) 2020-01-14 08:17:44 -08:00
Olivier Bellone
7aeae42fdc
Add support for CreditNote preview (#885) 2019-11-26 13:44:56 -08:00
remi-stripe
6b4a0343b3
Add support for Mandate (#879) 2019-11-05 19:36:41 -08:00
Brandur
27718e0e47 Drop Timecop dependency (#858)
If #857 comes in, it turns out that we don't need Timecop anymore (it
doesn't freeze the monotic clock, so I had to find another way) -- here
we remove all mentions of it and drop the dependency.

I don't find it causes too much trouble so I'm not against bringing it
back in the future if we need it again, but it seems good for project
cleanliness to take it out for now.
2019-10-01 10:10:39 -07:00
Brandur
44766516d9 stripe-ruby V5 (#815)
* Convert library to use built-in `Net::HTTP`

Moves the library off of Faraday and over onto the standard library's
built-in `Net::HTTP` module. The upside of the transition is that we
break away from a few dependencies that have caused us a fair bit of
trouble in the past, the downside is that we need more of our own code
to do things (although surprisingly, not that much more).

The biggest new pieces are:

* `ConnectionManager`: A per-thread class that manages a connection to
  each Stripe infrastructure URL (like `api.stripe.com`,
  `connect.stripe.com`, etc.) so that we can reuse them between
  requests. It's also responsible for setting up and configuring new
  `Net::HTTP` connections, which is a little more heavyweight
  code-wise compared to other libraries. All of this could have lived in
  `StripeClient`, but I extracted it because that class has gotten so
  big.

* `MultipartEncoder`: A class that does multipart form encoding for file
  uploads. Unfortunately, Ruby doesn't bundle anything like this. I
  built this by referencing the Go implementation because the original
  RFC is not very detailed or well-written. I also made sure that it was
  behaving similarly to our other custom implementations like
  stripe-node, and that it can really upload a file outside the test
  suite.

There's some risk here in that it's easy to miss something across one of
these big transitions. I've tried to test out various error cases
through tests, but also by leaving scripts running as I terminate my
network connection and bring it back. That said, we'd certainly release
on a major version bump because some of the interface (like setting
`Stripe.default_client`) changes.

* Drop support for old versions of Ruby

Drops support for Ruby 2.1 (EOL March 31, 2017) and 2.2 (EOL March 31,
2018). They're removed from `.travis.yml` and the gemspec and RuboCop
configuration have also been updated to the new lower bound.

Most of the diff here are minor updates to styling as required by
RuboCop:

* String literals are frozen by default, so the `.freeze` we had
  everywhere is now considered redundant.

* We can now use Ruby 1.9 style hash syntax with string keys like `{
  "foo": "bar" }`.

* Converted a few heredocs over to use squiggly (leading whitespace
  removed) syntax.

As discussed in Slack, I didn't drop support for Ruby 2.3 (EOL March 31,
2019) as we still have quite a few users on it. As far as I know
dropping it doesn't get us access to any major syntax improvements or
anything, so it's probably not a big deal.

* Make `CardError`'s `code` parameter named instead of positional (#816)

Makes the `code` parameter on `CardError` named instead of positional.
This makes it more consistent with the rest of the constructor's
parameters and makes instantiating `CardError` from `StripeClient`
cleaner.

This is a minor breaking change so we're aiming to release it for the
next major version of stripe-ruby.

* Bump Rubocop to latest version (#818)

* Ruby minimum version increase followup (#819)

* Remove old deprecated methods (#820)

* Remove all alias for list methods (#823)

* Remove UsageRecord.create method (#826)

* Remove IssuerFraudRecord (#827)

* Add ErrorObject to StripeError exceptions (#811)

* Tweak retry logic to be a little more like stripe-node (#828)

Tweaks the retry logic to be a little more like stripe-node's. In
particular, we also retry under these conditions:

* If we receive a 500 on a non-`POST` request.
* If we receive a 503.

I made it slightly different from stripe-node which checks for a 500
with `>= 500`. I don't really like that -- if we want to retry specific
status codes we should be explicit about it.

We're actively re-examining ways on how to make it easier for clients to
figure out when to retry right now, but I figure V5 is a good time to
tweak this because the modifications change the method signature of
`should_retry?` slightly, and it's technically a public method.

* Fix inverted sign for 500 retries (#830)

I messed up in #828 by (1) accidentally flipping the comparison against
`:post` when checking whether to retry on 500, and (2) forgetting to
write new tests for the condition, which is how (1) got through.

This patch fixes both those problems.

* Remove a few more very old deprecated methods (#831)

I noticed that we had a couple of other deprecated methods on `Stripe`
and `StripeObject` that have been around for a long time. May as well
get rid of them too -- luckily they were using `Gem::Deprecate` so
they've been producing annoying deprecated warnings for quite a while
now.

* Remove extraneous slash at the end of the line

* Reset connections when connection-changing configuration changes (#829)

Adds a few basic features around connection and connection manager
management:

* `clear` on connection manager, which calls `finish` on each active
  connection and then disposes of it.

* A centralized cross-thread tracking system for connection managers in
  `StripeClient` and `clear_all_connection_managers` which clears all
  known connection managers across all threads in a thread-safe way.

The addition of these allow us to modify the implementation of some of
our configuration on `Stripe` so that it can reset all currently open
connections when its value changes.

This fixes a currently problem with the library whereby certain
configuration must be set before the first request or it remains fixed
on any open connections. For example, if `Stripe.proxy` is set after a
request is made from the library, it has no effect because the proxy
must have been set when the connection was originally being initialized.

The impetus for getting this out is that I noticed that we will need
this internally in a few places when we're upgrading to stripe-ruby V5.
Those spots used to be able to hack around the unavailability of this
feature by just accessing the Faraday connection directly and resetting
state on it, but in V5 `StripeClient#conn` is gone, and that's no longer
possible.

* Minor cleanup in `StripeClient` (#832)

I ended up having to relax the maximum method line length in a few
previous PRs, so I wanted to try one more cleanup pass in
`execute_request` to see if I could get it back at all.

The answer was "not by much" (without reducing clarity), but I found a
few places that could be tweaked. Unfortunately, ~50 lines is probably
the "right" length for this method in that you _could_ extract it
further, but you'd end up passing huge amounts of state all over the
place in method parameters, and it really wouldn't look that good.

* Do better bookkeeping when tracking state in `Thread.current` (#833)

This is largely just another cleanup patch, but does a couple main
things:

* Hoists the `last_response` value into thread state. This is a very
  minor nicety, but effectively makes `StripeClient` fully thread-safe,
  which seems like a minor nicety. Two calls to `#request` to the same
  `StripeObject` can now be executed on two different threads and their
  results won't interfere with each other.

* Moves state off one-off `Thread.current` keys and into a single one
  for the whole client which stores a new simple type of record called
  `ThreadContext`. Again, this doesn't change much, but adds some minor
  type safety and lets us document each field we expect to have in a
  thread's context.

* Add Invoice.list_upcoming_line_items method (#834)
2019-08-20 11:35:24 -07:00
Remi Jannel
49f7201052 Move Balance History to /v1/balance_transactions and add tests 2019-07-30 11:54:48 -07:00
Remi Jannel
a993e892b3 Add support for the SetupIntent resource and APIs 2019-06-27 12:55:35 -07:00
Remi Jannel
abef09ef6e Add support for CustomerBalanceTransaction resource and APIs 2019-06-16 10:49:47 -07:00
Olivier Bellone
ec91de6849
Upgrade Rubocop and fix a bunch of issues (#786)
* Bump Rubocop to 0.57.2

* Style/StderrPuts: Use warn instead of .puts

* Style/ExpandPathArguments: Use expand_path('../test_helper', __dir__) instead of expand_path('../../test_helper', __FILE__)

* Style/Encoding: Unnecessary utf-8 encoding comment

* Style/StringLiterals: Prefer double-quoted strings

* Style/AccessModifierDeclarations

* Style/FormatStringToken: Prefer annotated tokens

* Naming/UncommunicativeMethodParamName

* Metrics/LineLength: set maximum line length to 100 characters

* Style/IfUnlessModifier: Favor modifier if usage when having a single-line body

* Style/ClassVars

* Metrics/LineLength: set maximum line length to 80 characters (default)

* Style/AccessModifierDeclarations: EnforcedStyle: inline
2019-05-24 10:43:42 -07:00
Olivier Bellone
6612b5b3c6
Bump stripe-mock to 0.57.0 and fix tests (#784) 2019-05-23 17:27:14 -07:00
remi-stripe
270e88b169 Add support for the Capability resource and APIs (#779) 2019-05-14 11:52:04 -07:00
Remi Jannel
b5cd9e3682 Add support for TaxId resource and APIs 2019-04-19 10:13:57 -07:00
remi-stripe
c3e65b2552 Fix our test suite for latest stripe-mock (#757) 2019-04-05 21:11:24 -07:00
Remi Jannel
de204dda1c Add support for retrieving a Checkout Session 2019-03-18 16:29:04 -07:00
Remi Jannel
1094e894cc Fix tests to work on latest stripe-mock for future updates 2019-03-05 10:16:49 -08:00
Remi Jannel
d784819901 Add support for Subscription Schedules 2019-02-11 22:38:08 -08:00
Remi Jannel
359a0c9cdf Move CheckoutSession to the Checkout namespace and rename to Session 2019-01-16 18:50:14 -08:00
Olivier Bellone
dbf8a41244
Embed OpenAPI files and start stripe-mock from test suite 2019-01-10 15:06:01 +01:00
Mick Jermsurawong
652047f130 bump strip mock version to 0.40.1 2019-01-09 15:55:41 -08:00
Remi Jannel
0747d59752 Add support for the Checkout Session resource 2018-12-21 09:20:29 +01:00
Remi Jannel
220bac9397 Add support for the Account Link resource 2018-12-07 16:06:04 -08:00
Remi Jannel
c186e71c92 Revert "Add support for the Account Link resource"
This reverts commit 335c40b4d8cf974c427f34024072272441a5131e.
2018-12-07 16:05:05 -08:00
Remi Jannel
335c40b4d8 Add support for the Account Link resource 2018-12-07 15:54:50 -08:00
Remi Jannel
0383de9dc2 Add support for the Review resource 2018-11-28 09:50:42 -05:00
Remi Jannel
ceab2740c1
Add support for Radar List and ListItem resources 2018-11-27 14:10:18 +01:00
Brandur
85013c9770 Use Faraday's Net::HTTP::Persistent adapter
This changes the library's default connection over to use the adapter
for `Net::HTTP::Persistent`, which is a connection pooling library for
Ruby.

In the long run, I think we should probably just drop Faraday ... the
amount of value it's getting us is extremely tenuous and its API is
difficult to work with. I hate to do it at this point though because
technically people could be writing custom middleware for it.
2018-11-15 08:55:28 -08:00
Remi Jannel
23d94005d3 Add support for the Person resource 2018-10-30 10:25:10 -07:00
David Zhu
51f4550c2f Bump StripeMock version 2018-09-24 13:43:49 -07:00
Olivier Bellone
9d64d31e2a
Upgrade stripe-mock 2018-09-22 16:52:58 +02:00
Olivier Bellone
ea09249e67
Use files.stripe.com only for the file create endpoint 2018-09-20 23:02:00 +02:00
Brandur
b19358fb80 Upgrade stripe-mock to 0.30.0
Upgrades to the most recent version of stripe-mock now that we've got a
few more fixes into both its implementation and into stripe-ruby's test
suite.
2018-08-30 10:09:10 -07:00