Module: Stripe

Extended by:
Gem::Deprecate
Defined in:
lib/stripe.rb,
lib/stripe/sku.rb,
lib/stripe/card.rb,
lib/stripe/plan.rb,
lib/stripe/util.rb,
lib/stripe/event.rb,
lib/stripe/oauth.rb,
lib/stripe/order.rb,
lib/stripe/token.rb,
lib/stripe/topup.rb,
lib/stripe/charge.rb,
lib/stripe/coupon.rb,
lib/stripe/errors.rb,
lib/stripe/payout.rb,
lib/stripe/refund.rb,
lib/stripe/source.rb,
lib/stripe/account.rb,
lib/stripe/balance.rb,
lib/stripe/dispute.rb,
lib/stripe/invoice.rb,
lib/stripe/product.rb,
lib/stripe/version.rb,
lib/stripe/webhook.rb,
lib/stripe/customer.rb,
lib/stripe/reversal.rb,
lib/stripe/transfer.rb,
lib/stripe/recipient.rb,
lib/stripe/login_link.rb,
lib/stripe/file_upload.rb,
lib/stripe/list_object.rb,
lib/stripe/api_resource.rb,
lib/stripe/bank_account.rb,
lib/stripe/country_spec.rb,
lib/stripe/invoice_item.rb,
lib/stripe/order_return.rb,
lib/stripe/subscription.rb,
lib/stripe/usage_record.rb,
lib/stripe/ephemeral_key.rb,
lib/stripe/exchange_rate.rb,
lib/stripe/stripe_client.rb,
lib/stripe/stripe_object.rb,
lib/stripe/alipay_account.rb,
lib/stripe/three_d_secure.rb,
lib/stripe/application_fee.rb,
lib/stripe/stripe_response.rb,
lib/stripe/apple_pay_domain.rb,
lib/stripe/bitcoin_receiver.rb,
lib/stripe/invoice_line_item.rb,
lib/stripe/subscription_item.rb,
lib/stripe/recipient_transfer.rb,
lib/stripe/source_transaction.rb,
lib/stripe/api_operations/list.rb,
lib/stripe/api_operations/save.rb,
lib/stripe/balance_transaction.rb,
lib/stripe/bitcoin_transaction.rb,
lib/stripe/issuer_fraud_record.rb,
lib/stripe/api_operations/create.rb,
lib/stripe/api_operations/delete.rb,
lib/stripe/api_operations/request.rb,
lib/stripe/application_fee_refund.rb,
lib/stripe/singleton_api_resource.rb,
lib/stripe/api_operations/nested_resource.rb

Defined Under Namespace

Modules: APIOperations, OAuth, Util, Webhook Classes: APIConnectionError, APIError, APIResource, Account, AlipayAccount, ApplePayDomain, ApplicationFee, ApplicationFeeRefund, AuthenticationError, Balance, BalanceTransaction, BankAccount, BitcoinReceiver, BitcoinTransaction, Card, CardError, Charge, CountrySpec, Coupon, Customer, Dispute, EphemeralKey, Event, ExchangeRate, FileUpload, IdempotencyError, InvalidRequestError, Invoice, InvoiceItem, InvoiceLineItem, IssuerFraudRecord, ListObject, LoginLink, Order, OrderReturn, Payout, PermissionError, Plan, Product, RateLimitError, Recipient, RecipientTransfer, Refund, Reversal, SKU, SignatureVerificationError, SingletonAPIResource, Source, SourceTransaction, StripeClient, StripeError, StripeObject, StripeResponse, Subscription, SubscriptionItem, ThreeDSecure, Token, Topup, Transfer, UsageRecord

Constant Summary

DEFAULT_CA_BUNDLE_PATH =
File.dirname(__FILE__) + "/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 =
"3.15.0".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_baseObject

Returns the value of attribute api_base



111
112
113
# File 'lib/stripe.rb', line 111

def api_base
  @api_base
end

.api_keyObject

Returns the value of attribute api_key



111
112
113
# File 'lib/stripe.rb', line 111

def api_key
  @api_key
end

.api_versionObject

Returns the value of attribute api_version



111
112
113
# File 'lib/stripe.rb', line 111

def api_version
  @api_version
end

.client_idObject

Returns the value of attribute client_id



111
112
113
# File 'lib/stripe.rb', line 111

def client_id
  @client_id
end

.connect_baseObject

Returns the value of attribute connect_base



111
112
113
# File 'lib/stripe.rb', line 111

def connect_base
  @connect_base
end

.initial_network_retry_delayObject (readonly)

Returns the value of attribute initial_network_retry_delay



114
115
116
# File 'lib/stripe.rb', line 114

def initial_network_retry_delay
  @initial_network_retry_delay
end

.max_network_retry_delayObject (readonly)

Returns the value of attribute max_network_retry_delay



114
115
116
# File 'lib/stripe.rb', line 114

def max_network_retry_delay
  @max_network_retry_delay
end

.open_timeoutObject

Returns the value of attribute open_timeout



111
112
113
# File 'lib/stripe.rb', line 111

def open_timeout
  @open_timeout
end

.read_timeoutObject

Returns the value of attribute read_timeout



111
112
113
# File 'lib/stripe.rb', line 111

def read_timeout
  @read_timeout
end

.stripe_accountObject

Returns the value of attribute stripe_account



111
112
113
# File 'lib/stripe.rb', line 111

def 
  @stripe_account
end

.uploads_baseObject

Returns the value of attribute uploads_base



111
112
113
# File 'lib/stripe.rb', line 111

def uploads_base
  @uploads_base
end

.verify_ssl_certsObject

Returns the value of attribute verify_ssl_certs



111
112
113
# File 'lib/stripe.rb', line 111

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.



119
120
121
# File 'lib/stripe.rb', line 119

def self.app_info
  @app_info
end

.app_info=(info) ⇒ Object



123
124
125
# File 'lib/stripe.rb', line 123

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.



130
131
132
# File 'lib/stripe.rb', line 130

def self.ca_bundle_path
  @ca_bundle_path
end

.ca_bundle_path=(path) ⇒ Object



134
135
136
137
138
139
# File 'lib/stripe.rb', line 134

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.



150
151
152
153
154
155
156
# File 'lib/stripe.rb', line 150

def self.ca_store
  @ca_store ||= begin
    store = OpenSSL::X509::Store.new
    store.add_file(ca_bundle_path)
    store
  end
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.



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

def self.log_level
  @log_level
end

.log_level=(val) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/stripe.rb', line 174

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.



195
196
197
# File 'lib/stripe.rb', line 195

def self.logger
  @logger
end

.logger=(val) ⇒ Object



199
200
201
# File 'lib/stripe.rb', line 199

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

.max_network_retriesObject



203
204
205
# File 'lib/stripe.rb', line 203

def self.max_network_retries
  @max_network_retries
end

.max_network_retries=(val) ⇒ Object



207
208
209
# File 'lib/stripe.rb', line 207

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

.set_app_info(name, version: nil, url: 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 version and plugin URL.



216
217
218
219
220
221
222
# File 'lib/stripe.rb', line 216

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