76 Commits

Author SHA1 Message Date
David Brownman
d25eb5252e
update doc link (#1690) 2025-10-01 15:36:37 -04:00
David Brownman
fd4368dbb8
⚠️ Drop support for Ruby < 2.6 & clarify version policy (#1684)
* update version requirements

* linting

* Fix linting

* add ci comment

* remove unused block
2025-09-30 17:25:42 +00:00
Ramya Rao
1cf3e3d504
Add section on private preview SDKs in readme (#1638) 2025-08-27 15:18:37 -04:00
helenye-stripe
2241742fa6
Explicitly mention that APIResource.request was removed (#1615) 2025-07-01 19:29:29 +00:00
prathmesh-stripe
8ac3b4f3c3
Updated stripeclient snippets in Readme.md (#1619) 2025-06-23 16:14:53 +00:00
Mike Chlipala
4367ac9511
Fix raw_request example in readme (#1620) 2025-06-16 07:10:55 -07:00
Ramya Rao
6a2a9dca26
Simplify public preview SDK instructions (#1604) 2025-05-09 07:31:13 -07:00
Ramya Rao
a89df859de
Rename beta SDKs to public preview SDKs in readme (#1603)
* Rename beta SDKs to public preview SDKs in readme

* More details in installation steps

* simplify text
2025-05-08 07:02:05 -07:00
helenye-stripe
1a0c78f112
Add resource pattern deprecation plan to README (#1592) 2025-04-24 12:43:28 -07:00
Ramya Rao
fdb39ed488
Remove unused youtube playlist link (#1575)
* Remove link for stale youtube video playlist

* Remove unused youtube playlist link
2025-04-08 15:17:57 -07:00
helenye-stripe
04f8d1b43a
Validate all instance variable keys returned from the API (#1571)
* Normalize all keys

* instead reject invalid keys

* rubocop

* more easy to read constants
2025-04-08 13:43:23 -07:00
Ramya Rao
182d4dc838
Remove link for stale youtube video playlist (#1573) 2025-04-08 16:11:34 -04:00
helenye-stripe
dc5174725f
Add RBI annotations for fields and params (#1559)
* Introduce types to ruby

* rubocop

* forgot these files

* other request methods

* more tests, fix for raw request

* Add README entry for types

* rebase and regen
2025-03-31 14:29:41 -07:00
David Brownman
08020d3207
add justfile (#1513)
* add justfile

* add just to ci and split out commands

* Fix justfile

* update readme and CI

* update justfile

* update CI

* update justfile import

* remove unused block
2025-01-16 14:54:59 -08:00
jar-stripe
ef7e6ee51e
added CONTRIBUTING.md file (#1515) 2025-01-15 19:30:40 +00:00
Jonathan Smith
042918c5f8
Always return the result of APIResource#refresh in APIResource.retrieve (#1473)
* Always return the result of .refresh in .retrieve

With the refactor of v13, there are now cases where `self` is not
mutated in the call to refresh and instead a new object is returned.
This change ensures that the new object is always returned by returning
the result of refresh instead.

* Update install instructions for stripe-mock
2024-10-23 08:45:51 -07:00
Ramya Rao
39d8736525
Support for APIs in the new API version 2024-09-30.acacia (#1458) 2024-10-01 09:35:59 -07:00
helenye-stripe
816fe0d0c7
Add raw_request (#1431)
* Add raw request

* Copy readme from beta

* fix readme
2024-07-10 21:34:52 +00:00
prathmesh-stripe
8a5fca9998
Added jruby back and removed coveralls (#1426) 2024-06-26 14:57:08 -04:00
helenye-stripe
a12ff9cdb8
Add last_response to StripeObject (#1377)
* Add last_response to StripeObject

* Add more data to test and fix README
2024-04-09 10:52:43 -07:00
helenye-stripe
6458ba68f4
Update README to use add_beta_version (#1345) 2024-02-28 12:19:18 -08:00
pakrym-stripe
64afe4a398
Update README.md (#1339) 2024-02-21 12:40:30 -08:00
Richard Marmorstein
1af9e1a864
Update README.md 2023-12-01 13:28:28 -08:00
Richard Marmorstein
fdde37d8f0 README note 2023-11-28 13:30:09 -08:00
Justin Hammond
d297fdef7d
fix: variable typo in README for instrumentation (#1231) 2023-06-20 11:47:16 -07:00
anniel-stripe
fcfeac740e
Update README.md with instrumentation changes (#1165) 2023-01-18 15:41:04 -08:00
Bart de Water
2dec63e6b0
Update request_end instrumentation example (#1095)
* Update request_end instrumentation example in README.md
2022-10-14 16:40:20 -07:00
Annie Li
2076cfd42e Add coveralls 2022-08-24 09:56:47 -07:00
pakrym-stripe
78863b4b0f
Update README.md (#1125) 2022-08-24 08:57:58 -07:00
pakrym-stripe
53ab9bf668
Add beta readme.md section (#1121) 2022-08-23 16:34:02 +00:00
Ramya Rao
0f04faab6d
Add a support section to the readme (#1115)
We have user feedback on the lack of clarity around whether or not we maintain and improve older major versions of the SDK. This PR adds a support section clarifying this
2022-08-17 14:06:15 -07:00
pakrym-stripe
df255e06b5
Update README.md (#1065) 2022-06-06 09:58:16 -07:00
Dominic Charley-Roy
3e476701b4
Update Docs URLs. (#1024) 2021-12-23 15:51:02 -05: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
f864e68bf7
CI: github actions (#967) 2021-03-10 14:48:48 -05:00
CJ Avilla
de27275ee6
Add playlist links into README (#959)
* Update readme

* Add link to YouTube playlist from README
2021-01-12 16:34:41 -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
CJ Avilla
e1ae307e60
Update readme (#942) 2020-08-31 15:11:13 -07:00
Brandur
69e19fa6bd Correct available fields for request_begin 2020-02-11 13:42:17 -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
7182ae0f8b
Move code examples from charge to customer and remove save mention (#899) 2020-01-27 10:09:39 -08:00
Alex Rattray (Stripe)
da06eb2cb3
Fix non-hash comment in README (#883) 2019-11-26 20:52:12 +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
Viktor Fonic
162e29c979 Add gem version badge (#881) 2019-11-06 09:35:55 -08:00
Joel Taylor
93ea15fb46 Add additional per-request configuration documentation (#876) 2019-11-01 10:09:45 -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
Brandur
8b45b1d980 Change max retry copy to match up to stripe-python's 2019-08-14 09:21:44 -07:00
Olivier Bellone
47686d844b
Enable request latency telemetry by default (#800) 2019-06-24 18:07:28 -07:00
Remi Jannel
54dcf73d96 Fix examples to not use hash rockets 2019-06-12 10:56:16 -07:00
Michael Bianco
322a8c60be Readme example of expanding parameters and specifying a per-request API version (#642)
These options aren't immediately appartent without digging through
the client source code
2019-04-30 09:53:48 -07:00