Module: ActiveMerchant::Billing::MastercardGateway
- Included in:
- CitrusPayGateway, TnsGateway
- Defined in:
- lib/active_merchant/billing/gateways/mastercard.rb
Instance Method Summary collapse
- #authorize(amount, payment_method, options = {}) ⇒ Object
- #capture(amount, authorization, options = {}) ⇒ Object
- #initialize(options = {}) ⇒ Object
- #purchase(amount, payment_method, options = {}) ⇒ Object
- #refund(amount, authorization, options = {}) ⇒ Object
- #scrub(transcript) ⇒ Object
- #supports_scrubbing? ⇒ Boolean
- #verify(credit_card, options = {}) ⇒ Object
- #verify_credentials ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 27 def (amount, payment_method, = {}) post = new_post add_invoice(post, amount, ) add_reference(post, *()) add_payment_method(post, payment_method) add_customer_data(post, payment_method, ) add_3dsecure_id(post, ) commit('authorize', post) end |
#capture(amount, authorization, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 38 def capture(amount, , = {}) post = new_post add_invoice(post, amount, , :transaction) add_reference(post, *()) add_customer_data(post, nil, ) add_3dsecure_id(post, ) commit('capture', post) end |
#initialize(options = {}) ⇒ Object
4 5 6 7 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 4 def initialize( = {}) requires!(, :userid, :password) super end |
#purchase(amount, payment_method, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 9 def purchase(amount, payment_method, = {}) if [:pay_mode] post = new_post add_invoice(post, amount, ) add_reference(post, *()) add_payment_method(post, payment_method) add_customer_data(post, payment_method, ) add_3dsecure_id(post, ) commit('pay', post) else MultiResponse.run do |r| r.process { (amount, payment_method, ) } r.process { capture(amount, r., ) } end end end |
#refund(amount, authorization, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 48 def refund(amount, , = {}) post = new_post add_invoice(post, amount, , :transaction) add_reference(post, *()) add_customer_data(post, nil, ) commit('refund', post) end |
#scrub(transcript) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 86 def scrub(transcript) transcript. gsub(%r((Authorization: Basic ).*\\r\\n), '\1[FILTERED]'). gsub(%r(("number"?\\?":"?\\?")\d*), '\1[FILTERED]'). gsub(%r(("securityCode"?\\?":"?\\?")\d*), '\1[FILTERED]') end |
#supports_scrubbing? ⇒ Boolean
82 83 84 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 82 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 64 def verify(credit_card, = {}) MultiResponse.run(:use_first_response) do |r| r.process { (100, credit_card, ) } r.process(:ignore_result) { void(r., ) } end end |
#verify_credentials ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 71 def verify_credentials url = build_url(SecureRandom.uuid, 'nonexistent') begin ssl_get(url, headers) rescue ResponseError => e return false if e.response.code.to_i == 401 end true end |
#void(authorization, options = {}) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 57 def void(, = {}) post = new_post add_reference(post, *(), :targetTransactionId) commit('void', post) end |