Class: ChargesPe
- Inherits:
-
OpenPayResource
- Object
- OpenPayResource
- ChargesPe
- Defined in:
- lib/openpay/peru/charges_pe.rb
Instance Attribute Summary
Attributes inherited from OpenPayResource
Instance Method Summary collapse
- #all(customer_id = nil) ⇒ Object
- #create(charge, customer_id = nil) ⇒ Object
-
#each(customer_id = nil) ⇒ Object
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.
- #get(charge = '', customer_id = nil) ⇒ Object
- #list(search_params, customer_id = nil) ⇒ Object
Methods inherited from OpenPayResource
#delete, #delete_all, #env, #errors?, #get_with_custom_url, #hash2json, #initialize, #json2hash, #post, #put
Constructor Details
This class inherits a constructor from OpenPayResource
Instance Method Details
#all(customer_id = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/openpay/peru/charges_pe.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 |
#create(charge, customer_id = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/openpay/peru/charges_pe.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
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
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
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/openpay/peru/charges_pe.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/peru/charges_pe.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/peru/charges_pe.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 |