Module: Stripe

Extended by:
Gem::Deprecate
Defined in:
lib/stripe/object_types.rb,
lib/stripe.rb,
lib/stripe/util.rb,
lib/stripe/oauth.rb,
lib/stripe/errors.rb,
lib/stripe/version.rb,
lib/stripe/webhook.rb,
lib/stripe/list_object.rb,
lib/stripe/api_resource.rb,
lib/stripe/resources/sku.rb,
lib/stripe/stripe_client.rb,
lib/stripe/stripe_object.rb,
lib/stripe/resources/card.rb,
lib/stripe/resources/file.rb,
lib/stripe/resources/file.rb,
lib/stripe/resources/plan.rb,
lib/stripe/resources/event.rb,
lib/stripe/resources/order.rb,
lib/stripe/resources/token.rb,
lib/stripe/resources/topup.rb,
lib/stripe/stripe_response.rb,
lib/stripe/resources/charge.rb,
lib/stripe/resources/coupon.rb,
lib/stripe/resources/payout.rb,
lib/stripe/resources/person.rb,
lib/stripe/resources/refund.rb,
lib/stripe/resources/review.rb,
lib/stripe/resources/source.rb,
lib/stripe/resources/tax_id.rb,
lib/stripe/resources/account.rb,
lib/stripe/resources/balance.rb,
lib/stripe/resources/dispute.rb,
lib/stripe/resources/invoice.rb,
lib/stripe/resources/product.rb,
lib/stripe/resources/customer.rb,
lib/stripe/resources/discount.rb,
lib/stripe/resources/reversal.rb,
lib/stripe/resources/tax_rate.rb,
lib/stripe/resources/transfer.rb,
lib/stripe/api_operations/list.rb,
lib/stripe/api_operations/save.rb,
lib/stripe/resources/file_link.rb,
lib/stripe/resources/recipient.rb,
lib/stripe/resources/capability.rb,
lib/stripe/resources/login_link.rb,
lib/stripe/api_operations/create.rb,
lib/stripe/api_operations/delete.rb,
lib/stripe/resources/credit_note.rb,
lib/stripe/api_operations/request.rb,
lib/stripe/resources/account_link.rb,
lib/stripe/resources/bank_account.rb,
lib/stripe/resources/country_spec.rb,
lib/stripe/resources/invoice_item.rb,
lib/stripe/resources/issuing/card.rb,
lib/stripe/resources/order_return.rb,
lib/stripe/resources/setup_intent.rb,
lib/stripe/resources/subscription.rb,
lib/stripe/resources/usage_record.rb,
lib/stripe/singleton_api_resource.rb,
lib/stripe/resources/ephemeral_key.rb,
lib/stripe/resources/exchange_rate.rb,
lib/stripe/resources/alipay_account.rb,
lib/stripe/resources/payment_intent.rb,
lib/stripe/resources/payment_method.rb,
lib/stripe/resources/three_d_secure.rb,
lib/stripe/resources/application_fee.rb,
lib/stripe/resources/issuing/dispute.rb,
lib/stripe/resources/terminal/reader.rb,
lib/stripe/resources/apple_pay_domain.rb,
lib/stripe/resources/bitcoin_receiver.rb,
lib/stripe/resources/checkout/session.rb,
lib/stripe/resources/radar/value_list.rb,
lib/stripe/resources/webhook_endpoint.rb,
lib/stripe/resources/invoice_line_item.rb,
lib/stripe/resources/subscription_item.rb,
lib/stripe/resources/terminal/location.rb,
lib/stripe/resources/issuing/cardholder.rb,
lib/stripe/resources/recipient_transfer.rb,
lib/stripe/resources/source_transaction.rb,
lib/stripe/resources/balance_transaction.rb,
lib/stripe/resources/bitcoin_transaction.rb,
lib/stripe/resources/issuer_fraud_record.rb,
lib/stripe/resources/issuing/transaction.rb,
lib/stripe/api_operations/nested_resource.rb,
lib/stripe/resources/issuing/card_details.rb,
lib/stripe/resources/reporting/report_run.rb,
lib/stripe/resources/usage_record_summary.rb,
lib/stripe/resources/issuing/authorization.rb,
lib/stripe/resources/radar/value_list_item.rb,
lib/stripe/resources/reporting/report_type.rb,
lib/stripe/resources/subscription_schedule.rb,
lib/stripe/resources/application_fee_refund.rb,
lib/stripe/resources/radar/early_fraud_warning.rb,
lib/stripe/resources/sigma/scheduled_query_run.rb,
lib/stripe/resources/terminal/connection_token.rb,
lib/stripe/resources/customer_balance_transaction.rb,
lib/stripe/resources/subscription_schedule_revision.rb

Overview

rubocop:disable Metrics/LineLength rubocop:disable Metrics/MethodLength

Defined Under Namespace

Modules: APIOperations, Checkout, Issuing, OAuth, ObjectTypes, Radar, Reporting, Sigma, Terminal, Util, Webhook Classes: APIConnectionError, APIError, APIResource, Account, AccountLink, AlipayAccount, ApplePayDomain, ApplicationFee, ApplicationFeeRefund, AuthenticationError, Balance, BalanceTransaction, BankAccount, BitcoinReceiver, BitcoinTransaction, Capability, Card, CardError, Charge, CountrySpec, Coupon, CreditNote, Customer, CustomerBalanceTransaction, Discount, Dispute, EphemeralKey, Event, ExchangeRate, File, FileLink, IdempotencyError, InvalidRequestError, Invoice, InvoiceItem, InvoiceLineItem, IssuerFraudRecord, ListObject, LoginLink, Order, OrderReturn, PaymentIntent, PaymentMethod, Payout, PermissionError, Person, Plan, Product, RateLimitError, Recipient, RecipientTransfer, Refund, Reversal, Review, SKU, SetupIntent, SignatureVerificationError, SingletonAPIResource, Source, SourceTransaction, StripeClient, StripeError, StripeObject, StripeResponse, Subscription, SubscriptionItem, SubscriptionSchedule, SubscriptionScheduleRevision, TaxId, TaxRate, ThreeDSecure, Token, Topup, Transfer, UsageRecord, UsageRecordSummary, WebhookEndpoint

Constant Summary collapse

DEFAULT_CA_BUNDLE_PATH =
__dir__ + "/data/ca-certificates.crt"
LEVEL_DEBUG =

map to the same values as the standard library’s logger

Logger::DEBUG
LEVEL_ERROR =
Logger::ERROR
LEVEL_INFO =
Logger::INFO
VERSION =
"4.21.3".freeze
FileUpload =

For backwards compatibility, the ‘File` class is aliased to `FileUpload`.

File

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_baseObject

Returns the value of attribute api_base.



73
74
75
# File 'lib/stripe.rb', line 73

def api_base
  @api_base
end

.api_keyObject

Returns the value of attribute api_key.



73
74
75
# File 'lib/stripe.rb', line 73

def api_key
  @api_key
end

.api_versionObject

Returns the value of attribute api_version.



73
74
75
# File 'lib/stripe.rb', line 73

def api_version
  @api_version
end

.client_idObject

Returns the value of attribute client_id.



73
74
75
# File 'lib/stripe.rb', line 73

def client_id
  @client_id
end

.connect_baseObject

Returns the value of attribute connect_base.



73
74
75
# File 'lib/stripe.rb', line 73

def connect_base
  @connect_base
end

.initial_network_retry_delayObject (readonly)

Returns the value of attribute initial_network_retry_delay.



77
78
79
# File 'lib/stripe.rb', line 77

def initial_network_retry_delay
  @initial_network_retry_delay
end

.max_network_retry_delayObject (readonly)

Returns the value of attribute max_network_retry_delay.



77
78
79
# File 'lib/stripe.rb', line 77

def max_network_retry_delay
  @max_network_retry_delay
end

.open_timeoutObject

Returns the value of attribute open_timeout.



73
74
75
# File 'lib/stripe.rb', line 73

def open_timeout
  @open_timeout
end

.proxyObject

Returns the value of attribute proxy.



73
74
75
# File 'lib/stripe.rb', line 73

def proxy
  @proxy
end

.read_timeoutObject

Returns the value of attribute read_timeout.



73
74
75
# File 'lib/stripe.rb', line 73

def read_timeout
  @read_timeout
end

.stripe_accountObject

Returns the value of attribute stripe_account.



73
74
75
# File 'lib/stripe.rb', line 73

def 
  @stripe_account
end

.uploads_baseObject

Returns the value of attribute uploads_base.



73
74
75
# File 'lib/stripe.rb', line 73

def uploads_base
  @uploads_base
end

.verify_ssl_certsObject

Returns the value of attribute verify_ssl_certs.



73
74
75
# File 'lib/stripe.rb', line 73

def verify_ssl_certs
  @verify_ssl_certs
end

Class Method Details

.app_infoObject

Gets the application for a plugin that’s identified some. See #set_app_info.



82
83
84
# File 'lib/stripe.rb', line 82

def self.app_info
  @app_info
end

.app_info=(info) ⇒ Object



86
87
88
# File 'lib/stripe.rb', line 86

def self.app_info=(info)
  @app_info = info
end

.ca_bundle_pathObject

The location of a file containing a bundle of CA certificates. By default the library will use an included bundle that can successfully validate Stripe certificates.



93
94
95
# File 'lib/stripe.rb', line 93

def self.ca_bundle_path
  @ca_bundle_path
end

.ca_bundle_path=(path) ⇒ Object



97
98
99
100
101
102
# File 'lib/stripe.rb', line 97

def self.ca_bundle_path=(path)
  @ca_bundle_path = path

  # empty this field so a new store is initialized
  @ca_store = nil
end

.ca_storeObject

A certificate store initialized from the the bundle in #ca_bundle_path and which is used to validate TLS on every request.

This was added to the give the gem “pseudo thread safety” in that it seems when initiating many parallel requests marshaling the certificate store is the most likely point of failure (see issue #382). Any program attempting to leverage this pseudo safety should make a call to this method (i.e. ‘Stripe.ca_store`) in their initialization code because it marshals lazily and is itself not thread safe.



113
114
115
116
117
118
119
# File 'lib/stripe.rb', line 113

def self.ca_store
  @ca_store ||= begin
    store = OpenSSL::X509::Store.new
    store.add_file(ca_bundle_path)
    store
  end
end

.enable_telemetry=(val) ⇒ Object



179
180
181
# File 'lib/stripe.rb', line 179

def self.enable_telemetry=(val)
  @enable_telemetry = val
end

.enable_telemetry?Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/stripe.rb', line 175

def self.enable_telemetry?
  @enable_telemetry
end

.log_levelObject

When set prompts the library to log some extra information to $stdout and $stderr about what it’s doing. For example, it’ll produce information about requests, responses, and errors that are received. Valid log levels are ‘debug` and `info`, with `debug` being a little more verbose in places.

Use of this configuration is only useful when ‘.logger` is not set. When it is, the decision what levels to print is entirely deferred to the logger.



133
134
135
# File 'lib/stripe.rb', line 133

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/stripe.rb', line 137

def self.log_level=(val)
  # Backwards compatibility for values that we briefly allowed
  if val == "debug"
    val = LEVEL_DEBUG
  elsif val == "info"
    val = LEVEL_INFO
  end

  if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
    raise ArgumentError,
          "log_level should only be set to `nil`, `debug` or `info`"
  end
  @log_level = val
end

.loggerObject

Sets a logger to which logging output will be sent. The logger should support the same interface as the ‘Logger` class that’s part of Ruby’s standard library (hint, anything in ‘Rails.logger` will likely be suitable).

If ‘.logger` is set, the value of `.log_level` is ignored. The decision on what levels to print is entirely deferred to the logger.



159
160
161
# File 'lib/stripe.rb', line 159

def self.logger
  @logger
end

.logger=(val) ⇒ Object



163
164
165
# File 'lib/stripe.rb', line 163

def self.logger=(val)
  @logger = val
end

.max_network_retriesObject



167
168
169
# File 'lib/stripe.rb', line 167

def self.max_network_retries
  @max_network_retries
end

.max_network_retries=(val) ⇒ Object



171
172
173
# File 'lib/stripe.rb', line 171

def self.max_network_retries=(val)
  @max_network_retries = val.to_i
end

.set_app_info(name, partner_id: nil, url: nil, version: nil) ⇒ Object

Sets some basic information about the running application that’s sent along with API requests. Useful for plugin authors to identify their plugin when communicating with Stripe.

Takes a name and optional partner program ID, plugin URL, and version.



188
189
190
191
192
193
194
195
# File 'lib/stripe.rb', line 188

def self.set_app_info(name, partner_id: nil, url: nil, version: nil)
  @app_info = {
    name: name,
    partner_id: partner_id,
    url: url,
    version: version,
  }
end