Class: ActiveMerchant::Billing::HpsGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::HpsGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/hps.rb
Constant Summary
collapse
- PAYMENT_DATA_SOURCE_MAPPING =
{
apple_pay: 'ApplePay',
google_pay: 'GooglePayApp'
}
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, transaction_id, options = {}) ⇒ Object
-
#credit(money, payment_method, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ HpsGateway
constructor
A new instance of HpsGateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
-
#refund(money, transaction_id, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(card_or_token, options = {}) ⇒ Object
-
#void(transaction_id, 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?
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ HpsGateway
Returns a new instance of HpsGateway.
23
24
25
26
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 23
def initialize(options = {})
requires!(options, :secret_api_key)
super
end
|
Instance Method Details
#authorize(money, payment_method, options = {}) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 28
def authorize(money, payment_method, options = {})
commit('CreditAuth') do |xml|
add_amount(xml, money)
add_allow_dup(xml)
add_card_or_token_customer_data(xml, payment_method, options)
add_details(xml, options)
add_descriptor_name(xml, options)
add_card_or_token_payment(xml, payment_method, options)
add_wallet_data(xml, payment_method, options)
add_three_d_secure(xml, payment_method, options)
add_stored_credentials(xml, options)
end
end
|
#capture(money, transaction_id, options = {}) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 42
def capture(money, transaction_id, options = {})
commit('CreditAddToBatch', transaction_id) do |xml|
add_amount(xml, money)
add_reference(xml, transaction_id)
end
end
|
#credit(money, payment_method, options = {}) ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 69
def credit(money, payment_method, options = {})
commit('CreditReturn') do |xml|
add_amount(xml, money)
add_allow_dup(xml)
add_card_or_token_payment(xml, payment_method, options)
add_details(xml, options)
end
end
|
#purchase(money, payment_method, options = {}) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 49
def purchase(money, payment_method, options = {})
if payment_method.is_a?(Check)
commit_check_sale(money, payment_method, options)
elsif options.dig(:stored_credential, :reason_type) == 'recurring'
commit_recurring_billing_sale(money, payment_method, options)
else
commit_credit_sale(money, payment_method, options)
end
end
|
#refund(money, transaction_id, options = {}) ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 59
def refund(money, transaction_id, options = {})
commit('CreditReturn') do |xml|
add_amount(xml, money)
add_allow_dup(xml)
add_reference(xml, transaction_id)
add_card_or_token_customer_data(xml, transaction_id, options)
add_details(xml, options)
end
end
|
#scrub(transcript) ⇒ Object
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 102
def scrub(transcript)
transcript.
gsub(%r((<hps:CardNbr>)[^<]*(<\/hps:CardNbr>))i, '\1[FILTERED]\2').
gsub(%r((<hps:CVV2>)[^<]*(<\/hps:CVV2>))i, '\1[FILTERED]\2').
gsub(%r((<hps:SecretAPIKey>)[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2').
gsub(%r((<hps:PaymentData>)[^<]*(<\/hps:PaymentData>))i, '\1[FILTERED]\2').
gsub(%r((<hps:RoutingNumber>)[^<]*(<\/hps:RoutingNumber>))i, '\1[FILTERED]\2').
gsub(%r((<hps:AccountNumber>)[^<]*(<\/hps:AccountNumber>))i, '\1[FILTERED]\2').
gsub(%r((<hps:Cryptogram>)[^<]*(<\/hps:Cryptogram>))i, '\1[FILTERED]\2')
end
|
#supports_scrubbing? ⇒ Boolean
98
99
100
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 98
def supports_scrubbing?
true
end
|
#verify(card_or_token, options = {}) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 78
def verify(card_or_token, options = {})
commit('CreditAccountVerify') do |xml|
add_card_or_token_customer_data(xml, card_or_token, options)
add_descriptor_name(xml, options)
add_card_or_token_payment(xml, card_or_token, options)
end
end
|
#void(transaction_id, options = {}) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/active_merchant/billing/gateways/hps.rb', line 86
def void(transaction_id, options = {})
if options[:check_void]
commit('CheckVoid') do |xml|
add_reference(xml, transaction_id)
end
else
commit('CreditVoid') do |xml|
add_reference(xml, transaction_id)
end
end
end
|