Class: ActiveMerchant::Billing::DatatransGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::DatatransGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/datatrans.rb
Constant Summary
collapse
- CREDIT_CARD_SOURCE =
{
visa: 'VISA',
master: 'MASTERCARD'
}.with_indifferent_access
- DEVICE_SOURCE =
{
apple_pay: 'APPLE_PAY',
google_pay: 'GOOGLE_PAY'
}.with_indifferent_access
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
-
#authorize(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ DatatransGateway
constructor
A new instance of DatatransGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment_method, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(authorization, options = {}) ⇒ Object
-
#verify(payment, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
#fetch_version, included
#expdate, #format, #strftime_yyyymm, #strftime_yyyymmdd_last_day
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of DatatransGateway.
30
31
32
33
34
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 30
def initialize(options = {})
requires!(options, :merchant_id, :password)
@merchant_id, @password = options.values_at(:merchant_id, :password)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 47
def authorize(money, payment, options = {})
post = { refno: options.fetch(:order_id, '') }
add_payment_method(post, payment)
add_3ds_data(post, payment, options)
add_currency_amount(post, money, options)
add_billing_address(post, options)
post[:autoSettle] = options[:auto_settle] if options[:auto_settle]
commit('authorize', post)
end
|
#capture(money, authorization, options = {}) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 57
def capture(money, authorization, options = {})
post = { refno: options.fetch(:order_id, '') }
transaction_id = authorization.split('|').first
add_currency_amount(post, money, options)
commit('settle', post, { transaction_id: })
end
|
#purchase(money, payment, options = {}) ⇒ Object
36
37
38
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 36
def purchase(money, payment, options = {})
authorize(money, payment, options.merge(auto_settle: true))
end
|
#refund(money, authorization, options = {}) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 64
def refund(money, authorization, options = {})
post = { refno: options.fetch(:order_id, '') }
transaction_id = authorization.split('|').first
add_currency_amount(post, money, options)
commit('credit', post, { transaction_id: })
end
|
#scrub(transcript) ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 103
def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )[\w =]+), '\1[FILTERED]').
gsub(%r((\"number\\":\\")\d+), '\1[FILTERED]\2').
gsub(%r((\"cvv\\":\\")\d+), '\1[FILTERED]\2').
gsub(%r((\"pan\\":\\")\d+), '\1[FILTERED]\2')
end
|
#store(payment_method, options = {}) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 77
def store(payment_method, options = {})
exp_year = format(payment_method.year, :two_digits)
exp_month = format(payment_method.month, :two_digits)
post = {
requests: [
{
type: 'CARD',
pan: payment_method.number,
expiryMonth: exp_month,
expiryYear: exp_year
}
]
}
commit('tokenize', post, { expiry_month: exp_month, expiry_year: exp_year })
end
|
#supports_scrubbing? ⇒ Boolean
99
100
101
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 99
def supports_scrubbing?
true
end
|
#unstore(authorization, options = {}) ⇒ Object
94
95
96
97
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 94
def unstore(authorization, options = {})
data_alias = authorization.split('|')[2]
commit('delete_alias', {}, { alias_id: data_alias }, :delete)
end
|
#verify(payment, options = {}) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 40
def verify(payment, options = {})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(100, payment, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
|
#void(authorization, options = {}) ⇒ Object
71
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/datatrans.rb', line 71
def void(authorization, options = {})
post = {}
transaction_id = authorization.split('|').first
commit('cancel', post, { transaction_id: })
end
|