Module: Payments::Client

Defined in:
lib/payments/client.rb,
lib/payments/client/config.rb,
lib/payments/client/facade.rb,
lib/payments/client/gateway.rb,
lib/payments/client/railtie.rb,
lib/payments/client/version.rb,
lib/payments/client/request_id.rb,
lib/payments/client/operations/http.rb,
lib/payments/client/operations/orders.rb,
lib/payments/client/operations/merchants.rb,
lib/payments/client/operations/middleware.rb,
lib/payments/client/operations/settlements.rb,
lib/payments/client/operations/receipt_numbers.rb,
lib/payments/client/operations/pricing_schedule.rb,
lib/payments/client/operations/financial_contexts.rb

Defined Under Namespace

Modules: DefaultMiddleware, GetOperation, PostOperation, PutOperation, WithoutDefaultMiddleware Classes: ChangeOrderExtraData, Config, CreateFinancialContext, CreateMerchant, Facade, Gateway, GetAccountDonationTransactionDetailReport, GetAccountStatement, GetDonationTransactionDetailReport, GetFinancialContext, GetMerchant, GetMerchantFinancialReports, GetPricingSchedule, GetReceiptNumber, Operation, PlaceOrder, Railtie, RequestId, RequestOrderVoid, RequestReceiptNumber, UpdateMerchant, UpdateMerchantsInFinancialContext

Constant Summary collapse

GATEWAY_ALIASES =
{
  http: :excon,
}
Error =
Class.new(StandardError)
VERSION =
"0.0.6"

Class Method Summary collapse

Class Method Details

.request_idObject



23
24
25
# File 'lib/payments/client.rb', line 23

def self.request_id
  @request_id ||= SecureRandom.uuid
end

.request_id=(value) ⇒ Object



19
20
21
# File 'lib/payments/client.rb', line 19

def self.request_id=(value)
  @request_id = value
end

.v1(name = :http, *gateway_options) ⇒ Object

Examples:

client = Payments::Client.v1
client = Payments::Client.v1(:rack, Payments::Application)

client.get_merchant(merchant_id)


32
33
34
35
36
37
38
# File 'lib/payments/client.rb', line 32

def self.v1(name = :http, *gateway_options)
  name = GATEWAY_ALIASES[name] || name
  config = Config.new(ENV.fetch("PAYMENTS_API_URL"))
  gateway = Gateway.new(name, config, *gateway_options)

  Facade.new(gateway)
end