Class: Charges
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
5
6
7
8
9
10
11
12
|
# File 'lib/openpay/charges.rb', line 5
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
14
15
16
17
18
19
20
21
|
# File 'lib/openpay/charges.rb', line 14
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
|
#capture(transaction_id, customer_id = nil) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/openpay/charges.rb', line 32
def capture(transaction_id, customer_id=nil)
if customer_id
customers=@api_hook.create(:customers)
customers.capture_charge(customer_id, transaction_id)
else
post('', transaction_id+'/capture')
end
end
|
#confirm_capture(options) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/openpay/charges.rb', line 41
def confirm_capture(options)
customer_id = options.fetch(:customer_id) { '' }
transaction_id = options.fetch(:transaction_id)
amount = options.fetch(:amount)
if amount.nil? or transaction_id.nil?
raise OpenpayException.new
end
amount_hash = { amount: amount }
unless customer_id.empty?
customers=@api_hook.create(:customers)
customers.confirm_customer_capture(customer_id, transaction_id, amount_hash)
else
post(amount_hash, transaction_id+'/capture')
end
end
|
#create(charge, customer_id = nil) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/openpay/charges.rb', line 83
def create(charge, customer_id=nil)
if customer_id
customers=@api_hook.create(:customers)
customers.create_charge(customer_id, charge)
else
super charge
end
end
|
#each(customer_id = nil) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/openpay/charges.rb', line 62
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
74
75
76
77
78
79
80
81
|
# File 'lib/openpay/charges.rb', line 74
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
92
93
94
95
96
97
98
99
|
# File 'lib/openpay/charges.rb', line 92
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
23
24
25
26
27
28
29
30
|
# File 'lib/openpay/charges.rb', line 23
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
|