Class: ActiveMerchant::Billing::WebpayGateway

Inherits:
StripeGateway show all
Defined in:
lib/active_merchant/billing/gateways/webpay.rb

Constant Summary

Constants inherited from StripeGateway

StripeGateway::AVS_CODE_TRANSLATOR, StripeGateway::CVC_CODE_TRANSLATOR

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from StripeGateway

#initialize, #purchase, #refund, #store, #unstore, #update, #void

Methods inherited from Gateway

#card_brand, card_brand, inherited, #initialize, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::StripeGateway

Instance Method Details

#headers(meta = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/active_merchant/billing/gateways/webpay.rb', line 26

def headers(meta={})
  @@ua ||= JSON.dump({
    :bindings_version => ActiveMerchant::VERSION,
    :lang => 'ruby',
    :lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
    :platform => RUBY_PLATFORM,
    :publisher => 'active_merchant',
    :uname => (RUBY_PLATFORM =~ /linux|darwin/i ? `uname -a 2>/dev/null`.strip : nil)
  })

  {
    "Authorization" => "Basic " + Base64.encode64(@api_key.to_s + ":").strip,
    "User-Agent" => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
    "X-Webpay-Client-User-Agent" => @@ua,
    "X-Webpay-Client-User-Metadata" => meta.to_json
  }
end

#json_error(raw_response) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/active_merchant/billing/gateways/webpay.rb', line 16

def json_error(raw_response)
  msg = 'Invalid response received from the WebPay API.  Please contact [email protected] if you continue to receive this message.'
  msg += "  (The raw response returned by the API was #{raw_response.inspect})"
  {
    "error" => {
      "message" => msg
    }
  }
end