Class: BanortePayworks::SimpleTPV

Inherits:
Object
  • Object
show all
Defined in:
lib/banorte_payworks/simple_tpv.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ SimpleTPV

Returns a new instance of SimpleTPV.



29
30
31
# File 'lib/banorte_payworks/simple_tpv.rb', line 29

def initialize(config = {})
  self.config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



27
28
29
# File 'lib/banorte_payworks/simple_tpv.rb', line 27

def config
  @config
end

Instance Method Details

#do_payment(order_id, card_number, exp_date, cvv, amount) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/banorte_payworks/simple_tpv.rb', line 33

def do_payment(order_id, card_number, exp_date, cvv, amount)
  do_transaction card_number: card_number,
                 exp_date: exp_date,
                 cvv: cvv,
                 amount: amount,
                 order_id: order_id,
                 response_path: 'http://sample.net/',
                 type: BanortePayworks::TYPE[:auth]
end

#do_transaction(properties = {}) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/banorte_payworks/simple_tpv.rb', line 55

def do_transaction(properties = {})
  return_eval BanorteTransaction.from_post payworks_request(properties).first do |protocol|
    protocol.card_number = properties[:card_number]
    protocol.cvv = properties[:cvv]
    protocol.exp_date = properties[:exp_date]
    protocol.validate!
  end
end

#void(transaction) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/banorte_payworks/simple_tpv.rb', line 43

def void(transaction)
  do_transaction order_id: transaction.order_id,
                 amount: transaction.amount,
                 authnum: transaction.authnum,
                 card_number: transaction.card_number,
                 exp_date: transaction.exp_date,
                 cvv: transaction.cvv,
                 response_path: 'http://sample.net/',
                 type: BanortePayworks::TYPE[:void]

end