Class: ActiveMerchant::Billing::PayeezyGateway

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

Constant Summary collapse

CREDIT_CARD_BRAND =
{
  'visa' => 'Visa',
  'master' => 'Mastercard',
  'american_express' => 'American Express',
  'discover' => 'Discover',
  'jcb' => 'JCB',
  'diners_club' => 'Diners Club'
}

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 = {}) ⇒ PayeezyGateway

Returns a new instance of PayeezyGateway.



28
29
30
31
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 28

def initialize(options = {})
  requires!(options, :apikey, :apisecret, :token)
  super
end

Instance Method Details

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



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 51

def authorize(amount, payment_method, options = {})
  params = { transaction_type: 'authorize' }

  add_invoice(params, options)
  add_reversal_id(params, options)
  add_customer_ref(params, options)
  add_reference_3(params, options)
  add_payment_method(params, payment_method, options)
  add_address(params, options)
  add_amount(params, amount, options)
  add_soft_descriptors(params, options)
  add_level2_data(params, options)
  add_stored_credentials(params, options)
  add_external_three_ds(params, payment_method, options)

  commit(params, options)
end

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



69
70
71
72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 69

def capture(amount, authorization, options = {})
  params = { transaction_type: 'capture' }

  add_authorization_info(params, authorization)
  add_amount(params, amount, options)
  add_soft_descriptors(params, options)

  commit(params, options)
end

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



90
91
92
93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 90

def credit(amount, payment_method, options = {})
  params = { transaction_type: 'refund' }

  add_amount(params, amount, options)
  add_payment_method(params, payment_method, options)
  add_soft_descriptors(params, options)
  add_invoice(params, options)
  commit(params, options)
end

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 33

def purchase(amount, payment_method, options = {})
  params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' }

  add_invoice(params, options)
  add_reversal_id(params, options)
  add_customer_ref(params, options)
  add_reference_3(params, options)
  add_payment_method(params, payment_method, options)
  add_address(params, options)
  add_amount(params, amount, options)
  add_soft_descriptors(params, options)
  add_level2_data(params, options)
  add_stored_credentials(params, options)
  add_external_three_ds(params, payment_method, options)

  commit(params, options)
end

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



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

def refund(amount, authorization, options = {})
  params = { transaction_type: 'refund' }

  add_authorization_info(params, authorization)
  add_amount(params, (amount || amount_from_authorization(authorization)), options)
  add_soft_descriptors(params, options)
  add_invoice(params, options)

  commit(params, options)
end

#scrub(transcript) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 128

def scrub(transcript)
  transcript.
    gsub(%r((Token: )(\w|-)+), '\1[FILTERED]').
    gsub(%r((Apikey: )(\w|-)+), '\1[FILTERED]').
    gsub(%r((\\?"card_number\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r((\\?"cvv\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r((\\?"cvv\\?":\\?)\d+), '\1[FILTERED]').
    gsub(%r((\\?"account_number\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r((\\?"routing_number\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r((\\?card_number=)\d+(&?)), '\1[FILTERED]').
    gsub(%r((\\?cvv=)\d+(&?)), '\1[FILTERED]').
    gsub(%r((\\?apikey=)\w+(&?)), '\1[FILTERED]').
    gsub(%r{(\\?"credit_card\.card_number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
    gsub(%r{(\\?"credit_card\.cvv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
    gsub(%r{(\\?"apikey\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
    gsub(%r{(\\?"cavv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
    gsub(%r{(\\?"xid\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
end

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



100
101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 100

def store(payment_method, options = {})
  params = { transaction_type: 'store' }

  add_creditcard_for_tokenization(params, payment_method, options)

  commit(params, options)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 124

def supports_scrubbing?
  true
end

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



117
118
119
120
121
122
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 117

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

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



108
109
110
111
112
113
114
115
# File 'lib/active_merchant/billing/gateways/payeezy.rb', line 108

def void(authorization, options = {})
  params = { transaction_type: 'void' }

  add_authorization_info(params, authorization, options)
  add_amount(params, amount_from_authorization(authorization), options)

  commit(params, options)
end