Class: ActiveMerchant::Billing::PayJunctionV2Gateway

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

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#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

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ PayJunctionV2Gateway


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

def initialize(options={})
  requires!(options, :api_login, :api_password, :api_key)
  super
end

Instance Method Details

#authorize(amount, payment_method, options = {}) ⇒ Object


28
29
30
31
32
33
34
35
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 28

def authorize(amount, payment_method, options={})
  post = {}
  post[:status] = "HOLD"
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)

  commit("authorize", post)
end

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


37
38
39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 37

def capture(amount, authorization, options={})
  post = {}
  post[:status] = "CAPTURE"
  post[:transactionId] = authorization
  add_invoice(post, amount, options)

  commit("capture", post)
end

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


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

def credit(amount, payment_method, options={})
  post = {}
  post[:action] = "REFUND"
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)

  commit("credit", post)
end

#purchase(amount, payment_method, options = {}) ⇒ Object


20
21
22
23
24
25
26
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 20

def purchase(amount, payment_method, options={})
  post = {}
  add_invoice(post, amount, options)
  add_payment_method(post, payment_method)

  commit("purchase", post)
end

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


54
55
56
57
58
59
60
61
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 54

def refund(amount, authorization, options={})
  post = {}
  post[:action] = "REFUND"
  post[:transactionId] = authorization
  add_invoice(post, amount, options)

  commit("refund", post)
end

#scrub(transcript) ⇒ Object


87
88
89
90
91
92
93
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 87

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((X-Pj-Application-Key: )[\w-]+), '\1[FILTERED]').
    gsub(%r((cardNumber=)\d+), '\1[FILTERED]').
    gsub(%r((cardCvv=)\d+), '\1[FILTERED]')
end

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


79
80
81
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 79

def store(payment_method, options = {})
  verify(payment_method, options)
end

#supports_scrubbing?Boolean


83
84
85
# File 'lib/active_merchant/billing/gateways/pay_junction_v2.rb', line 83

def supports_scrubbing?
  true
end

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


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

def verify(credit_card, options={})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

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


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

def void(authorization, options={})
  post = {}
  post[:status] = "VOID"
  post[:transactionId] = authorization

  commit("void", post)
end