Class: ActiveMerchant::Billing::SageGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::SageGateway
show all
- Includes:
- Empty
- Defined in:
- lib/active_merchant/billing/gateways/sage.rb
Defined Under Namespace
Classes: SageVault
Constant Summary
collapse
- TRANSACTIONS =
{
purchase: '01',
authorization: '02',
capture: '11',
void: '04',
credit: '06',
refund: '10'
}
- SOURCE_CARD =
'bankcard'
- SOURCE_ECHECK =
'virtual_check'
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, credit_card, options = {}) ⇒ Object
-
#capture(money, reference, options = {}) ⇒ Object
The money
amount is not used.
-
#credit(money, payment_method, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ SageGateway
constructor
A new instance of SageGateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
-
#refund(money, reference, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#unstore(identification, options = {}) ⇒ Object
-
#void(reference, 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 = {}) ⇒ SageGateway
Returns a new instance of SageGateway.
25
26
27
28
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 25
def initialize(options = {})
requires!(options, :login, :password)
super
end
|
Instance Method Details
#authorize(money, credit_card, options = {}) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 30
def authorize(money, credit_card, options = {})
post = {}
add_credit_card(post, credit_card)
add_transaction_data(post, money, options)
commit(:authorization, post, SOURCE_CARD)
end
|
#capture(money, reference, options = {}) ⇒ Object
The money
amount is not used. The entire amount of the initial authorization will be captured.
53
54
55
56
57
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 53
def capture(money, reference, options = {})
post = {}
add_reference(post, reference)
commit(:capture, post, SOURCE_CARD)
end
|
#credit(money, payment_method, options = {}) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 66
def credit(money, payment_method, options = {})
post = {}
if card_brand(payment_method) == 'check'
source = SOURCE_ECHECK
add_check(post, payment_method)
add_check_customer_data(post, options)
else
source = SOURCE_CARD
add_credit_card(post, payment_method)
end
add_transaction_data(post, money, options)
commit(:credit, post, source)
end
|
#purchase(money, payment_method, options = {}) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 37
def purchase(money, payment_method, options = {})
post = {}
if card_brand(payment_method) == 'check'
source = SOURCE_ECHECK
add_check(post, payment_method)
add_check_customer_data(post, options)
else
source = SOURCE_CARD
add_credit_card(post, payment_method)
end
add_transaction_data(post, money, options)
commit(:purchase, post, source)
end
|
#refund(money, reference, options = {}) ⇒ Object
80
81
82
83
84
85
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 80
def refund(money, reference, options = {})
post = {}
add_reference(post, reference)
add_transaction_data(post, money, options)
commit(:refund, post, SOURCE_CARD)
end
|
#scrub(transcript) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 99
def scrub(transcript)
force_utf8(transcript).
gsub(%r((M_id=)[^&]*), '\1[FILTERED]').
gsub(%r((M_key=)[^&]*), '\1[FILTERED]').
gsub(%r((C_cardnumber=)[^&]*), '\1[FILTERED]').
gsub(%r((C_cvv=)[^&]*), '\1[FILTERED]').
gsub(%r((C_rte=)[^&]*), '\1[FILTERED]').
gsub(%r((C_acct=)[^&]*), '\1[FILTERED]').
gsub(%r((C_ssn=)[^&]*), '\1[FILTERED]').
gsub(%r((<ns1:CARDNUMBER>).+(</ns1:CARDNUMBER>)), '\1[FILTERED]\2').
gsub(%r((<ns1:M_ID>).+(</ns1:M_ID>)), '\1[FILTERED]\2').
gsub(%r((<ns1:M_KEY>).+(</ns1:M_KEY>)), '\1[FILTERED]\2')
end
|
#store(credit_card, options = {}) ⇒ Object
87
88
89
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 87
def store(credit_card, options = {})
vault.store(credit_card, options)
end
|
#supports_scrubbing? ⇒ Boolean
95
96
97
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 95
def supports_scrubbing?
true
end
|
#unstore(identification, options = {}) ⇒ Object
91
92
93
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 91
def unstore(identification, options = {})
vault.unstore(identification, options)
end
|
#void(reference, options = {}) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/active_merchant/billing/gateways/sage.rb', line 59
def void(reference, options = {})
post = {}
add_reference(post, reference)
source = reference.split(';').last
commit(:void, post, source)
end
|