Class: ActiveMerchant::Billing::PayboxDirectGateway

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

Constant Summary collapse

API_VERSION =

Payment API Version

'00103'
TRANSACTIONS =

Transactions hash

{
  :authorization => '00001',
  :capture => '00002',
  :purchase => '00003',
  :unreferenced_credit => '00004',
  :void => '00005',
  :refund => '00014'
}
CURRENCY_CODES =
{
  "AUD"=> '036',
  "CAD"=> '124',
  "CZK"=> '203',
  "DKK"=> '208',
  "HKD"=> '344',
  "ICK"=> '352',
  "JPY"=> '392',
  "NOK"=> '578',
  "SGD"=> '702',
  "SEK"=> '752',
  "CHF"=> '756',
  "GBP"=> '826',
  "USD"=> '840',
  "EUR"=> '978'
}
SUCCESS_CODES =
['00000']
UNAVAILABILITY_CODES =
['00001', '00097', '00098']
SUCCESS_MESSAGE =
'The transaction was approved'
FAILURE_MESSAGE =
'The transaction failed'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ PayboxDirectGateway

Returns a new instance of PayboxDirectGateway.



61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/paybox_direct.rb', line 61

def initialize(options = {})
  requires!(options, :login, :password)
  @options = options
  super
end

Instance Method Details

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



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

def authorize(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  commit('authorization', money, post)
end

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



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

def capture(money, authorization, options = {})
  requires!(options, :order_id)
  post = {}
  add_invoice(post, options)
  post[:numappel] = authorization[0,10]
  post[:numtrans] = authorization[10,10]
  commit('capture', money, post)
end

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



100
101
102
103
# File 'lib/active_merchant/billing/gateways/paybox_direct.rb', line 100

def credit(money, identification, options = {})
  deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, identification, options)
end

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



74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/paybox_direct.rb', line 74

def purchase(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  commit('purchase', money, post)
end

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



105
106
107
108
109
110
# File 'lib/active_merchant/billing/gateways/paybox_direct.rb', line 105

def refund(money, identification, options = {})
  post = {}
  add_invoice(post, options)
  add_reference(post, identification)
  commit('refund', money, post)
end

#test?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/active_merchant/billing/gateways/paybox_direct.rb', line 112

def test?
  @options[:test] || Base.gateway_mode == :test
end

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



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

def void(identification, options = {})
  requires!(options, :order_id, :amount)
  post ={}
  add_invoice(post, options)
  add_reference(post, identification)
  post[:porteur] = '000000000000000'
  post[:dateval] = '0000'
  commit('void', options[:amount], post)
end