376 Commits

Author SHA1 Message Date
Brandur
d71cda7adf Better error message when passing non-string to custom method
Raises a slightly more helpful error message when passing a non-string
to a custom method (currently, it reads "no implicit conversion of Hash
into String", which is terrible).

This a partial remediation for the problem encountered in #809.
2019-07-15 16:38:05 -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
mbianco-stripe
41538b3970 Order#pay without arguments (#789)
* Don't require params in order.pay

* Test for order#pay without arguments
2019-05-27 17:36:43 -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
f68fb25b83
Add support for radar.early_fraud_warning resource (#783) 2019-05-23 17:40:54 -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
Pavel Pravosud
cd05d363f8 More simplifying inheritance (#775) 2019-05-06 17:34:23 -07:00
Remi Jannel
962538b149 Add support for TaxRate resource and APIs 2019-04-23 09:56:03 -07:00
Remi Jannel
b5cd9e3682 Add support for TaxId resource and APIs 2019-04-19 10:13:57 -07:00
remi-stripe
06498dbe14
Merge pull request #758 from stripe/remi-add-creditnote
Add support for CreditNote
2019-04-18 12:24:05 -07:00
Brandur
81b7cb3ca8 Relax constraints on objects that we'll accept as a file
When uploading a file, we previously made a check on whether it
supported both `#read` and `#path` before wrapping it in a
`Faraday::UploadIO` and sending it off. The second check on `#path`
isn't strictly necessary, and as reported in #761 can prevent objects
created by `open-uri` from being compatible with file upload.

Here we remove the check `#path` so that we just require that objects
support `#read`, and in addition error when an object is passed that's
not file-compatible and not a string. This should prevent users from
seeing the very confusing "Invalid hash" error in these situations.

Fixes #761.
2019-04-16 08:33:42 -07:00
Remi Jannel
5aa63d2cc6 Move tests for nested resources up to the parent class 2019-04-12 19:23:52 -07:00
Remi Jannel
0233deb5c6 Add support for CreditNote 2019-04-07 09:47:43 -07:00
remi-stripe
c3e65b2552 Fix our test suite for latest stripe-mock (#757) 2019-04-05 21:11:24 -07:00
Olivier Bellone
81035d401f
Include file_link_data parameter in file creation test (#756) 2019-04-05 14:43:52 -07:00
Olivier Bellone
0790bb4154
Static methods for delete (#752)
New `.delete` class method on deletable API resources
2019-04-02 10:25:05 -07:00
Olivier Bellone
160028ada1
New custom_method DSL for defining custom API request methods as static methods (#754)
New `custom_method` DSL for defining custom API request methods as static methods
2019-04-02 10:06:40 -07:00
Olivier Bellone
6e95bf45f9 Add a global proxy configuration parameter 2019-03-25 18:34:12 -07:00
remi-stripe
39d66c00ce
Merge pull request #745 from stripe/remi-add-payment-methods
Add support for the PaymentMethod resource
2019-03-18 16:42:53 -07:00
remi-stripe
7b9b7b6aab
Merge pull request #748 from stripe/remi-add-terminal-delete
Add support for Terminal Location and Reader deletion
2019-03-18 16:41:08 -07:00
Remi Jannel
f93c0075c0 Add support for the PaymentMethod resource 2019-03-18 16:30:51 -07:00
Remi Jannel
de204dda1c Add support for retrieving a Checkout Session 2019-03-18 16:29:04 -07:00
Remi Jannel
031075c954 Add support for Terminal Location and Reader deletion 2019-03-18 16:28:24 -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-stripe
7af2826ad1
Merge pull request #739 from stripe/remi-add-subscription-schedules
Add support for Subscription Schedules
2019-02-12 08:51:47 -08:00
Remi Jannel
d784819901 Add support for Subscription Schedules 2019-02-11 22:38:08 -08:00
Brandur
cf6d79a1ca Remove attempt to nicen UploadIO in logs
In #741 I tried to do something too clever by replacing instances of
`Faraday::UploadIO` found in parameters with a human-readable string to
improve `STRIPE_LOG` logging output.

I thought I'd tested it at the time, but apparently not (or not well
enough), and this change caused the regression detailed in #742.

My findings about how Faraday encodes multipart were apparently wrong
and it does use these parameters, so here we remove the step where we
try to nicen them for logging. The logs look a little worse, but it's
not that big of a deal.

I've tested this patch against the API and confirmed that it addresses
the problem.

Fixes #742.
2019-02-11 11:14:27 -08:00
Brandur
9dd5bdb0e6 Use FaradayStripeEncoder to encode all parameter styles
Makes a few tweaks to hopefully simplify clarity things:

* `FaradayStripeEncoder` now becomes the way to encode all of form,
  multipart form, and query parameters.
* Introduce a cache in it so that we don't have to encode everything
  twice (once for logging, and once for the request body).
* Try to sanitize logging a bit by replacing `Faraday::UploadIO`s found
  in incoming parameters with a string representation of the file (note
  that all other styles of file input like `File` or `Tempfile` have
  been converted to `Faraday::UploadIO` by the time they reach the
  encoder).
2019-02-03 12:24:53 -08:00
Brandur
07f939b46b Fix query encoding for integer-indexed maps
As reported in #608, integer-indexed maps currently work when passed as
part of the body, but they are reverted to non-indexed maps when passed
in the query.

It turns out that we actually had two problems:

1. We weren't calling our `Util.encode_parameters` on our query
   parameters anywhere, and it's this method will does the integer
   encoding.

2. Even when I fixed (1) by calling `Util.encode_parameters`, Faraday
   would still strip the integer indexes as they were transformed in
   its default `NestedParamsEncoder`.

Here we fix both issues by calling `Util.encode_parameters` and sending
Faraday a custom encoder which bypasses its normal shenanigans.

Unfortunately, this has turned out to be somewhat difficult to test
because the integer-indexed maps also seem to confuse Webmock, which
strips them down to standard maps (I even tried testing against a
string, and it still got it wrong). I did use stripe-mock though to
verify that we are now sending the right payload.

Fixes #608.
2019-02-01 09:14:54 -08:00
remi-stripe
3366cacd6a
Merge pull request #735 from stripe/remi-fix-checkout-sessions
Move CheckoutSession to the Checkout namespace and rename to Session
2019-01-23 15:40:26 -08:00
Olivier Bellone
6b89b3b6c1
Properly serialize individual on Account objects 2019-01-18 15:31:47 +01:00
Remi Jannel
359a0c9cdf Move CheckoutSession to the Checkout namespace and rename to Session 2019-01-16 18:50:14 -08:00
Olivier Bellone
fe4e21c8db
Remove to_hash method on NilClass after test 2019-01-04 17:34:51 +01:00
Brandur
403be3b106 Generate OAuth authorize URLs for express accounts
Connect with Express accounts uses a slightly different version of the
OAuth authorize URL [1] in that it's prefixed with `/express`.

Here we add a new option to `Stripe::OAuth.authorize_url` which allows
`express: true` to be passed in to generate the Express variant.

Note that the token endpoint has no equivalent so we don't need the
option there.

Fixes #717.

[1] https://stripe.com/docs/connect/oauth-reference#express-account-differences
2018-12-31 13:47:35 -07:00
Kazuhiro Sera
4081d8c5ed Fix typo/misspell in comments & error messages 2018-12-31 15:26:56 +09: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
Anton Kropp
5e3c3a9b45
Making stripe telemetry more specific in terms of units 2018-11-12 16:35:21 -08:00
Anton Kropp
ab248ec691
Adding metadata header to client requests 2018-11-12 10:24:06 -08:00
Remi Jannel
bbec79ccba Add new methods to the Invoice resource 2018-11-08 17:28:55 -08:00
Remi Jannel
da9d15df95 Add support for the Webhook Endpoint resource 2018-10-30 10:36:10 -07:00
Remi Jannel
23d94005d3 Add support for the Person resource 2018-10-30 10:25:10 -07:00
David Zhu
cd5e3a7077 Linting issues 2018-09-24 13:50:06 -07:00
David Zhu
b3055bfd44 Terminal Bindings 2018-09-24 13:43:32 -07:00