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

#authorize(money, credit_card, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/active_merchant/billing/gateways/webpay.rb', line 16

def authorize(money, credit_card, options = {})
  raise NotImplementedError.new
end

#capture(money, credit_card, options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/active_merchant/billing/gateways/webpay.rb', line 20

def capture(money, credit_card, options = {})
  raise NotImplementedError.new
end

#headers(meta = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/active_merchant/billing/gateways/webpay.rb', line 34

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



24
25
26
27
28
29
30
31
32
# File 'lib/active_merchant/billing/gateways/webpay.rb', line 24

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