module Bongloy

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

Constants

DEFAULT_CA_BUNDLE_PATH
FileUpload

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

LEVEL_DEBUG

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

LEVEL_ERROR
LEVEL_INFO
VERSION

Attributes

api_base[RW]
api_key[RW]
api_version[RW]
client_id[RW]
connect_base[RW]
initial_network_retry_delay[R]
max_network_retry_delay[R]
open_timeout[RW]
proxy[RW]
read_timeout[RW]
stripe_account[RW]
uploads_base[RW]
verify_ssl_certs[RW]

Public Class Methods

app_info() click to toggle source

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

# File lib/stripe.rb, line 82
def self.app_info
  @app_info
end
app_info=(info) click to toggle source
# File lib/stripe.rb, line 86
def self.app_info=(info)
  @app_info = info
end
ca_bundle_path() click to toggle source

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.

# File lib/stripe.rb, line 93
def self.ca_bundle_path
  @ca_bundle_path
end
ca_bundle_path=(path) click to toggle source
# 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_store() click to toggle source

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.

# 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) click to toggle source
# File lib/stripe.rb, line 179
def self.enable_telemetry=(val)
  @enable_telemetry = val
end
enable_telemetry?() click to toggle source
# File lib/stripe.rb, line 175
def self.enable_telemetry?
  @enable_telemetry
end
log_level() click to toggle source

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.

# File lib/stripe.rb, line 133
def self.log_level
  @log_level
end
log_level=(val) click to toggle source
# 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
logger() click to toggle source

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.

# File lib/stripe.rb, line 159
def self.logger
  @logger
end
logger=(val) click to toggle source
# File lib/stripe.rb, line 163
def self.logger=(val)
  @logger = val
end
max_network_retries() click to toggle source
# File lib/stripe.rb, line 167
def self.max_network_retries
  @max_network_retries
end
max_network_retries=(val) click to toggle source
# 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) click to toggle source

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.

# 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

Private Class Methods

uri_encode(params) click to toggle source

DEPRECATED. Use `Util#encode_parameters` instead.

# File lib/stripe.rb, line 198
def self.uri_encode(params)
  Util.encode_parameters(params)
end