Class: ChargesCo
Instance Attribute Summary
#api_hook
Instance Method Summary
collapse
#delete, #delete_all, #env, #errors?, #get_with_custom_url, #hash2json, #initialize, #json2hash, #post, #put
Instance Method Details
#all(customer_id = nil) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/openpay/colombia/charges_co.rb', line 19
def all(customer_id = nil)
if customer_id
customers = @api_hook.create(:customers)
customers.all_charges(customer_id)
else
super ''
end
end
|
#cancel(transaction_id, customer_id = nil) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/openpay/colombia/charges_co.rb', line 28
def cancel(transaction_id, customer_id = nil)
if customer_id
customers = @api_hook.create(:customers)
customers.cancel_charge(customer_id, transaction_id)
else
post('', transaction_id + '/cancel')
end
end
|
#create(charge, customer_id = nil) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/openpay/colombia/charges_co.rb', line 5
def create(charge, customer_id = nil)
amount = charge[:amount].to_s.split('.')
if amount.length > 0
LOG.warn "The amount have decimals. Revoming.."
end
charge[:amount] = amount[0]
if customer_id
customers = @api_hook.create(:customers)
customers.create_charge(customer_id, charge)
else
super charge
end
end
|
#each(customer_id = nil) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/openpay/colombia/charges_co.rb', line 46
def each(customer_id = nil)
if customer_id
all(customer_id).each do |card|
yield card
end
else
all.each do |card|
yield card
end
end
end
|
#get(charge = '', customer_id = nil) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/openpay/colombia/charges_co.rb', line 58
def get(charge = '', customer_id = nil)
if customer_id
customers = @api_hook.create(:customers)
customers.get_charge(customer_id, charge)
else
super charge
end
end
|
#list(search_params, customer_id = nil) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/openpay/colombia/charges_co.rb', line 67
def list(search_params, customer_id = nil)
if customer_id
customers = @api_hook.create(:customers)
customers.list_charges(customer_id, search_params)
else
super search_params
end
end
|
#refund(transaction_id, description, customer_id = nil) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/openpay/colombia/charges_co.rb', line 37
def refund(transaction_id, description, customer_id = nil)
if customer_id
customers = @api_hook.create(:customers)
customers.refund_charge(customer_id, transaction_id, description)
else
post(description, transaction_id + '/refund')
end
end
|