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 collapse

TEST_URL =
'https://secure2.mde.epdq.co.uk:11500'
LIVE_URL =
'https://secure2.epdq.co.uk:11500'

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 Utils

#deprecated, generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ BarclaysEpdqGateway

Returns a new instance of BarclaysEpdqGateway.



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

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

Instance Method Details

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



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

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



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

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



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

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



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

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



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

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

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



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

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

  commit(document)
end