Class: ActiveMerchant::Billing::VersaPayGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/versa_pay.rb

Constant Summary

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

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?, #test?

Methods included from CreditCardFormatting

#expdate, #format, #strftime_yyyymm

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ VersaPayGateway

Returns a new instance of VersaPayGateway.



15
16
17
18
19
20
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 15

def initialize(options = {})
  requires!(options, :api_token, :api_key)
  @api_token = options[:api_token]
  @api_key = options[:api_key]
  super
end

Instance Method Details

#authorize(money, payment, options = {}) ⇒ Object



26
27
28
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 26

def authorize(money, payment, options = {})
  transact(money, payment, options, 'auth')
end

#capture(money, authorization, options = {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 30

def capture(money, authorization, options = {})
  post = {
    amount_cents: money,
    transaction: authorization.split('|').first
  }
  commit('capture', post)
end

#credit(money, payment_method, options = {}) ⇒ Object



54
55
56
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 54

def credit(money, payment_method, options = {})
  transact(money, payment_method, options, 'credit')
end

#purchase(money, payment, options = {}) ⇒ Object



22
23
24
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 22

def purchase(money, payment, options = {})
  transact(money, payment, options)
end

#refund(money, authorization, options = {}) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 46

def refund(money, authorization, options = {})
  post = {
    amount_cents: money,
    transaction: authorization.split('|').first
  }
  commit('refund', post)
end

#scrub(transcript) ⇒ Object



76
77
78
79
80
81
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 76

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r(("card_number\\?":\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvv\\?":\\?")[^"]*)i, '\1[FILTERED]')
end

#store(payment_method, options = {}) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 58

def store(payment_method, options = {})
  post = {
    contact: { email: options[:email] }
  }
  add_customer_data(post, options)
  add_payment_method(post, payment_method, options)
  commit('store', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 72

def supports_scrubbing?
  true
end

#unstore(authorization, options = {}) ⇒ Object



67
68
69
70
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 67

def unstore(authorization, options = {})
  _, wallet_token, fund_token = authorization.split('|')
  commit('unstore', {}, :delete, { fund_token: fund_token, wallet_token: wallet_token })
end

#verify(credit_card, options = {}) ⇒ Object



38
39
40
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 38

def verify(credit_card, options = {})
  transact(0, credit_card, options, 'verify')
end

#void(authorization, options = {}) ⇒ Object



42
43
44
# File 'lib/active_merchant/billing/gateways/versa_pay.rb', line 42

def void(authorization, options = {})
  commit('void', { transaction: authorization.split('|').first })
end