Class: ActiveMerchant::Billing::PlexoGateway

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

Constant Summary collapse

APPENDED_URLS =
%w(captures refunds cancellations verify)
AMOUNT_IN_RESPONSE =
%w(authonly purchase /verify)
APPROVED_STATUS =
%w(approved authorized)

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

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ PlexoGateway

Returns a new instance of PlexoGateway.



18
19
20
21
22
# File 'lib/active_merchant/billing/gateways/plexo.rb', line 18

def initialize(options = {})
  requires!(options, :client_id, :api_key)
  @credentials = options
  super
end

Instance Method Details

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



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

def authorize(money, payment, options = {})
  post = {}
  build_auth_purchase_request(money, post, payment, options)
  add_capture_type(post, options)

  commit('authonly', post, options)
end

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



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

def capture(money, authorization, options = {})
  post = {}
  post[:ReferenceId] = options[:reference_id] || generate_unique_id
  post[:Amount] = amount(money)

  commit("/#{authorization}/captures", post, options)
end

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



24
25
26
27
28
29
# File 'lib/active_merchant/billing/gateways/plexo.rb', line 24

def purchase(money, payment, options = {})
  post = {}
  build_auth_purchase_request(money, post, payment, options)

  commit('purchase', post, options)
end

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



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

def refund(money, authorization, options = {})
  post = {}
  post[:ReferenceId] = options[:reference_id] || generate_unique_id
  post[:Type] = options[:refund_type] || 'refund'
  post[:Description] = options[:description]
  post[:Reason] = options[:reason]
  post[:Amount] = amount(money)

  commit("/#{authorization}/refunds", post, options)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r(("Number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("Cvc\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("InvoiceNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
    gsub(%r(("MerchantId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/active_merchant/billing/gateways/plexo.rb', line 67

def verify(credit_card, options = {})
  post = {}
  post[:ReferenceId] = options[:reference_id] || generate_unique_id
  post[:MerchantId] = options[:merchant_id] || @credentials[:merchant_id]
  post[:StatementDescriptor] = options[:statement_descriptor] if options[:statement_descriptor]
  post[:CustomerId] = options[:customer_id] if options[:customer_id]
  money = options[:verify_amount].to_i || 100

  add_payment_method(post, credit_card, options)
  (post, options[:metadata])
  add_amount(money, post, options)
  add_browser_details(post, options)

  commit('/verify', post, options)
end

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



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

def void(authorization, options = {})
  post = {}
  post[:ReferenceId] = options[:reference_id] || generate_unique_id
  post[:Description] = options[:description]
  post[:Reason] = options[:reason]

  commit("/#{authorization}/cancellations", post, options)
end