1068 Commits

Author SHA1 Message Date
Olivier Bellone
de21302f4e
Encode arrays as hashes when needed 2017-10-14 17:48:20 +02:00
Brandur
f628a1eff5 Convert stripe-dotnet links to stripe-ruby (fixes bad copy + paste)
While converting this changelog over, I improperly added links that were
copied from stripe-dotnet. The numbers were right, but the links was
wrong because it was going to the wrong project. This patch corrects all
those bad links.
2017-10-13 10:34:09 -07:00
Brandur
c59c3661c6 Bump version to 3.5.2 v3.5.2 2017-10-13 10:33:30 -07:00
Brandur
1c1e58a6eb Merge pull request #593 from stripe/brandur-changelog
Convert History.txt to CHANGELOG.md
2017-10-13 10:00:28 -07:00
Brandur
f543771003 Merge pull request #592 from stripe/brandur-reimplement-custom-marshal
Implement custom Marshal encoder/decoder for `StripeObject`
2017-10-13 09:52:45 -07:00
Brandur
72e1a14552 Comment out Vim hint 2017-10-13 09:45:42 -07:00
Brandur
a05f59edf2 Convert History.txt to CHANGELOG.md
Converts `History.txt` to a Markdown-based changelog in the same style
as the one established in stripe-dotnet [1].

We leave `History.txt` in place with a reference to the new file so that
existing links will not be broken.

[1] https://github.com/stripe/stripe-dotnet/pull/1026
2017-10-13 09:42:41 -07:00
Brandur
91099f9ee5 Implement custom Marshal encoder/decoder for StripeObject
Backtracks a little bit #586 by bringing back custom `StripeObject`
encoding and decoding methods for Ruby's `Marshal`. These work by just
persisting values and some opts, and skipping everything else. It's
mostly the same as what we had before, but implemented a little more
cleanly so that we don't actually need to invoke `Marshal` anywhere
ourselves.

In #586 we still managed to remove all the uses of `Marshal` in our own
codebase to make the linter happy. Even though we wouldn't recommend the
use of `Marshal`, this code at least enables it for anyone using a Rails
cache or similar mechanism.

Addresses #90.
2017-10-13 09:31:08 -07:00
Brandur
2a0df29bf4 Bump version to 3.5.1 v3.5.1 2017-10-12 10:20:24 -07:00
Brandur
d41a59fc82 Merge pull request #591 from stripe/ob-fix-590
Ensure that each thread has its own client
2017-10-12 09:59:22 -07:00
Olivier Bellone
a210c5cd76
Ensure that each thread has its own client 2017-10-12 18:20:13 +02:00
Brandur
a579368c17 Improve latest change description in changelog 2017-10-11 09:42:29 -07:00
Brandur
283e611a88 Fix typo in changelog ("fromm") 2017-10-11 09:31:08 -07:00
Brandur
c251dfa952 Bump version to 3.5.0 v3.5.0 2017-10-11 09:30:35 -07:00
Brandur
a0a9c7cf22 Merge pull request #589 from stripe/ob-detach-sources
detach method for detaching sources from customers
2017-10-11 09:29:25 -07:00
Olivier Bellone
92e216634c
detach method for detaching sources from customers 2017-10-11 11:15:38 +02:00
Brandur
6bd1d6b9a0 Bump version to 3.4.1 v3.4.1 2017-10-05 09:56:33 -07:00
Brandur
e4725b8006 Merge pull request #588 from stripe/ob-fix-576
Require Faraday 0.10 for proper nested array encoding
2017-10-05 09:47:44 -07:00
Olivier Bellone
cd7e607258
Require Faraday 0.10 for proper nested array encoding 2017-10-05 17:56:39 +02:00
Brandur
9099b5d24d Merge pull request #587 from stripe/brandur-log-query-string
Log query string as well as body on log debug
2017-10-05 08:41:20 -07:00
Brandur
8ea866616b Log query string as well as body on log debug
This patch modifies the debugging-level logging logic slightly so that
if it's a `GET` request that includes a query string, we log that string
just like we would've for a request body on a `POST` or like.

This especially comes in handy when looking when trying to resolve
something like a problem with the upcoming invoices endpoint like we saw
in #576, but will be useful in a number of situations.
2017-10-04 13:00:35 -07:00
Brandur
3f454495bf Merge pull request #586 from stripe/brandur-remove-marshal
Implement deep copy for StripeObject and remove marshal/unmarshal
2017-09-29 07:13:32 -07:00
Brandur
212a2052a4 Merge pull request #585 from stripe/brandur-guard-clause
Remove Rubocop TODO around guard clauses
2017-09-29 02:15:37 -07:00
Brandur
80d85a522c Implement deep copy for StripeObject and remove marshal/unmarshal
We were previously using a bit of a hack to get a free deep copy
implementation through Ruby's marshaling framework. Lint call this out
as a security problem though, and rightfully so: when combined with
unsanitized user input, unmarshaling can result in very serious security
breaches involving arbitrary code execution.

This patch removes all uses of marshal/unmarshal in favor of
implementing a deep copy method for `StripeObject`. I also reworked some
of the constants around what keys are available for `opts`. I'm still
not completely happy with the results, but I think it's going to need a
slightly larger refactor in order to get somewhere truly good.

There is what could be a breaking change for people doing non-standard
stuff with the library: the opts that we copy with an object are now
whitelisted, so if they were being used to pass around extraneous data,
that might not work as expected anymore. But because this is a contract
that we never committed to, I don't think I'd bump the major version for
change.
2017-09-28 11:02:20 -07:00
Brandur
cb198baaa3 Remove Rubocop TODO around guard clauses
Removes Rubocop TODO around guard clauses and fixes the outstanding
offenses.

This is starting to get into territory that feels of more dubious value
to me, but at least it did get me writing a couple more tests, so let's
see how it goes by keeping this on.
2017-09-28 09:32:44 -07:00
Brandur
45101b7b0d Merge pull request #584 from stripe/brandur-rubocop-fixes
Fix low hanging Rubocop TODOs
2017-09-28 09:16:31 -07: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
Brandur
f8e28baf6b Merge pull request #583 from stripe/brandur-pin-rubocop
Pin Rubocop dependency in `Gemfile`
2017-09-27 13:41:13 -07:00
Brandur
867bf9c4e0 Pin Rubocop dependency in Gemfile
Because we're a library, our `Gemfile.lock` is in `.gitinore` (see [1]).
This means that you'd be otherwise be vulnerable to the whims of
whatever version of Rubocop is installed on the local system.

Because Rubocop changes fairly quickly and those changes tend to lead to
either errors or warnings on its runs, lock the gem to a particular
version in our `Gemfile`. We should try to keep the locked version
relatively current.

[1] http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
2017-09-27 13:07:50 -07:00
Brandur
234b0809bf Merge pull request #575 from stripe/ob-rubocop
Start using RuboCop for linting
2017-09-27 12:41:52 -07:00
Olivier Bellone
e02ff7f849
Start using RuboCop for linting 2017-09-27 21:28:25 +02:00
Brandur
56a07b1986 Merge pull request #582 from stripe/brandur-upgrade-mock-020
Upgrade stripe-mock to 0.2.0
2017-09-22 12:10:03 -07:00
Brandur
ed6d7a7cf9 Upgrade stripe-mock to 0.2.0
This pulls us onto the new version of stripe-mock which should be
checking parameters more accurately now that it's on OpenAPI 3.0.
2017-09-22 12:01:30 -07:00
tmaxwell-stripe
ebeded507d Merge pull request #580 from stripe/tmaxwell/remove-outdated-tests 2017-09-20 14:58:03 -07:00
Tim Maxwell
f4412eec1b Work around idiosyncrasies of stripe-mock 2017-09-20 14:11:11 -07:00
Tim Maxwell
0b4ac62eae Remove recipient card tests 2017-09-20 14:03:00 -07:00
Tim Maxwell
d12fcdb862 Remove tests for legacy Bitcoin API 2017-09-20 13:48:05 -07:00
Brandur
ab1c971e8d Bump version to 3.3.2 v3.3.2 2017-09-20 12:17:40 -07:00
Brandur
36c2ed58ad Merge pull request #579 from garethrees/patch-1
Add correct required_ruby_version
2017-09-20 12:16:57 -07:00
Gareth Rees
bc3abe663f Add correct required_ruby_version
The `stripe` gem installs on 1.9.3, but is unusable due to the use of keyword args.

    vagrant@vagrant-ubuntu-trusty-64: ~
    $ ruby -v
    ruby 1.9.3p551 (2014-11-13) [x86_64-linux] Brightbox

    vagrant@vagrant-ubuntu-trusty-64: ~
    $ sudo gem install stripe
    Fetching: multipart-post-2.0.0.gem (100%)
    Fetching: faraday-0.13.1.gem (100%)
    Fetching: stripe-3.3.1.gem (100%)
    Successfully installed multipart-post-2.0.0
    Successfully installed faraday-0.13.1
    Successfully installed stripe-3.3.1
    3 gems installed

    vagrant@vagrant-ubuntu-trusty-64: ~
    $ irb
    irb(main):001:0> require 'stripe'
    SyntaxError: /var/lib/gems/1.9.1/gems/stripe-3.3.1/lib/stripe.rb:207: syntax error, unexpected tLABEL
      def self.set_app_info(name, version: nil, url: nil)
                                          ^
    /var/lib/gems/1.9.1/gems/stripe-3.3.1/lib/stripe.rb:207: Can't assign to nil
      def self.set_app_info(name, version: nil, url: nil)
                                               ^
    /var/lib/gems/1.9.1/gems/stripe-3.3.1/lib/stripe.rb:225: syntax error, unexpected keyword_end, expecting $end
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
            from (irb):1
            from /usr/bin/irb:12:in `<main>'
2017-09-20 19:43:55 +01:00
Brandur
465da7a997 Bump version to 3.3.1 v3.3.1 2017-08-18 10:15:11 -07:00
Brandur
aa5ef2f7ff Add comment so the post-verify parse change doesn't regress 2017-08-18 10:13:54 -07:00
Brandur
a19dfed759 Merge pull request #572 from timcraft/webhook
Parse webhook payload after verifying the signature header
2017-08-18 10:11:51 -07:00
Tim Craft
4739ece7b0 Parse webhook payload after verifying the signature header 2017-08-18 11:17:57 +01:00
Brandur
8e897a43b5 Bump version to 3.3.0 v3.3.0 2017-08-11 15:02:09 -07:00
Brandur
92d28b38cd Merge pull request #570 from stripe/brandur-support-logger
Add support for setting a logger
2017-08-11 14:59:13 -07: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
20ec883e8b Bump version to 3.2.0 v3.2.0 2017-08-03 14:09:33 -07:00
Brandur
c0bccc8c23 Merge pull request #568 from stripe/brandur-log-stripe-account
Log `Stripe-Account` values with `STRIPE_LOG`
2017-08-03 14:08:55 -07:00