Class: ActiveMerchant::Billing::BarclaysEpdqGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/barclays_epdq.rb

Defined Under Namespace

Classes: Document, Parser

Constant Summary

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 Gateway

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

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ BarclaysEpdqGateway

Returns a new instance of BarclaysEpdqGateway.



14
15
16
17
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 14

def initialize(options = {})
  requires!(options, :login, :password, :client_id)
  super
end

Instance Method Details

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



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 19

def authorize(money, creditcard, options = {})
  document = Document.new(self, @options) do
    add_order_form(options[:order_id]) do
      add_consumer(options) do
        add_creditcard(creditcard)
      end
      add_transaction(:PreAuth, money)
    end
  end

  commit(document)
end

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

authorization is your unique order ID, not the authorization code returned by ePDQ



52
53
54
55
56
57
58
59
60
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 52

def capture(money, authorization, options = {})
  document = Document.new(self, @options) do
    add_order_form(authorization) do
      add_transaction(:PostAuth, money)
    end
  end

  commit(document)
end

#credit(money, creditcard_or_authorization, options = {}) ⇒ Object

authorization is your unique order ID, not the authorization code returned by ePDQ



64
65
66
67
68
69
70
71
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 64

def credit(money, creditcard_or_authorization, options = {})
  if creditcard_or_authorization.is_a?(String)
    deprecated CREDIT_DEPRECATION_MESSAGE
    refund(money, creditcard_or_authorization, options)
  else
    credit_new_order(money, creditcard_or_authorization, options)
  end
end

#purchase(money, creditcard, options = {}) ⇒ Object



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

def purchase(money, creditcard, options = {})
  # disable fraud checks if this is a repeat order:
  if options[:payment_number] && (options[:payment_number] > 1)
    no_fraud = true
  else
    no_fraud = options[:no_fraud]
  end
  document = Document.new(self, @options, :no_fraud => no_fraud) do
    add_order_form(options[:order_id], options[:group_id]) do
      add_consumer(options) do
        add_creditcard(creditcard)
      end
      add_transaction(:Auth, money, options)
    end
  end
  commit(document)
end

#refund(money, authorization, options = {}) ⇒ Object



73
74
75
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 73

def refund(money, authorization, options = {})
  credit_existing_order(money, authorization, options)
end

#void(authorization, options = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/active_merchant/billing/gateways/barclays_epdq.rb', line 77

def void(authorization, options = {})
  document = Document.new(self, @options) do
    add_order_form(authorization) do
      add_transaction(:Void)
    end
  end

  commit(document)
end