stripe 4.10.0 → 5.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +316 -1
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +10 -14
- data/Makefile +7 -0
- data/README.md +186 -62
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +28 -2
- data/lib/stripe/api_operations/list.rb +1 -12
- data/lib/stripe/api_operations/nested_resource.rb +38 -28
- data/lib/stripe/api_operations/request.rb +81 -9
- data/lib/stripe/api_operations/save.rb +8 -7
- data/lib/stripe/api_operations/search.rb +19 -0
- data/lib/stripe/api_resource.rb +45 -3
- data/lib/stripe/api_resource_test_helpers.rb +47 -0
- data/lib/stripe/connection_manager.rb +200 -0
- data/lib/stripe/error_object.rb +93 -0
- data/lib/stripe/errors.rb +31 -10
- data/lib/stripe/instrumentation.rb +84 -0
- data/lib/stripe/list_object.rb +41 -7
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/oauth.rb +8 -6
- data/lib/stripe/object_types.rb +119 -0
- data/lib/stripe/{account.rb → resources/account.rb} +48 -30
- data/lib/stripe/{account_link.rb → resources/account_link.rb} +2 -1
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +2 -1
- data/lib/stripe/resources/application_fee.rb +14 -0
- data/lib/stripe/resources/application_fee_refund.rb +31 -0
- data/lib/stripe/{balance.rb → resources/balance.rb} +2 -1
- data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +2 -5
- data/lib/stripe/resources/bank_account.rb +43 -0
- data/lib/stripe/{issuing/dispute.rb → resources/billing_portal/configuration.rb} +4 -3
- data/lib/stripe/resources/billing_portal/session.rb +12 -0
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +4 -3
- data/lib/stripe/resources/bitcoin_transaction.rb +16 -0
- data/lib/stripe/resources/capability.rb +34 -0
- data/lib/stripe/{card.rb → resources/card.rb} +13 -4
- data/lib/stripe/resources/cash_balance.rb +22 -0
- data/lib/stripe/resources/charge.rb +32 -0
- data/lib/stripe/resources/checkout/session.rb +27 -0
- data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +2 -1
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +3 -2
- data/lib/stripe/resources/credit_note.rb +33 -0
- data/lib/stripe/resources/credit_note_line_item.rb +8 -0
- data/lib/stripe/resources/customer.rb +74 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +31 -0
- data/lib/stripe/resources/discount.rb +8 -0
- data/lib/stripe/resources/dispute.rb +22 -0
- data/lib/stripe/{ephemeral_key.rb → resources/ephemeral_key.rb} +6 -2
- data/lib/stripe/{event.rb → resources/event.rb} +2 -1
- data/lib/stripe/{exchange_rate.rb → resources/exchange_rate.rb} +2 -1
- data/lib/stripe/resources/file.rb +36 -0
- data/lib/stripe/{file_link.rb → resources/file_link.rb} +3 -2
- data/lib/stripe/resources/financial_connections/account.rb +31 -0
- data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
- data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
- data/lib/stripe/resources/financial_connections/session.rb +12 -0
- data/lib/stripe/resources/funding_instructions.rb +16 -0
- data/lib/stripe/resources/identity/verification_report.rb +12 -0
- data/lib/stripe/resources/identity/verification_session.rb +35 -0
- data/lib/stripe/resources/invoice.rb +83 -0
- data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +3 -2
- data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +2 -1
- data/lib/stripe/resources/issuing/authorization.rb +34 -0
- data/lib/stripe/resources/issuing/card.rb +25 -0
- data/lib/stripe/resources/issuing/card_details.rb +10 -0
- data/lib/stripe/{issuing → resources/issuing}/cardholder.rb +3 -2
- data/lib/stripe/resources/issuing/dispute.rb +25 -0
- data/lib/stripe/{issuing → resources/issuing}/transaction.rb +3 -2
- data/lib/stripe/resources/line_item.rb +8 -0
- data/lib/stripe/resources/login_link.rb +15 -0
- data/lib/stripe/resources/mandate.rb +8 -0
- data/lib/stripe/resources/order.rb +33 -0
- data/lib/stripe/{order_return.rb → resources/order_return.rb} +2 -1
- data/lib/stripe/resources/payment_intent.rb +82 -0
- data/lib/stripe/resources/payment_link.rb +23 -0
- data/lib/stripe/resources/payment_method.rb +33 -0
- data/lib/stripe/resources/payout.rb +33 -0
- data/lib/stripe/{person.rb → resources/person.rb} +9 -3
- data/lib/stripe/{plan.rb → resources/plan.rb} +2 -1
- data/lib/stripe/resources/price.rb +21 -0
- data/lib/stripe/resources/product.rb +22 -0
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/quote.rb +105 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +12 -0
- data/lib/stripe/{radar → resources/radar}/value_list.rb +3 -2
- data/lib/stripe/{radar → resources/radar}/value_list_item.rb +3 -2
- data/lib/stripe/{recipient.rb → resources/recipient.rb} +3 -6
- data/lib/stripe/{recipient_transfer.rb → resources/recipient_transfer.rb} +1 -1
- data/lib/stripe/resources/refund.rb +42 -0
- data/lib/stripe/{reporting → resources/reporting}/report_run.rb +3 -2
- data/lib/stripe/{reporting → resources/reporting}/report_type.rb +3 -2
- data/lib/stripe/resources/reversal.rb +30 -0
- data/lib/stripe/resources/review.rb +21 -0
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +43 -0
- data/lib/stripe/{product.rb → resources/shipping_rate.rb} +4 -4
- data/lib/stripe/{sigma → resources/sigma}/scheduled_query_run.rb +3 -2
- data/lib/stripe/{sku.rb → resources/sku.rb} +4 -3
- data/lib/stripe/resources/source.rb +47 -0
- data/lib/stripe/{source_transaction.rb → resources/source_transaction.rb} +2 -1
- data/lib/stripe/resources/subscription.rb +35 -0
- data/lib/stripe/resources/subscription_item.rb +26 -0
- data/lib/stripe/resources/subscription_schedule.rb +33 -0
- data/lib/stripe/resources/tax_code.rb +10 -0
- data/lib/stripe/resources/tax_id.rb +27 -0
- data/lib/stripe/{refund.rb → resources/tax_rate.rb} +3 -2
- data/lib/stripe/{terminal/reader.rb → resources/terminal/configuration.rb} +3 -2
- data/lib/stripe/resources/terminal/connection_token.rb +12 -0
- data/lib/stripe/{terminal → resources/terminal}/location.rb +3 -2
- data/lib/stripe/resources/terminal/reader.rb +75 -0
- data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
- data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +2 -1
- data/lib/stripe/{token.rb → resources/token.rb} +2 -1
- data/lib/stripe/resources/topup.rb +23 -0
- data/lib/stripe/resources/transfer.rb +27 -0
- data/lib/stripe/resources/usage_record.rb +8 -0
- data/lib/stripe/{usage_record_summary.rb → resources/usage_record_summary.rb} +2 -1
- data/lib/stripe/{webhook_endpoint.rb → resources/webhook_endpoint.rb} +3 -2
- data/lib/stripe/resources.rb +100 -0
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/singleton_api_resource.rb +3 -1
- data/lib/stripe/stripe_client.rb +661 -266
- data/lib/stripe/stripe_configuration.rb +194 -0
- data/lib/stripe/stripe_object.rb +80 -61
- data/lib/stripe/stripe_response.rb +87 -27
- data/lib/stripe/util.rb +128 -117
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +43 -10
- data/lib/stripe.rb +46 -197
- data/stripe.gemspec +24 -8
- metadata +123 -283
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -8
- data/.rubocop.yml +0 -32
- data/.rubocop_todo.yml +0 -50
- data/.travis.yml +0 -42
- data/lib/stripe/alipay_account.rb +0 -27
- data/lib/stripe/application_fee.rb +0 -23
- data/lib/stripe/application_fee_refund.rb +0 -22
- data/lib/stripe/bank_account.rb +0 -32
- data/lib/stripe/bitcoin_transaction.rb +0 -15
- data/lib/stripe/charge.rb +0 -84
- data/lib/stripe/checkout/session.rb +0 -11
- data/lib/stripe/customer.rb +0 -90
- data/lib/stripe/dispute.rb +0 -19
- data/lib/stripe/file.rb +0 -37
- data/lib/stripe/invoice.rb +0 -48
- data/lib/stripe/issuer_fraud_record.rb +0 -9
- data/lib/stripe/issuing/authorization.rb +0 -22
- data/lib/stripe/issuing/card.rb +0 -18
- data/lib/stripe/issuing/card_details.rb +0 -9
- data/lib/stripe/login_link.rb +0 -11
- data/lib/stripe/order.rb +0 -31
- data/lib/stripe/payment_intent.rb +0 -26
- data/lib/stripe/payment_method.rb +0 -23
- data/lib/stripe/payout.rb +0 -20
- data/lib/stripe/reversal.rb +0 -22
- data/lib/stripe/review.rb +0 -14
- data/lib/stripe/source.rb +0 -38
- data/lib/stripe/subscription.rb +0 -25
- data/lib/stripe/subscription_item.rb +0 -17
- data/lib/stripe/subscription_schedule.rb +0 -32
- data/lib/stripe/subscription_schedule_revision.rb +0 -25
- data/lib/stripe/terminal/connection_token.rb +0 -11
- data/lib/stripe/topup.rb +0 -16
- data/lib/stripe/transfer.rb +0 -23
- data/lib/stripe/usage_record.rb +0 -14
- data/test/api_stub_helpers.rb +0 -1
- data/test/openapi/README.md +0 -9
- data/test/stripe/account_external_accounts_operations_test.rb +0 -69
- data/test/stripe/account_link_test.rb +0 -18
- data/test/stripe/account_login_links_operations_test.rb +0 -21
- data/test/stripe/account_persons_operations_test.rb +0 -70
- data/test/stripe/account_test.rb +0 -256
- data/test/stripe/alipay_account_test.rb +0 -37
- data/test/stripe/api_operations_test.rb +0 -81
- data/test/stripe/api_resource_test.rb +0 -526
- data/test/stripe/apple_pay_domain_test.rb +0 -33
- data/test/stripe/application_fee_refund_test.rb +0 -37
- data/test/stripe/application_fee_refunds_operations_test.rb +0 -56
- data/test/stripe/application_fee_test.rb +0 -14
- data/test/stripe/balance_test.rb +0 -13
- data/test/stripe/bank_account_test.rb +0 -36
- data/test/stripe/charge_test.rb +0 -59
- data/test/stripe/checkout/session_test.rb +0 -41
- data/test/stripe/country_spec_test.rb +0 -20
- data/test/stripe/coupon_test.rb +0 -51
- data/test/stripe/customer_card_test.rb +0 -42
- data/test/stripe/customer_sources_operations_test.rb +0 -64
- data/test/stripe/customer_test.rb +0 -115
- data/test/stripe/dispute_test.rb +0 -42
- data/test/stripe/ephemeral_key_test.rb +0 -86
- data/test/stripe/errors_test.rb +0 -20
- data/test/stripe/exchange_rate_test.rb +0 -20
- data/test/stripe/file_link_test.rb +0 -41
- data/test/stripe/file_test.rb +0 -73
- data/test/stripe/file_upload_test.rb +0 -76
- data/test/stripe/invoice_item_test.rb +0 -55
- data/test/stripe/invoice_line_item_test.rb +0 -8
- data/test/stripe/invoice_test.rb +0 -161
- data/test/stripe/issuer_fraud_record_test.rb +0 -20
- data/test/stripe/issuing/authorization_test.rb +0 -50
- data/test/stripe/issuing/card_test.rb +0 -53
- data/test/stripe/issuing/cardholder_test.rb +0 -53
- data/test/stripe/issuing/dispute_test.rb +0 -45
- data/test/stripe/issuing/transaction_test.rb +0 -48
- data/test/stripe/list_object_test.rb +0 -156
- data/test/stripe/login_link_test.rb +0 -37
- data/test/stripe/oauth_test.rb +0 -88
- data/test/stripe/order_return_test.rb +0 -21
- data/test/stripe/order_test.rb +0 -57
- data/test/stripe/payment_intent_test.rb +0 -80
- data/test/stripe/payment_method_test.rb +0 -66
- data/test/stripe/payout_test.rb +0 -50
- data/test/stripe/person_test.rb +0 -46
- data/test/stripe/plan_test.rb +0 -92
- data/test/stripe/product_test.rb +0 -49
- data/test/stripe/radar/value_list_item_test.rb +0 -38
- data/test/stripe/radar/value_list_test.rb +0 -51
- data/test/stripe/recipient_test.rb +0 -49
- data/test/stripe/refund_test.rb +0 -39
- data/test/stripe/reporting/report_run_test.rb +0 -33
- data/test/stripe/reporting/report_type_test.rb +0 -22
- data/test/stripe/reversal_test.rb +0 -43
- data/test/stripe/review_test.rb +0 -27
- data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
- data/test/stripe/sku_test.rb +0 -50
- data/test/stripe/source_test.rb +0 -86
- data/test/stripe/source_transaction_test.rb +0 -19
- data/test/stripe/stripe_client_test.rb +0 -823
- data/test/stripe/stripe_object_test.rb +0 -525
- data/test/stripe/stripe_response_test.rb +0 -49
- data/test/stripe/subscription_item_test.rb +0 -53
- data/test/stripe/subscription_schedule_revision_test.rb +0 -37
- data/test/stripe/subscription_schedule_revisions_operations_test.rb +0 -35
- data/test/stripe/subscription_schedule_test.rb +0 -64
- data/test/stripe/subscription_test.rb +0 -60
- data/test/stripe/terminal/connection_token_test.rb +0 -16
- data/test/stripe/terminal/location_test.rb +0 -58
- data/test/stripe/terminal/reader_test.rb +0 -52
- data/test/stripe/three_d_secure_test.rb +0 -23
- data/test/stripe/topup_test.rb +0 -54
- data/test/stripe/transfer_reversals_operations_test.rb +0 -57
- data/test/stripe/transfer_test.rb +0 -43
- data/test/stripe/usage_record_summary_test.rb +0 -19
- data/test/stripe/usage_record_test.rb +0 -28
- data/test/stripe/util_test.rb +0 -402
- data/test/stripe/webhook_endpoint_test.rb +0 -42
- data/test/stripe/webhook_test.rb +0 -96
- data/test/stripe_mock.rb +0 -77
- data/test/stripe_test.rb +0 -63
- data/test/test_data.rb +0 -61
- data/test/test_helper.rb +0 -73
data/lib/stripe.rb
CHANGED
@@ -3,15 +3,16 @@
|
|
3
3
|
# Stripe Ruby bindings
|
4
4
|
# API spec at https://stripe.com/docs/api
|
5
5
|
require "cgi"
|
6
|
-
require "faraday"
|
7
6
|
require "json"
|
8
7
|
require "logger"
|
8
|
+
require "net/http"
|
9
9
|
require "openssl"
|
10
10
|
require "rbconfig"
|
11
11
|
require "securerandom"
|
12
12
|
require "set"
|
13
13
|
require "socket"
|
14
14
|
require "uri"
|
15
|
+
require "forwardable"
|
15
16
|
|
16
17
|
# Version
|
17
18
|
require "stripe/version"
|
@@ -23,122 +24,72 @@ require "stripe/api_operations/list"
|
|
23
24
|
require "stripe/api_operations/nested_resource"
|
24
25
|
require "stripe/api_operations/request"
|
25
26
|
require "stripe/api_operations/save"
|
27
|
+
require "stripe/api_operations/search"
|
26
28
|
|
27
29
|
# API resource support classes
|
28
30
|
require "stripe/errors"
|
31
|
+
require "stripe/object_types"
|
29
32
|
require "stripe/util"
|
33
|
+
require "stripe/connection_manager"
|
34
|
+
require "stripe/multipart_encoder"
|
30
35
|
require "stripe/stripe_client"
|
31
36
|
require "stripe/stripe_object"
|
32
37
|
require "stripe/stripe_response"
|
33
38
|
require "stripe/list_object"
|
39
|
+
require "stripe/search_result_object"
|
40
|
+
require "stripe/error_object"
|
34
41
|
require "stripe/api_resource"
|
42
|
+
require "stripe/api_resource_test_helpers"
|
35
43
|
require "stripe/singleton_api_resource"
|
36
44
|
require "stripe/webhook"
|
45
|
+
require "stripe/stripe_configuration"
|
37
46
|
|
38
47
|
# Named API resources
|
39
|
-
require "stripe/
|
40
|
-
require "stripe/account_link"
|
41
|
-
require "stripe/alipay_account"
|
42
|
-
require "stripe/apple_pay_domain"
|
43
|
-
require "stripe/application_fee"
|
44
|
-
require "stripe/application_fee_refund"
|
45
|
-
require "stripe/balance"
|
46
|
-
require "stripe/balance_transaction"
|
47
|
-
require "stripe/bank_account"
|
48
|
-
require "stripe/bitcoin_receiver"
|
49
|
-
require "stripe/bitcoin_transaction"
|
50
|
-
require "stripe/card"
|
51
|
-
require "stripe/charge"
|
52
|
-
require "stripe/checkout/session"
|
53
|
-
require "stripe/country_spec"
|
54
|
-
require "stripe/coupon"
|
55
|
-
require "stripe/customer"
|
56
|
-
require "stripe/dispute"
|
57
|
-
require "stripe/ephemeral_key"
|
58
|
-
require "stripe/event"
|
59
|
-
require "stripe/exchange_rate"
|
60
|
-
require "stripe/file"
|
61
|
-
require "stripe/file_link"
|
62
|
-
require "stripe/invoice"
|
63
|
-
require "stripe/invoice_item"
|
64
|
-
require "stripe/invoice_line_item"
|
65
|
-
require "stripe/issuer_fraud_record"
|
66
|
-
require "stripe/issuing/authorization"
|
67
|
-
require "stripe/issuing/card"
|
68
|
-
require "stripe/issuing/card_details"
|
69
|
-
require "stripe/issuing/cardholder"
|
70
|
-
require "stripe/issuing/dispute"
|
71
|
-
require "stripe/issuing/transaction"
|
72
|
-
require "stripe/login_link"
|
73
|
-
require "stripe/order"
|
74
|
-
require "stripe/order_return"
|
75
|
-
require "stripe/payment_intent"
|
76
|
-
require "stripe/payment_method"
|
77
|
-
require "stripe/payout"
|
78
|
-
require "stripe/person"
|
79
|
-
require "stripe/plan"
|
80
|
-
require "stripe/product"
|
81
|
-
require "stripe/radar/value_list"
|
82
|
-
require "stripe/radar/value_list_item"
|
83
|
-
require "stripe/recipient"
|
84
|
-
require "stripe/recipient_transfer"
|
85
|
-
require "stripe/refund"
|
86
|
-
require "stripe/reporting/report_run"
|
87
|
-
require "stripe/reporting/report_type"
|
88
|
-
require "stripe/reversal"
|
89
|
-
require "stripe/review"
|
90
|
-
require "stripe/sigma/scheduled_query_run"
|
91
|
-
require "stripe/sku"
|
92
|
-
require "stripe/source"
|
93
|
-
require "stripe/source_transaction"
|
94
|
-
require "stripe/subscription"
|
95
|
-
require "stripe/subscription_item"
|
96
|
-
require "stripe/subscription_schedule"
|
97
|
-
require "stripe/subscription_schedule_revision"
|
98
|
-
require "stripe/terminal/connection_token"
|
99
|
-
require "stripe/terminal/location"
|
100
|
-
require "stripe/terminal/reader"
|
101
|
-
require "stripe/three_d_secure"
|
102
|
-
require "stripe/token"
|
103
|
-
require "stripe/topup"
|
104
|
-
require "stripe/transfer"
|
105
|
-
require "stripe/usage_record"
|
106
|
-
require "stripe/usage_record_summary"
|
107
|
-
require "stripe/webhook_endpoint"
|
48
|
+
require "stripe/resources"
|
108
49
|
|
109
50
|
# OAuth
|
110
51
|
require "stripe/oauth"
|
111
52
|
|
112
53
|
module Stripe
|
113
|
-
DEFAULT_CA_BUNDLE_PATH =
|
54
|
+
DEFAULT_CA_BUNDLE_PATH = __dir__ + "/data/ca-certificates.crt"
|
114
55
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
@uploads_base = "https://files.stripe.com"
|
120
|
-
|
121
|
-
@log_level = nil
|
122
|
-
@logger = nil
|
123
|
-
|
124
|
-
@max_network_retries = 0
|
125
|
-
@max_network_retry_delay = 2
|
126
|
-
@initial_network_retry_delay = 0.5
|
127
|
-
|
128
|
-
@ca_bundle_path = DEFAULT_CA_BUNDLE_PATH
|
129
|
-
@ca_store = nil
|
130
|
-
@verify_ssl_certs = true
|
56
|
+
# map to the same values as the standard library's logger
|
57
|
+
LEVEL_DEBUG = Logger::DEBUG
|
58
|
+
LEVEL_ERROR = Logger::ERROR
|
59
|
+
LEVEL_INFO = Logger::INFO
|
131
60
|
|
132
|
-
@
|
133
|
-
@read_timeout = 80
|
61
|
+
@app_info = nil
|
134
62
|
|
135
|
-
@
|
63
|
+
@config = Stripe::StripeConfiguration.setup
|
136
64
|
|
137
65
|
class << self
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
66
|
+
extend Forwardable
|
67
|
+
|
68
|
+
attr_reader :config
|
69
|
+
|
70
|
+
# User configurable options
|
71
|
+
def_delegators :@config, :api_key, :api_key=
|
72
|
+
def_delegators :@config, :api_version, :api_version=
|
73
|
+
def_delegators :@config, :stripe_account, :stripe_account=
|
74
|
+
def_delegators :@config, :api_base, :api_base=
|
75
|
+
def_delegators :@config, :uploads_base, :uploads_base=
|
76
|
+
def_delegators :@config, :connect_base, :connect_base=
|
77
|
+
def_delegators :@config, :open_timeout, :open_timeout=
|
78
|
+
def_delegators :@config, :read_timeout, :read_timeout=
|
79
|
+
def_delegators :@config, :write_timeout, :write_timeout=
|
80
|
+
def_delegators :@config, :proxy, :proxy=
|
81
|
+
def_delegators :@config, :verify_ssl_certs, :verify_ssl_certs=
|
82
|
+
def_delegators :@config, :ca_bundle_path, :ca_bundle_path=
|
83
|
+
def_delegators :@config, :log_level, :log_level=
|
84
|
+
def_delegators :@config, :logger, :logger=
|
85
|
+
def_delegators :@config, :max_network_retries, :max_network_retries=
|
86
|
+
def_delegators :@config, :enable_telemetry=, :enable_telemetry?
|
87
|
+
def_delegators :@config, :client_id=, :client_id
|
88
|
+
|
89
|
+
# Internal configurations
|
90
|
+
def_delegators :@config, :max_network_retry_delay
|
91
|
+
def_delegators :@config, :initial_network_retry_delay
|
92
|
+
def_delegators :@config, :ca_store
|
142
93
|
end
|
143
94
|
|
144
95
|
# Gets the application for a plugin that's identified some. See
|
@@ -151,103 +102,11 @@ module Stripe
|
|
151
102
|
@app_info = info
|
152
103
|
end
|
153
104
|
|
154
|
-
# The location of a file containing a bundle of CA certificates. By default
|
155
|
-
# the library will use an included bundle that can successfully validate
|
156
|
-
# Stripe certificates.
|
157
|
-
def self.ca_bundle_path
|
158
|
-
@ca_bundle_path
|
159
|
-
end
|
160
|
-
|
161
|
-
def self.ca_bundle_path=(path)
|
162
|
-
@ca_bundle_path = path
|
163
|
-
|
164
|
-
# empty this field so a new store is initialized
|
165
|
-
@ca_store = nil
|
166
|
-
end
|
167
|
-
|
168
|
-
# A certificate store initialized from the the bundle in #ca_bundle_path and
|
169
|
-
# which is used to validate TLS on every request.
|
170
|
-
#
|
171
|
-
# This was added to the give the gem "pseudo thread safety" in that it seems
|
172
|
-
# when initiating many parallel requests marshaling the certificate store is
|
173
|
-
# the most likely point of failure (see issue #382). Any program attempting
|
174
|
-
# to leverage this pseudo safety should make a call to this method (i.e.
|
175
|
-
# `Stripe.ca_store`) in their initialization code because it marshals lazily
|
176
|
-
# and is itself not thread safe.
|
177
|
-
def self.ca_store
|
178
|
-
@ca_store ||= begin
|
179
|
-
store = OpenSSL::X509::Store.new
|
180
|
-
store.add_file(ca_bundle_path)
|
181
|
-
store
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
# map to the same values as the standard library's logger
|
186
|
-
LEVEL_DEBUG = Logger::DEBUG
|
187
|
-
LEVEL_ERROR = Logger::ERROR
|
188
|
-
LEVEL_INFO = Logger::INFO
|
189
|
-
|
190
|
-
# When set prompts the library to log some extra information to $stdout and
|
191
|
-
# $stderr about what it's doing. For example, it'll produce information about
|
192
|
-
# requests, responses, and errors that are received. Valid log levels are
|
193
|
-
# `debug` and `info`, with `debug` being a little more verbose in places.
|
194
|
-
#
|
195
|
-
# Use of this configuration is only useful when `.logger` is _not_ set. When
|
196
|
-
# it is, the decision what levels to print is entirely deferred to the logger.
|
197
|
-
def self.log_level
|
198
|
-
@log_level
|
199
|
-
end
|
200
|
-
|
201
|
-
def self.log_level=(val)
|
202
|
-
# Backwards compatibility for values that we briefly allowed
|
203
|
-
if val == "debug"
|
204
|
-
val = LEVEL_DEBUG
|
205
|
-
elsif val == "info"
|
206
|
-
val = LEVEL_INFO
|
207
|
-
end
|
208
|
-
|
209
|
-
if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
|
210
|
-
raise ArgumentError, "log_level should only be set to `nil`, `debug` or `info`"
|
211
|
-
end
|
212
|
-
@log_level = val
|
213
|
-
end
|
214
|
-
|
215
|
-
# Sets a logger to which logging output will be sent. The logger should
|
216
|
-
# support the same interface as the `Logger` class that's part of Ruby's
|
217
|
-
# standard library (hint, anything in `Rails.logger` will likely be
|
218
|
-
# suitable).
|
219
|
-
#
|
220
|
-
# If `.logger` is set, the value of `.log_level` is ignored. The decision on
|
221
|
-
# what levels to print is entirely deferred to the logger.
|
222
|
-
def self.logger
|
223
|
-
@logger
|
224
|
-
end
|
225
|
-
|
226
|
-
def self.logger=(val)
|
227
|
-
@logger = val
|
228
|
-
end
|
229
|
-
|
230
|
-
def self.max_network_retries
|
231
|
-
@max_network_retries
|
232
|
-
end
|
233
|
-
|
234
|
-
def self.max_network_retries=(val)
|
235
|
-
@max_network_retries = val.to_i
|
236
|
-
end
|
237
|
-
|
238
|
-
def self.enable_telemetry?
|
239
|
-
@enable_telemetry
|
240
|
-
end
|
241
|
-
|
242
|
-
def self.enable_telemetry=(val)
|
243
|
-
@enable_telemetry = val
|
244
|
-
end
|
245
|
-
|
246
105
|
# Sets some basic information about the running application that's sent along
|
247
106
|
# with API requests. Useful for plugin authors to identify their plugin when
|
248
107
|
# communicating with Stripe.
|
249
108
|
#
|
250
|
-
# Takes a name and optional
|
109
|
+
# Takes a name and optional partner program ID, plugin URL, and version.
|
251
110
|
def self.set_app_info(name, partner_id: nil, url: nil, version: nil)
|
252
111
|
@app_info = {
|
253
112
|
name: name,
|
@@ -256,16 +115,6 @@ module Stripe
|
|
256
115
|
version: version,
|
257
116
|
}
|
258
117
|
end
|
259
|
-
|
260
|
-
# DEPRECATED. Use `Util#encode_parameters` instead.
|
261
|
-
def self.uri_encode(params)
|
262
|
-
Util.encode_parameters(params)
|
263
|
-
end
|
264
|
-
private_class_method :uri_encode
|
265
|
-
class << self
|
266
|
-
extend Gem::Deprecate
|
267
|
-
deprecate :uri_encode, "Stripe::Util#encode_parameters", 2016, 1
|
268
|
-
end
|
269
118
|
end
|
270
119
|
|
271
120
|
Stripe.log_level = ENV["STRIPE_LOG"] unless ENV["STRIPE_LOG"].nil?
|
data/stripe.gemspec
CHANGED
@@ -7,19 +7,35 @@ require "stripe/version"
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "stripe"
|
9
9
|
s.version = Stripe::VERSION
|
10
|
-
s.required_ruby_version = ">= 2.
|
10
|
+
s.required_ruby_version = ">= 2.3.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
|
-
s.homepage = "https://stripe.com/docs/api
|
16
|
+
s.homepage = "https://stripe.com/docs/api?lang=ruby"
|
16
17
|
s.license = "MIT"
|
17
18
|
|
18
|
-
s.
|
19
|
-
|
19
|
+
s.metadata = {
|
20
|
+
"bug_tracker_uri" => "https://github.com/stripe/stripe-ruby/issues",
|
21
|
+
"changelog_uri" =>
|
22
|
+
"https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md",
|
23
|
+
"documentation_uri" => "https://stripe.com/docs/api?lang=ruby",
|
24
|
+
"github_repo" => "ssh://github.com/stripe/stripe-ruby",
|
25
|
+
"homepage_uri" => "https://stripe.com/docs/api?lang=ruby",
|
26
|
+
"source_code_uri" => "https://github.com/stripe/stripe-ruby",
|
27
|
+
}
|
20
28
|
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
ignored = Regexp.union(
|
30
|
+
/\A\.editorconfig/,
|
31
|
+
/\A\.git/,
|
32
|
+
/\A\.rubocop/,
|
33
|
+
/\A\.travis.yml/,
|
34
|
+
/\A\.vscode/,
|
35
|
+
/\Atest/
|
36
|
+
)
|
37
|
+
s.files = `git ls-files`.split("\n").reject { |f| ignored.match(f) }
|
38
|
+
s.executables = `git ls-files -- bin/*`.split("\n")
|
39
|
+
.map { |f| ::File.basename(f) }
|
24
40
|
s.require_paths = ["lib"]
|
25
41
|
end
|