Class: ActiveMerchant::Billing::SafeChargeGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::SafeChargeGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/safe_charge.rb
Constant Summary
collapse
- VERSION =
'4.1.0'
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
-
#credit(money, payment, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ SafeChargeGateway
constructor
A new instance of SafeChargeGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, 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
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of SafeChargeGateway.
18
19
20
21
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 18
def initialize(options = {})
requires!(options, :client_login_id, :client_password)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 45
def authorize(money, payment, options = {})
post = {}
add_external_mpi_data(post, options) if options[:three_d_secure]&.is_a?(Hash)
add_transaction_data('Auth', post, money, options)
add_payment(post, payment, options)
add_customer_details(post, payment, options)
commit(post)
end
|
#capture(money, authorization, options = {}) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 56
def capture(money, authorization, options = {})
post = {}
auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
add_transaction_data('Settle', post, money, options.merge!({ currency: original_currency }))
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
post[:sg_ExpYear] = exp_year
post[:sg_Email] = options[:email]
commit(post)
end
|
#credit(money, payment, options = {}) ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 84
def credit(money, payment, options = {})
post = {}
add_payment(post, payment, options)
add_transaction_data('Credit', post, money, options)
post[:sg_CreditType] = 1
commit(post)
end
|
#purchase(money, payment, options = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 23
def purchase(money, payment, options = {})
post = {}
if options[:three_d_secure]
if options[:three_d_secure].is_a?(Hash)
add_external_mpi_data(post, options)
else
post[:sg_APIType] = 1
trans_type = 'Sale3D'
end
end
trans_type ||= 'Sale'
add_transaction_data(trans_type, post, money, options)
add_payment(post, payment, options)
add_customer_details(post, payment, options)
commit(post)
end
|
#refund(money, authorization, options = {}) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 70
def refund(money, authorization, options = {})
post = {}
auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
add_transaction_data('Credit', post, money, options.merge!({ currency: original_currency }))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
post[:sg_ExpYear] = exp_year
commit(post)
end
|
#scrub(transcript) ⇒ Object
117
118
119
120
121
122
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 117
def scrub(transcript)
transcript.
gsub(%r((sg_ClientPassword=)[^&]+(&?)), '\1[FILTERED]\2').
gsub(%r((sg_CardNumber=)[^&]+(&?)), '\1[FILTERED]\2').
gsub(%r((sg_CVV2=)\d+), '\1[FILTERED]')
end
|
#supports_scrubbing? ⇒ Boolean
113
114
115
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 113
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
109
110
111
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 109
def verify(credit_card, options = {})
authorize(0, credit_card, options)
end
|
#void(authorization, options = {}) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/active_merchant/billing/gateways/safe_charge.rb', line 95
def void(authorization, options = {})
post = {}
auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split('|')
add_transaction_data('Void', post, (original_amount.to_f * 100), options.merge!({ currency: original_currency }))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
post[:sg_ExpYear] = exp_year
commit(post)
end
|