Class: ActiveMerchant::Billing::WorldNetGateway

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

Overview

Constant Summary collapse

CARD_TYPES =
{
  visa:             'VISA',
  master:           'MASTERCARD',
  discover:         'DISCOVER',
  american_express: 'AMEX',
  maestro:          'MAESTRO',
  diners_club:      'DINERS',
  jcb:              'JCB',
  secure_card:      'SECURECARD'
}.freeze

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, 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

#format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ WorldNetGateway

Returns a new instance of WorldNetGateway.



28
29
30
31
32
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 28

def initialize(options = {})
  requires!(options, :terminal_id, :secret)
  options[:terminal_type] ||= 2 # eCommerce
  super
end

Instance Method Details

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



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

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

  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment)
  add_address(post, payment, options)
  add_customer_data(post, options)

  commit('PREAUTH', post)
end

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



58
59
60
61
62
63
64
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 58

def capture(money, authorization, options = {})
  post = {}
  add_invoice(post, money, options)
  post[:uniqueref] = authorization

  commit('PREAUTHCOMPLETION', post)
end

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



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 34

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

  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment)
  add_address(post, payment, options)
  add_customer_data(post, options)

  commit('PAYMENT', post)
end

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



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 66

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

  post = {}
  post[:uniqueref] = authorization
  add_invoice(post, money, options)
  post[:operator] = options[:operator]
  post[:reason] = options[:reason]

  commit('REFUND', post)
end

#scrub(transcript) ⇒ Object



115
116
117
118
119
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 115

def scrub(transcript)
  transcript
    .gsub(%r{(<CARDNUMBER>\d{6})\d+(\d{4}</CARDNUMBER>)}, '\1...\2')
    .gsub(%r{(<CVV>)\d+(</CVV)}, '\1...\2')
end

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



91
92
93
94
95
96
97
98
99
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 91

def store(payment, options = {})
  requires!(options, :order_id)

  post = {}
  post[:merchantref] = options[:order_id]
  add_payment(post, payment)

  commit('SECURECARDREGISTRATION', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 111

def supports_scrubbing?
  true
end

#unstore(payment, options = {}) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 101

def unstore(payment, options = {})
  requires!(options, :order_id)

  post = {}
  post[:merchantref] = options[:order_id]
  add_card_reference(post, payment)

  commit('SECURECARDREMOVAL', post)
end

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



84
85
86
87
88
89
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 84

def verify(credit_card, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

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



78
79
80
81
82
# File 'lib/active_merchant/billing/gateways/world_net.rb', line 78

def void(authorization, _options = {})
  post = {}
  post[:uniqueref] = authorization
  commit('VOID', post)
end