lib/active_merchant/billing/gateways/mastercard.rb in activemerchant-1.98.0 vs lib/active_merchant/billing/gateways/mastercard.rb in activemerchant-1.99.0
- old
+ new
@@ -5,13 +5,24 @@
requires!(options, :userid, :password)
super
end
def purchase(amount, payment_method, options={})
- MultiResponse.run do |r|
- r.process { authorize(amount, payment_method, options) }
- r.process { capture(amount, r.authorization, options) }
+ if options[:pay_mode]
+ post = new_post
+ add_invoice(post, amount, options)
+ add_reference(post, *new_authorization)
+ add_payment_method(post, payment_method)
+ add_customer_data(post, payment_method, options)
+ add_3dsecure_id(post, options)
+
+ commit('pay', post)
+ else
+ MultiResponse.run do |r|
+ r.process { authorize(amount, payment_method, options) }
+ r.process { capture(amount, r.authorization, options) }
+ end
end
end
def authorize(amount, payment_method, options={})
post = new_post
@@ -204,12 +215,26 @@
"#{base_url}merchant/#{@options[:userid]}/order/#{orderid}/transaction/#{transactionid}"
end
def base_url
if test?
- @options[:region] == 'asia_pacific' ? test_ap_url : test_na_url
+ case @options[:region]
+ when 'asia_pacific'
+ test_ap_url
+ when 'europe'
+ test_eu_url
+ when 'north_america', nil
+ test_na_url
+ end
else
- @options[:region] == 'asia_pacific' ? live_ap_url : live_na_url
+ case @options[:region]
+ when 'asia_pacific'
+ live_ap_url
+ when 'europe'
+ live_eu_url
+ when 'north_america', nil
+ live_na_url
+ end
end
end
def build_request(post = {})
post.to_json