Class: ActiveMerchant::Billing::CheckoutV2
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::CheckoutV2
- Defined in:
- lib/active_merchant/billing/checkout_v2.rb
Overview
:nodoc:
Instance Method Summary collapse
- #authorize(amount, payment_method, options = {}) ⇒ Object
- #capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ CheckoutV2
constructor
A new instance of CheckoutV2.
- #purchase(amount, payment_method, options = {}) ⇒ Object
- #refund(amount, authorization, options = {}) ⇒ Object
- #scrub(transcript) ⇒ Object
- #supports_scrubbing? ⇒ Boolean
- #verify(credit_card, options = {}) ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CheckoutV2
Returns a new instance of CheckoutV2.
22 23 24 25 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 22 def initialize(={}) requires!(, :secret_key) super end |
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 34 def (amount, payment_method, ={}) post = {} post[:autoCapture] = "n" add_invoice(post, amount, ) if payment_method.is_a?(String) && payment_method.include?('card_tok_') post[:cardToken] = payment_method post[:email] = [:email] commit(:authorize_token, post) else add_payment_method(post, payment_method) add_customer_data(post, ) commit(:authorize, post) end end |
#capture(amount, authorization, options = {}) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 52 def capture(amount, , ={}) post = {} add_invoice(post, amount, ) add_customer_data(post, ) commit(:capture, post, ) end |
#purchase(amount, payment_method, options = {}) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 27 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
65 66 67 68 69 70 71 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 65 def refund(amount, , ={}) post = {} add_invoice(post, amount, ) add_customer_data(post, ) commit(:refund, post, ) end |
#scrub(transcript) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 84 def scrub(transcript) transcript. gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]'). gsub(%r(("number\\":\\")\d+), '\1[FILTERED]'). gsub(%r(("cvv\\":\\")\d+), '\1[FILTERED]') end |
#supports_scrubbing? ⇒ Boolean
80 81 82 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 80 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 73 def verify(credit_card, ={}) MultiResponse.run(:use_first_response) do |r| r.process { (100, credit_card, ) } r.process(:ignore_result) { void(r., ) } end end |
#void(authorization, options = {}) ⇒ Object
60 61 62 63 |
# File 'lib/active_merchant/billing/checkout_v2.rb', line 60 def void(, ={}) post = {} commit(:void, post, ) end |