stripe 4.18.0 → 4.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -1
- data/.rubocop_todo.yml +3 -15
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +5 -3
- data/lib/stripe/account.rb +31 -17
- data/lib/stripe/alipay_account.rb +10 -3
- data/lib/stripe/api_operations/nested_resource.rb +12 -6
- data/lib/stripe/api_operations/request.rb +3 -7
- data/lib/stripe/api_operations/save.rb +1 -3
- data/lib/stripe/api_resource.rb +11 -3
- data/lib/stripe/application_fee.rb +2 -1
- data/lib/stripe/application_fee_refund.rb +11 -3
- data/lib/stripe/bank_account.rb +16 -4
- data/lib/stripe/bitcoin_receiver.rb +2 -1
- data/lib/stripe/capability.rb +10 -3
- data/lib/stripe/card.rb +16 -5
- data/lib/stripe/charge.rb +4 -6
- data/lib/stripe/customer.rb +5 -7
- data/lib/stripe/ephemeral_key.rb +4 -1
- data/lib/stripe/errors.rb +8 -8
- data/lib/stripe/invoice.rb +2 -1
- data/lib/stripe/list_object.rb +9 -4
- data/lib/stripe/login_link.rb +4 -1
- data/lib/stripe/order.rb +3 -5
- data/lib/stripe/person.rb +7 -2
- data/lib/stripe/reversal.rb +10 -3
- data/lib/stripe/singleton_api_resource.rb +3 -1
- data/lib/stripe/source.rb +4 -2
- data/lib/stripe/stripe_client.rb +84 -65
- data/lib/stripe/stripe_object.rb +50 -36
- data/lib/stripe/subscription.rb +1 -3
- data/lib/stripe/subscription_item.rb +2 -1
- data/lib/stripe/subscription_schedule_revision.rb +13 -4
- data/lib/stripe/tax_id.rb +7 -3
- data/lib/stripe/transfer.rb +2 -1
- data/lib/stripe/usage_record.rb +12 -3
- data/lib/stripe/util.rb +40 -24
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +4 -2
- data/stripe.gemspec +4 -2
- data/test/stripe/account_link_test.rb +1 -1
- data/test/stripe/account_test.rb +1 -1
- data/test/stripe/alipay_account_test.rb +1 -1
- data/test/stripe/api_operations_test.rb +1 -2
- data/test/stripe/api_resource_test.rb +5 -8
- data/test/stripe/apple_pay_domain_test.rb +1 -1
- data/test/stripe/application_fee_refund_test.rb +1 -1
- data/test/stripe/application_fee_test.rb +1 -1
- data/test/stripe/balance_test.rb +1 -1
- data/test/stripe/bank_account_test.rb +1 -1
- data/test/stripe/capability_test.rb +1 -1
- data/test/stripe/charge_test.rb +1 -1
- data/test/stripe/checkout/session_test.rb +1 -1
- data/test/stripe/country_spec_test.rb +1 -1
- data/test/stripe/coupon_test.rb +1 -1
- data/test/stripe/credit_note_test.rb +1 -1
- data/test/stripe/customer_card_test.rb +1 -1
- data/test/stripe/customer_test.rb +1 -1
- data/test/stripe/dispute_test.rb +1 -1
- data/test/stripe/ephemeral_key_test.rb +1 -1
- data/test/stripe/errors_test.rb +1 -1
- data/test/stripe/exchange_rate_test.rb +1 -1
- data/test/stripe/file_link_test.rb +1 -1
- data/test/stripe/file_test.rb +1 -1
- data/test/stripe/file_upload_test.rb +1 -1
- data/test/stripe/invoice_item_test.rb +1 -1
- data/test/stripe/invoice_line_item_test.rb +1 -1
- data/test/stripe/invoice_test.rb +1 -1
- data/test/stripe/issuer_fraud_record_test.rb +1 -1
- data/test/stripe/issuing/authorization_test.rb +1 -1
- data/test/stripe/issuing/card_test.rb +1 -1
- data/test/stripe/issuing/cardholder_test.rb +1 -1
- data/test/stripe/issuing/dispute_test.rb +1 -1
- data/test/stripe/issuing/transaction_test.rb +1 -1
- data/test/stripe/list_object_test.rb +1 -1
- data/test/stripe/login_link_test.rb +1 -1
- data/test/stripe/oauth_test.rb +1 -1
- data/test/stripe/order_return_test.rb +1 -1
- data/test/stripe/order_test.rb +8 -1
- data/test/stripe/payment_intent_test.rb +1 -1
- data/test/stripe/payment_method_test.rb +1 -1
- data/test/stripe/payout_test.rb +1 -1
- data/test/stripe/person_test.rb +1 -1
- data/test/stripe/plan_test.rb +1 -1
- data/test/stripe/product_test.rb +1 -1
- data/test/stripe/radar/early_fraud_warning_test.rb +1 -1
- data/test/stripe/radar/value_list_item_test.rb +1 -1
- data/test/stripe/radar/value_list_test.rb +1 -1
- data/test/stripe/recipient_test.rb +1 -1
- data/test/stripe/refund_test.rb +1 -1
- data/test/stripe/reporting/report_run_test.rb +1 -1
- data/test/stripe/reporting/report_type_test.rb +1 -1
- data/test/stripe/reversal_test.rb +1 -1
- data/test/stripe/review_test.rb +1 -1
- data/test/stripe/sigma/scheduled_query_run_test.rb +1 -1
- data/test/stripe/sku_test.rb +1 -1
- data/test/stripe/source_test.rb +1 -1
- data/test/stripe/source_transaction_test.rb +1 -1
- data/test/stripe/stripe_client_test.rb +1 -1
- data/test/stripe/stripe_object_test.rb +1 -1
- data/test/stripe/stripe_response_test.rb +1 -1
- data/test/stripe/subscription_item_test.rb +1 -1
- data/test/stripe/subscription_schedule_revision_test.rb +1 -1
- data/test/stripe/subscription_schedule_test.rb +1 -1
- data/test/stripe/subscription_test.rb +1 -1
- data/test/stripe/tax_id_test.rb +1 -1
- data/test/stripe/tax_rate_test.rb +1 -1
- data/test/stripe/terminal/connection_token_test.rb +1 -1
- data/test/stripe/terminal/location_test.rb +1 -1
- data/test/stripe/terminal/reader_test.rb +1 -1
- data/test/stripe/three_d_secure_test.rb +1 -1
- data/test/stripe/topup_test.rb +1 -1
- data/test/stripe/transfer_test.rb +1 -1
- data/test/stripe/usage_record_summary_test.rb +1 -1
- data/test/stripe/usage_record_test.rb +1 -1
- data/test/stripe/util_test.rb +1 -1
- data/test/stripe/webhook_endpoint_test.rb +1 -1
- data/test/stripe/webhook_test.rb +2 -2
- data/test/stripe_test.rb +1 -1
- data/test/test_helper.rb +4 -6
- metadata +2 -2
data/lib/stripe/version.rb
CHANGED
data/lib/stripe/webhook.rb
CHANGED
@@ -8,7 +8,8 @@ module Stripe
|
|
8
8
|
#
|
9
9
|
# This may raise JSON::ParserError if the payload is not valid JSON, or
|
10
10
|
# SignatureVerificationError if the signature verification fails.
|
11
|
-
def self.construct_event(payload, sig_header, secret,
|
11
|
+
def self.construct_event(payload, sig_header, secret,
|
12
|
+
tolerance: DEFAULT_TOLERANCE)
|
12
13
|
Signature.verify_header(payload, sig_header, secret, tolerance: tolerance)
|
13
14
|
|
14
15
|
# It's a good idea to parse the payload only after verifying it. We use
|
@@ -50,7 +51,8 @@ module Stripe
|
|
50
51
|
# Returns true otherwise
|
51
52
|
def self.verify_header(payload, header, secret, tolerance: nil)
|
52
53
|
begin
|
53
|
-
timestamp, signatures =
|
54
|
+
timestamp, signatures =
|
55
|
+
get_timestamp_and_signatures(header, EXPECTED_SCHEME)
|
54
56
|
rescue StandardError
|
55
57
|
raise SignatureVerificationError.new(
|
56
58
|
"Unable to extract timestamp and signatures from header",
|
data/stripe.gemspec
CHANGED
@@ -9,7 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.version = Stripe::VERSION
|
10
10
|
s.required_ruby_version = ">= 2.1.0"
|
11
11
|
s.summary = "Ruby bindings for the Stripe API"
|
12
|
-
s.description = "Stripe is the easiest way to accept payments online.
|
12
|
+
s.description = "Stripe is the easiest way to accept payments online. " \
|
13
|
+
"See https://stripe.com for details."
|
13
14
|
s.author = "Stripe"
|
14
15
|
s.email = "support@stripe.com"
|
15
16
|
s.homepage = "https://stripe.com/docs/api/ruby"
|
@@ -20,6 +21,7 @@ Gem::Specification.new do |s|
|
|
20
21
|
|
21
22
|
s.files = `git ls-files`.split("\n")
|
22
23
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
23
|
-
s.executables = `git ls-files -- bin/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n")
|
25
|
+
.map { |f| ::File.basename(f) }
|
24
26
|
s.require_paths = ["lib"]
|
25
27
|
end
|
data/test/stripe/account_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require ::File.expand_path("
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
5
4
|
|
6
5
|
module Stripe
|
7
6
|
class ApiResourceTest < Test::Unit::TestCase
|
@@ -491,7 +490,7 @@ module Stripe
|
|
491
490
|
end
|
492
491
|
end
|
493
492
|
|
494
|
-
@@fixtures = {}
|
493
|
+
@@fixtures = {} # rubocop:disable Style/ClassVars
|
495
494
|
setup do
|
496
495
|
if @@fixtures.empty?
|
497
496
|
cache_fixture(:charge) do
|
@@ -503,19 +502,17 @@ module Stripe
|
|
503
502
|
end
|
504
503
|
end
|
505
504
|
|
506
|
-
private
|
507
|
-
|
508
|
-
def charge_fixture
|
505
|
+
private def charge_fixture
|
509
506
|
@@fixtures[:charge]
|
510
507
|
end
|
511
508
|
|
512
|
-
def customer_fixture
|
509
|
+
private def customer_fixture
|
513
510
|
@@fixtures[:customer]
|
514
511
|
end
|
515
512
|
|
516
513
|
# Expects to retrieve a fixture from stripe-mock (an API call should be
|
517
514
|
# included in the block to yield to) and does very simple memoization.
|
518
|
-
def cache_fixture(key)
|
515
|
+
private def cache_fixture(key)
|
519
516
|
return @@fixtures[key] if @@fixtures.key?(key)
|
520
517
|
|
521
518
|
obj = yield
|
data/test/stripe/balance_test.rb
CHANGED
data/test/stripe/charge_test.rb
CHANGED
data/test/stripe/coupon_test.rb
CHANGED
data/test/stripe/dispute_test.rb
CHANGED
data/test/stripe/errors_test.rb
CHANGED
data/test/stripe/file_test.rb
CHANGED
data/test/stripe/invoice_test.rb
CHANGED
data/test/stripe/oauth_test.rb
CHANGED
data/test/stripe/order_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require ::File.expand_path("
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
4
4
|
|
5
5
|
module Stripe
|
6
6
|
class OrderTest < Test::Unit::TestCase
|
@@ -45,6 +45,13 @@ module Stripe
|
|
45
45
|
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{order.id}/pay"
|
46
46
|
assert order.is_a?(Stripe::Order)
|
47
47
|
end
|
48
|
+
|
49
|
+
should "pay an order without additional arguments" do
|
50
|
+
order = Stripe::Order.retrieve("or_123")
|
51
|
+
order = order.pay
|
52
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{order.id}/pay"
|
53
|
+
assert order.is_a?(Stripe::Order)
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
57
|
context ".pay" do
|