Class: ActiveMerchant::Billing::HiPayGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::HiPayGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/hi_pay.rb
Constant Summary
collapse
- PAYMENT_PRODUCT =
{
'visa' => 'visa',
'master' => 'mastercard'
}
- DEVICE_CHANEL =
{
app: 1,
browser: 2,
three_ds_requestor_initiaded: 3
}
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_method, options = {}) ⇒ Object
-
#capture(money, authorization, options) ⇒ Object
-
#initialize(options = {}) ⇒ HiPayGateway
constructor
A new instance of HiPayGateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
-
#refund(money, authorization, options) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment_method, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(authorization, 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?
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ HiPayGateway
Returns a new instance of HiPayGateway.
27
28
29
30
31
32
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 27
def initialize(options = {})
requires!(options, :username, :password)
@username = options[:username]
@password = options[:password]
super
end
|
Instance Method Details
#authorize(money, payment_method, options = {}) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 38
def authorize(money, payment_method, options = {})
MultiResponse.run do |r|
if payment_method.is_a?(CreditCard)
response = r.process { tokenize(payment_method, options) }
card_token = response.params['token']
elsif payment_method.is_a?(String)
_transaction_ref, card_token, payment_product = payment_method.split('|') if payment_method.split('|').size == 3
card_token, payment_product = payment_method.split('|') if payment_method.split('|').size == 2
end
payment_product = payment_method.is_a?(CreditCard) ? PAYMENT_PRODUCT[payment_method.brand] : PAYMENT_PRODUCT[payment_product&.downcase]
post = {
payment_product:,
operation: options[:operation] || 'Authorization',
cardtoken: card_token
}
add_address(post, options)
add_product_data(post, options)
add_invoice(post, money, options)
add_3ds(post, options)
r.process { commit('order', post) }
end
end
|
#capture(money, authorization, options) ⇒ Object
63
64
65
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 63
def capture(money, authorization, options)
reference_operation(money, authorization, options.merge({ operation: 'capture' }))
end
|
#purchase(money, payment_method, options = {}) ⇒ Object
34
35
36
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 34
def purchase(money, payment_method, options = {})
authorize(money, payment_method, options.merge({ operation: 'Sale' }))
end
|
#refund(money, authorization, options) ⇒ Object
77
78
79
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 77
def refund(money, authorization, options)
reference_operation(money, authorization, options.merge({ operation: 'refund' }))
end
|
#scrub(transcript) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 89
def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )[\w =]+), '\1[FILTERED]').
gsub(%r((card_number=)\w+), '\1[FILTERED]\2').
gsub(%r((cvc=)\w+), '\1[FILTERED]\2')
end
|
#store(payment_method, options = {}) ⇒ Object
67
68
69
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 67
def store(payment_method, options = {})
tokenize(payment_method, options.merge({ multiuse: '1' }))
end
|
#supports_scrubbing? ⇒ Boolean
85
86
87
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 85
def supports_scrubbing?
true
end
|
#unstore(authorization, options = {}) ⇒ Object
71
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 71
def unstore(authorization, options = {})
_transaction_ref, card_token, _payment_product = authorization.split('|') if authorization.split('|').size == 3
card_token, _payment_product = authorization.split('|') if authorization.split('|').size == 2
commit('unstore', { card_token: }, options, :delete)
end
|
#void(authorization, options) ⇒ Object
81
82
83
|
# File 'lib/active_merchant/billing/gateways/hi_pay.rb', line 81
def void(authorization, options)
reference_operation(nil, authorization, options.merge({ operation: 'cancel' }))
end
|