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
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 17 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
28 29 30 31 32 33 34 35 36 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 28 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
5 6 7 8 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 5 def initialize(={}) requires!(, :userid, :password) super end |
#purchase(amount, payment_method, options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 10 def purchase(amount, payment_method, ={}) MultiResponse.run do |r| r.process { (amount, payment_method, ) } r.process { capture(amount, r., ) } end end |
#refund(amount, authorization, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 38 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
76 77 78 79 80 81 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 76 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
72 73 74 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 72 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 54 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
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 61 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
47 48 49 50 51 52 |
# File 'lib/active_merchant/billing/gateways/mastercard.rb', line 47 def void(, ={}) post = new_post add_reference(post, *(), :targetTransactionId) commit('void', post) end |