Class: ActiveMerchant::Billing::BarclaycardSmartpayGateway

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

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ BarclaycardSmartpayGateway

Returns a new instance of BarclaycardSmartpayGateway.



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

def initialize(options = {})
  requires!(options, :company, :merchant, :password)
  super
end

Instance Method Details

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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 29

def authorize(money, creditcard, options = {})
  requires!(options, :order_id)

  post = payment_request(money, options)
  post[:amount] = amount_hash(money, options[:currency])
  post[:card] = credit_card_hash(creditcard)

  if address = (options[:billing_address] || options[:address])
    post[:billingAddress] = address_hash(address)
  end

  if options[:shipping_address]
    post[:deliveryAddress] = address_hash(options[:shipping_address])
  end

  commit('authorise', post)
end

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



47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 47

def capture(money, authorization, options = {})
  requires!(options, :order_id)

  post = modification_request(authorization, options)
  post[:modificationAmount] = amount_hash(money, options[:currency])

  commit('capture', post)
end

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



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

def credit(money, creditcard, options = {})
  post = payment_request(money, options)
  post[:amount] = amount_hash(money, options[:currency])
  post[:card] = credit_card_hash(creditcard)

  commit('refundWithData', post)
end

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



20
21
22
23
24
25
26
27
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 20

def purchase(money, creditcard, options = {})
  requires!(options, :order_id)

  MultiResponse.run do |r|
    r.process { authorize(money, creditcard, options) }
    r.process { capture(money, r.authorization, options) }
  end
end

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



56
57
58
59
60
61
62
63
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 56

def refund(money, authorization, options = {})
  requires!(options, :order_id)

  post = modification_request(authorization, options)
  post[:modificationAmount] = amount_hash(money, options[:currency])

  commit('refund', post)
end

#scrub(transcript) ⇒ Object



97
98
99
100
101
102
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 97

def scrub(transcript)
  transcript.
    gsub(%r(((?:\r\n)?Authorization: Basic )[^\r\n]+(\r\n)?), '\1[FILTERED]').
    gsub(%r((card.number=)\d+), '\1[FILTERED]').
    gsub(%r((card.cvc=)\d+), '\1[FILTERED]')
end

#store(creditcard, options = {}) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 85

def store(creditcard, options = {})
  post = store_request(options)
  post[:card] = credit_card_hash(creditcard)
  post[:recurring] = {:contract => 'RECURRING'}

  commit('store', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 93

def supports_scrubbing?
  true
end

#verify(creditcard, options = {}) ⇒ Object



81
82
83
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 81

def verify(creditcard, options = {})
  authorize(0, creditcard, options)
end

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



73
74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/barclaycard_smartpay.rb', line 73

def void(identification, options = {})
  requires!(options, :order_id)

  post = modification_request(identification, options)

  commit('cancel', post)
end