Class: ActiveMerchant::Billing::FirstPayJsonGateway

Inherits:
Gateway
  • Object
show all
Includes:
FirstPayCommon
Defined in:
lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb

Constant Summary collapse

ACTIONS =
{
  purchase: 'Sale',
  authorize: 'Auth',
  capture: 'Settle',
  refund: 'Refund',
  void: 'Void'
}.freeze
WALLET_TYPES =
{
  apple_pay: 'ApplePay',
  google_pay: 'GooglePay'
}.freeze

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 included from FirstPayCommon

included, #supports_scrubbing?

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?, #supports_scrubbing?, #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 = {}) ⇒ FirstPayJsonGateway

Creates a new FirstPayJsonGateway

The gateway requires two values for connection to be passed in the options hash.

Options

  • :merchant_key – FirstPay’s merchant_key (REQUIRED)

  • :processor_id – FirstPay’s processor_id or processorId (REQUIRED)



33
34
35
36
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 33

def initialize(options = {})
  requires!(options, :merchant_key, :processor_id)
  super
end

Instance Method Details

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



47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 47

def authorize(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment, options)
  add_address(post, payment, options)

  commit(:authorize, post)
end

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



56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 56

def capture(money, authorization, options = {})
  post = {}
  add_invoice(post, money, options)
  add_reference(post, authorization)

  commit(:capture, post)
end

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



38
39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 38

def purchase(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment, options)
  add_address(post, payment, options)

  commit(:purchase, post)
end

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



64
65
66
67
68
69
70
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 64

def refund(money, authorization, options = {})
  post = {}
  add_invoice(post, money, options)
  add_reference(post, authorization)

  commit(:refund, post)
end

#scrub(transcript) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 79

def scrub(transcript)
  transcript.
    gsub(%r(("processorId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("merchantKey\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cardNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("paymentCryptogram\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("cvv\\?"\s*:\s*\\?)[^,]*)i, '\1[FILTERED]')
end

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



72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb', line 72

def void(authorization, options = {})
  post = {}
  add_reference(post, authorization)

  commit(:void, post)
end