186 Commits

Author SHA1 Message Date
Remi Jannel
04ae411754 Add support for Issuing resources 2018-07-26 13:35:50 -04:00
zach wick
ab3949b8da Adds support for 'partner_id' in 'set_app_info' (#658)
* Adds support for 'partner_id' in 'set_app_info'

Signed-off-by: zach wick <zwick@stripe.com>
2018-06-28 08:55:58 -07:00
Remi Jannel
201f9c29f4 Add support for the PaymentIntent resource
This feature is gated so the tests are stubbed for now
2018-06-27 19:24:23 -04:00
Brandur
863da48398 Add frozen_string_literal to every file and enforce Rubocop rule
Adds the magic `frozen_string_literal: true` comment to every file and
enables a Rubocop rule to make sure that it's always going to be there
going forward as well.

See here for more background [1], but the basic idea is that unlike many
other languages, static strings in code are mutable by default. This has
since been acknowledged as not a particularly good idea, and the
intention is to rectify the mistake when Ruby 3 comes out, where all
string literals will be frozen. The `frozen_string_literal` magic
comment was introduced in Ruby 2.3 as a way of easing the transition,
and allows libraries and projects to freeze their literals in advance.

I don't think this is breaking in any way: it's possible that users
might've been pulling out one of are literals somehow and mutating it,
but that would probably not have been useful for anything and would
certainly not be recommended, so I'm quite comfortable pushing this
change through as a minor version.

As discussed in #641.

[1] https://stackoverflow.com/a/37799399
2018-05-10 14:56:14 -07:00
Fay Wu
6ce45193d2 Add support for v1/issuer_fraud_records endpoints (#645) 2018-05-09 14:55:10 -07:00
Alexander Thiemann
c066c9c5f8 flexible billing primitives and tests 2018-04-11 13:29:24 -07:00
Jamu Kakar
0be22683a3 Add support for /v1/topups endpoints. 2018-02-16 15:03:46 -08:00
Olivier Bellone
b153b39203
Add support for exchange_rates API requests 2017-10-31 10:25:18 +01:00
Olivier Bellone
c455be74d4
Add support for listing source_transactions 2017-10-26 15:43:34 +02:00
Brandur
cf5354cc27 Alphabetize inclusion order 2017-10-17 17:50:20 -07:00
Brandur
7699033d90 Merge pull request #597 from stripe/ob-nested-resource-class-methods
Nested resource class methods
2017-10-17 17:50:52 -07:00
Brandur
6dca58937d Merge require lists together + add uri
There's really no reason for these to have been two separate lists.
Also, add `uri` as an explicit dependency (so far it's been getting
included by luck with other libraries).
2017-10-16 12:32:18 -07:00
Olivier Bellone
7f866aab5c
Nested resource class methods 2017-10-15 18:49:13 +02:00
Brandur
7f85eea3ee Fix low hanging Rubocop TODOs
I wanted to see what fixing Rubocop TODOs was like, so I tried to
eliminate all the easy ones. Most of these were pretty easy, and the
changes required are relatively minimal.

Some of the stuff left is harder. Pretty much everything under
`Metrics/*` is going to be a pretty big yak shave. A few of the others
are just going to need a little more work (e.g. `Style/ClassVars` and
`Style/GuardClause`). Going to stop here for now.
2017-09-27 15:07:18 -07:00
Olivier Bellone
e02ff7f849
Start using RuboCop for linting 2017-09-27 21:28:25 +02:00
Brandur
1ca67cb954 Correct behavior for error logging
A few changes:

* Add a new `Util.log_error` method which will forward to the equivalent
  of `#error` on a logger.
* Move errors produced by `StripeClient` to use `Util.log_error`.
* Change standard stdout logging behavior to log to stderr in the case
  of `Util.log_error.
* Change `Stripe.log_level` values to be an enum in a similar fashion as
  the standard library's built in `Logger`.
2017-08-11 11:45:43 -07:00
Brandur
cb111a8e74 Add support for setting a logger
Adds support for setting `Stripe.logger` to a logger that's compatible
with `Logger` from Ruby's standard library. In set, the library will no
longer log to stdout, and instead emit straight to the logger and defer
decision on what log level to print to it.

Addresses a request in #566.
2017-08-11 11:22:14 -07:00
Brandur
ce69d749e1 Implement STRIPE_LOG for stripe-ruby
Adds logging support for stripe-ruby in a similar way that we did it for
stripe-python [1], with the idea that users you can optionally get some
additional low-cost-to-configure logging for operational visibility or
debugging.

I made a few tweaks from the Python implementation (which I'll try to
contribute back to there):

* Added an elapsed parameter to responses so you can tell how long they
  lasted.
* Mixed in idempotency_key to all lines that users have a way to
  aggregate logs related to a request from start to finish.
* Standardized naming between different log lines as much as possible.
* Detect a TTY and produce output that's colorized and formatted.

[1] https://github.com/stripe/stripe-python/pull/269
2017-08-03 13:39:15 -07:00
Marc Hesse
d69ccfc1dd Add support for ephemeral keys (#549) 2017-06-20 18:30:30 -07:00
Olivier Bellone
330763aa02 Adds support for login links 2017-05-19 17:22:54 +02:00
Olivier Bellone
a645a78cd0 Add OAuth methods 2017-05-18 11:29:59 +02:00
Olivier Bellone
0376e242d9 Support for deserializing webhook events and verifying signatures 2017-04-28 14:25:40 +02:00
Corey Farwell
408c697847 Add Stripe::InvoiceLineItem class.
Fixes #531.
2017-04-26 14:59:02 -04:00
Brandur
06992ef370 Add app info to User-Agent as well 2017-04-17 12:57:16 -07:00
Brandur
6acd21ac48 Support "app info" for plugins in Ruby
Adds support for "app info" (a mechanism that allows a plugin's author
to identify that plugin) in Ruby. This is already supported in PHP and
we're adding it elsewhere.
2017-04-14 14:37:01 -07:00
Remi Jannel
65e8f505d5 Added support for the new Payout and RecipientTransfer objects
The Transfer object used to represent all movements of funds in Stripe. It
split in three resources:
- Transfer: this describes the movement of funds between Stripe accounts
and is specific to Stripe Connect.
- Payout: this describes the movement of funds from a Stripe account to a
bank account, debit card or any future payout method.
- RecipientTransfer: this describes the movement of funds from a Stripe
account to a Recipient's card or Bank Account. This is here for legacy
reasons and can only be accessed from an expanded BalanceTransaction.

This change is behind an API version so old API versions would still use
the Transfer object for everything while new API version would see the
split.

This applies beyond the new object as some properties/methods are removed
from Transfer and other properties are renamed on other objects.
2017-03-31 14:03:56 -04:00
Brandur
de08a9b986 Lots of broken tests, but working implementation! 2017-02-14 12:17:37 -08:00
Brandur
41f58e3cde Functional and tested StripeClient 2017-02-14 12:17:37 -08:00
Brandur
1c780e2b3f Working test suite! 2017-02-14 12:17:37 -08:00
Brandur
1886d9a625 Move to an alternative system based on StripeClient 2017-02-14 12:17:37 -08:00
Brandur
843ea88219 Add a StripeResponse to objects created by API calls 2017-02-14 12:17:37 -08:00
Brandur
4da4bd3ff3 Colocate uname helpers + tests
Colocates the helper methods for looking up a uname by renaming them to
have the same prefix as the base method (i.e. `get_uname`).

Also adds an additional rescue in case we try to run an executable on a
system but it wasn't founded (this should never happen).

Also adds some tests to make sure that each method gets at least a very
basic amount of exercise in the test suite.
2017-01-13 10:59:08 -08:00
Brandur
09c4885d31 Consolidate errors to one file + document them
Right now we have every error class in a separate file which doesn't do
anyone a lot of good, especially given that most of them are just stubs
that derive directly from `StripeError`.

This patch pulls them all into one file and gives them some
documentation. It follows #487 and #488 as minor refactoring work.
2017-01-13 10:28:10 -08:00
Brandur
da1b87f1c6 Alphabetize stripe.rb require list
Alphabetizes the list of named model requires in stripe.rb. This makes
it a little easier to spot things, and makes the correct spot to insert
a new model fully deterministic.

This continues along the path of #487 in introducing minor cleanups.
2017-01-13 10:06:32 -08:00
Brandur
83201e1a48 Alphabetize methods in lib/stripe.rb
This one is unfortunately a lot of churn, but it's incredibly
frustrating how difficult it is to find methods in this file.

Here we alphabetize the methods, but do nothing else. Alphabetization
only occurs within visibility blocks, so visibility is not affected at
all.
2017-01-13 09:58:29 -08:00
Brandur
7b9169712f Rename error class to be singular "permissions"
The addition of this class was unreleased so this is not a breaking
change.
2016-10-14 10:29:09 -07:00
Jack Flintermann
1806d9524c handle 403 status codes 2016-10-14 08:57:19 -04:00
Jacqueline
d2f783df34 Add support for multiplan subscriptions (#466)
* Add support for multiplan subscriptions:
Serialize indexed arrays into hashes with index keys in subscription create, subscription update, and upcoming invoice
Add a SubscriptionItem object that supports creation, deletion, update, listing, and retrieval

* Remove helpers that convert items array to indexed hash
2016-09-21 17:44:00 -07:00
Vijay Singh
35bbb7a26b Ruby bindings of ApplePayDomain 2016-09-14 18:16:12 -07:00
Brandur
6ebf6ad92a Whitelist retry exceptions
Right now we are retrying *most* non-HTTP exceptions. This is
problematic because in something like a test context, even a rogue name
error could initiate a retry. It's also bad for production because there
are quite a number of socket errors [1] for which we don't want to
retry.

Fixes #462.

[1] https://ruby-doc.org/stdlib-2.3.0/libdoc/socket/rdoc/Socket.html
2016-08-31 15:23:21 -07:00
Brandur
2a9413e155 Move away from rest-client's "symbol header names"
This moves away from rest-client's convention of using symbols as header
names so as to present less obfuscation as to how these are actually
named when they go over the wire.

Because headers can be injected via the bindings' API I was initially
worried that this change might break something, but upon inspection of
rest-client source, I can see now that headers take precedence as
assigned by their insertion order into the header hash, and are
"stringified" in that same loop [1]. This means that even if a user
injects a symbolized header name (`:idempotency_key`), it will still
correctly overwrite the one generated by stripe-ruby despite that using
the string format (`"Idempotency-Key"`).

[1] https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L603,L625
2016-08-25 11:42:44 -07:00
Will Bronitsky
4a6d70bf14 Add Source functionality 2016-07-28 17:25:06 -07:00
Olivier Bellone
be8c56458f Added support for 3D Secure 2016-07-12 17:01:33 +02:00
Brandur
ac49ef0b59 Remove hack to work around rest-client bug
This removes a hack in the code that's designed to work around a
rest-client bug which was added back in 2011. Unfortunately neither
comments nor commit messages bother to tell us what the nature of the
bug actually was, but based on what it's rescuing, it might be
rest-client/rest-client#58, which has been fixed for over five years
now.

Following up on the work done in #436, let's continue to try and simply
the error handling paths by taking this out.
2016-07-07 09:25:48 -07:00
Brandur
3984246514 Rework HTTP retry path + retry 409s
Two changes:

1. The HTTP retry path has been refactored to make retries on errors
that are not RestClient exceptions possible by bringing the logic up a
level. This also has the effect of somewhat simplifying the exception
handling logic which can be somewhat difficult to reason about right
now.

2. Retry on `RestClient::Conflict` (a 409 from the API) as discussed in
issue #431.

Fixes #431.
2016-07-05 12:37:39 -07:00
Brandur
774e885334 Clean up comments around exponential backoff 2016-06-30 10:44:08 -07:00
Kyle Conroy
732a494ac4 Add update class method to API resources (#426)
* Rename the `Update` operation to `Save`
* Add the `update` class method to all saveable resources
* Add tests for update method
* Add tests for plans, invoice items, and application fees
2016-06-29 14:13:42 -07:00
Rasmus Rygaard
dab45737c9 Add order returns. 2016-05-18 17:56:15 -07:00
Remi Jannel
2a6673a8e5 Support AlipayAccount retrieval and deletion 2016-05-17 17:52:00 -04:00
Edouard CHIN
75f366acb9 Allow stripe_account to be set globally:
- When performing requests on the behalf of a managed account, `stripe_account` option must be passed everytime, this can become redundant
- Allowing to set the `stripe_account` globally makes thing easier for wrapping every request in a single method, the same way as it is for defining the `api_key` globally
2016-04-13 20:40:55 +00:00