Class: ActiveMerchant::Billing::MigsGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::MigsGateway
show all
- Includes:
- MigsCodes
- Defined in:
- lib/active_merchant/billing/gateways/migs.rb
Constant Summary
collapse
- API_VERSION =
1
Constants included
from MigsCodes
ActiveMerchant::Billing::MigsCodes::CARD_TYPES, ActiveMerchant::Billing::MigsCodes::ISSUER_RESPONSE_CODES, ActiveMerchant::Billing::MigsCodes::TXN_RESPONSE_CODES, ActiveMerchant::Billing::MigsCodes::VERIFIED_3D_CODES
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
-
#capture(money, authorization, options = {}) ⇒ Object
Options.
-
#credit(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ MigsGateway
constructor
Creates a new MigsGateway The advanced_login/advanced_password fields are needed for advanced methods such as the capture, refund and status methods.
-
#purchase(money, creditcard, options = {}) ⇒ Object
(also: #authorize)
Options.
-
#purchase_offsite_response(data) ⇒ Object
Parses a response from purchase_offsite_url once user is redirected back.
-
#purchase_offsite_url(money, options = {}) ⇒ Object
Generates a URL to redirect user to MiGS to process payment Once user is finished MiGS will redirect back to specified URL With a response hash which can be turned into a Response object with purchase_offsite_response.
-
#refund(money, authorization, options = {}) ⇒ Object
Options.
-
#scrub(transcript) ⇒ Object
-
#status(unique_id) ⇒ Object
Checks the status of a previous transaction This can be useful when a response is not received due to network issues.
-
#supports_scrubbing? ⇒ Boolean
-
#test? ⇒ 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?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ MigsGateway
Creates a new MigsGateway
The advanced_login/advanced_password fields are needed for
advanced methods such as the capture, refund and status methods
Options
- :login -- The MiGS Merchant ID (REQUIRED)
- :password -- The MiGS Access Code (REQUIRED)
- :secure_hash -- The MiGS Secure Hash
(Required for Server Hosted payments)
- :advanced_login -- The MiGS AMA User
- :advanced_password -- The MiGS AMA User's password
46
47
48
49
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 46
def initialize(options = {})
requires!(options, :login, :password)
super
end
|
Instance Method Details
#capture(money, authorization, options = {}) ⇒ Object
Options
- :unique_id -- A unique id for this request (Max 40 chars).
If not supplied one will be generated.
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 79
def capture(money, authorization, options = {})
requires!(@options, :advanced_login, :advanced_password)
post = options.merge(:TransNo => authorization)
add_amount(post, money, options)
add_advanced_user(post)
add_standard_parameters('capture', post, options[:unique_id])
add_tx_source(post, options)
commit(post)
end
|
#credit(money, authorization, options = {}) ⇒ Object
#purchase(money, creditcard, options = {}) ⇒ Object
Also known as:
authorize
Options
- :order_id -- A reference for tracking the order (REQUIRED)
- :unique_id -- A unique id for this request (Max 40 chars).
If not supplied one will be generated.
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 56
def purchase(money, creditcard, options = {})
requires!(options, :order_id)
post = {}
add_amount(post, money, options)
add_invoice(post, options)
add_creditcard(post, creditcard)
add_standard_parameters('pay', post, options[:unique_id])
add_3ds(post, options)
add_tx_source(post, options)
commit(post)
end
|
#purchase_offsite_response(data) ⇒ Object
Parses a response from purchase_offsite_url once user is redirected back
Parameters
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 192
def purchase_offsite_response(data)
requires!(@options, :secure_hash)
response_hash = parse(data)
expected_secure_hash = calculate_secure_hash(response_hash, @options[:secure_hash])
unless response_hash[:SecureHash] == expected_secure_hash
raise SecurityError, 'Secure Hash mismatch, response may be tampered with'
end
response_object(response_hash)
end
|
#purchase_offsite_url(money, options = {}) ⇒ Object
Generates a URL to redirect user to MiGS to process payment
Once user is finished MiGS will redirect back to specified URL
With a response hash which can be turned into a Response object
with purchase_offsite_response
Options
- :order_id -- A reference for tracking the order (REQUIRED)
- :locale -- Change the language of the redirected page
Values are 2 digit locale, e.g. en, es
- :return_url -- the URL to return to once the payment is complete
- :card_type -- Providing this skips the card type step.
Values are ActiveMerchant formats: e.g. master, visa, american_express, diners_club
- :unique_id -- Unique id of transaction to find.
If not supplied one will be generated.
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 166
def purchase_offsite_url(money, options = {})
requires!(options, :order_id, :return_url)
requires!(@options, :secure_hash)
post = {}
add_amount(post, money, options)
add_invoice(post, options)
add_creditcard_type(post, options[:card_type]) if options[:card_type]
post[:Locale] = options[:locale] || 'en'
post[:ReturnURL] = options[:return_url]
add_standard_parameters('pay', post, options[:unique_id])
add_secure_hash(post)
self.server_hosted_url + '?' + post_data(post)
end
|
#refund(money, authorization, options = {}) ⇒ Object
Options
- :unique_id -- A unique id for this request (Max 40 chars).
If not supplied one will be generated.
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 96
def refund(money, authorization, options = {})
requires!(@options, :advanced_login, :advanced_password)
post = options.merge(:TransNo => authorization)
add_amount(post, money, options)
add_advanced_user(post)
add_standard_parameters('refund', post, options[:unique_id])
add_tx_source(post, options)
commit(post)
end
|
#scrub(transcript) ⇒ Object
213
214
215
216
217
218
219
220
221
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 213
def scrub(transcript)
transcript.
gsub(%r((&?CardNum=)\d*(&?)), '\1[FILTERED]\2').
gsub(%r((&?CardSecurityCode=)\d*(&?)), '\1[FILTERED]\2').
gsub(%r((&?AccessCode=)[^&]*(&?)), '\1[FILTERED]\2').
gsub(%r((&?Password=)[^&]*(&?)), '\1[FILTERED]\2').
gsub(%r((&?3DSXID=)[^&]*(&?)), '\1[FILTERED]\2').
gsub(%r((&?VerToken=)[^&]*(&?)), '\1[FILTERED]\2')
end
|
#status(unique_id) ⇒ Object
Checks the status of a previous transaction
This can be useful when a response is not received due to network issues
Parameters
- unique_id -- Unique id of transaction to find.
This is the value of the option supplied in other methods or
if not supplied is returned with key :MerchTxnRef
141
142
143
144
145
146
147
148
149
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 141
def status(unique_id)
requires!(@options, :advanced_login, :advanced_password)
post = {}
add_advanced_user(post)
add_standard_parameters('queryDR', post, unique_id)
commit(post)
end
|
#supports_scrubbing? ⇒ Boolean
209
210
211
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 209
def supports_scrubbing?
true
end
|
#test? ⇒ Boolean
205
206
207
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 205
def test?
@options[:login].start_with?('TEST')
end
|
#verify(credit_card, options = {}) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 126
def verify(credit_card, options={})
MultiResponse.run do |r|
r.process { authorize(100, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
|
#void(authorization, options = {}) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/active_merchant/billing/gateways/migs.rb', line 109
def void(authorization, options = {})
requires!(@options, :advanced_login, :advanced_password)
post = options.merge(:TransNo => authorization)
add_advanced_user(post)
add_standard_parameters('voidAuthorisation', post, options[:unique_id])
add_tx_source(post, options)
commit(post)
end
|