Class: CustomersCo
- Inherits:
-
OpenPayResource
- Object
- OpenPayResource
- CustomersCo
- Defined in:
- lib/openpay/colombia/customers_co.rb
Instance Attribute Summary
Attributes inherited from OpenPayResource
Instance Method Summary collapse
- #all_cards(customer) ⇒ Object
-
#all_charges(customer_id) ⇒ Object
return all charges for the given customer_id.
- #all_subscriptions(customer_id) ⇒ Object
-
#create_card(customer, card) ⇒ Object
Card.
-
#create_charge(customer_id, charge) ⇒ Object
Charges customers.create_charge(customer_id,charge).
-
#create_subscription(subscription, customer_id) ⇒ Object
def capture_charge(customer_id, charge_id) post(”, “#customer_id/charges/#charge_id/capture”) end.
- #delete_all_cards(customer_id) ⇒ Object
- #delete_all_subscriptions(customer_id) ⇒ Object
- #delete_card(customer, card_id) ⇒ Object
- #delete_subscription(customer_id, subscription_id) ⇒ Object
- #each_card(customer) ⇒ Object
- #each_subscription(customer_id) ⇒ Object
- #get_card(customer, card_id) ⇒ Object
-
#get_charge(customer_id, charge_id) ⇒ Object
gets a charge_id for a given customer_id.
- #get_subscription(customer_id, subscription_id) ⇒ Object
- #list_cards(customer, search_params) ⇒ Object
- #list_subscriptions(customer, search_params) ⇒ Object
-
#refund_charge(customer_id, charge_id, description) ⇒ Object
def cancel_charge(customer_id, charge_id) post(charge_id, “#customer_id/charges/#charge_id/cancel”) end.
- #update_subscription(subscription, customer, params) ⇒ Object
Methods inherited from OpenPayResource
#delete, #delete_all, #each, #env, #errors?, #get, #get_with_custom_url, #hash2json, #initialize, #json2hash, #list, #post, #put
Constructor Details
This class inherits a constructor from OpenPayResource
Instance Method Details
#all_cards(customer) ⇒ Object
162 163 164 |
# File 'lib/openpay/colombia/customers_co.rb', line 162 def all_cards(customer) get("#{customer}/cards") end |
#all_charges(customer_id) ⇒ Object
return all charges for the given customer_id
22 23 24 |
# File 'lib/openpay/colombia/customers_co.rb', line 22 def all_charges(customer_id) get("#{customer_id}/charges/") end |
#all_subscriptions(customer_id) ⇒ Object
103 104 105 |
# File 'lib/openpay/colombia/customers_co.rb', line 103 def all_subscriptions(customer_id) get("#{customer_id}/subscriptions/") end |
#create_card(customer, card) ⇒ Object
Card
131 132 133 |
# File 'lib/openpay/colombia/customers_co.rb', line 131 def create_card(customer, card) create(card, "#{customer}/cards") end |
#create_charge(customer_id, charge) ⇒ Object
Charges customers.create_charge(customer_id,charge)
7 8 9 |
# File 'lib/openpay/colombia/customers_co.rb', line 7 def create_charge(customer_id, charge) create(charge, "#{customer_id}/charges") end |
#create_subscription(subscription, customer_id) ⇒ Object
def capture_charge(customer_id, charge_id)
post('', "#{customer_id}/charges/#{charge_id}/capture")
end
def confirm_customer_capture(customer_id, charge_id, amount)
post(amount, "#{customer_id}/charges/#{charge_id}/capture")
end
#Payouts def create_payout(customer_id, payout)
post(payout, "#{customer_id}/payouts")
end
def all_payouts(customer_id)
get("#{customer_id}/payouts")
end
def get_payout(customer_id, payout_id)
get("#{customer_id}/payouts/#{payout_id}")
end
def each_payout(customer_id)
all_payouts(customer_id).each do |pay|
yield pay
end
end
def list_payouts(customer, search_params)
get("#{customer}/payouts#{search_params.to_s}")
end
#Transfers def create_transfer(customer_id, transfer)
post(transfer, "#{customer_id}/transfers")
end
def all_transfers(customer_id)
get("#{customer_id}/transfers/")
end
def list_transfers(customer, search_params)
get("#{customer}/transfers#{search_params.to_s}")
end
def get_transfer(customer_id, transfer_id)
get("#{customer_id}/transfers/#{transfer_id}")
end
def each_transfer(customer_id)
all_transfers(customer_id).each do |trans|
yield trans
end
end
Subscriptions
90 91 92 93 |
# File 'lib/openpay/colombia/customers_co.rb', line 90 def create_subscription(subscription, customer_id) #revisar la url post(subscription, "#{customer_id}/subscriptions") end |
#delete_all_cards(customer_id) ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'lib/openpay/colombia/customers_co.rb', line 143 def delete_all_cards(customer_id) if env == :production raise OpenpayException.new('This method is not supported on PRODUCTION', false) end each_card(customer_id) do |card| delete_card(customer_id, card['id']) end end |
#delete_all_subscriptions(customer_id) ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'lib/openpay/colombia/customers_co.rb', line 121 def delete_all_subscriptions(customer_id) if env == :production raise OpenpayException.new('This method is not supported on PRODUCTION', false) end all_subscriptions(customer_id).each do |sub| delete_subscription(customer_id, sub['id']) end end |
#delete_card(customer, card_id) ⇒ Object
139 140 141 |
# File 'lib/openpay/colombia/customers_co.rb', line 139 def delete_card(customer, card_id) delete("#{customer}/cards/#{card_id}") end |
#delete_subscription(customer_id, subscription_id) ⇒ Object
95 96 97 |
# File 'lib/openpay/colombia/customers_co.rb', line 95 def delete_subscription(customer_id, subscription_id) delete("#{customer_id}/subscriptions/#{subscription_id}") end |
#each_card(customer) ⇒ Object
152 153 154 155 156 |
# File 'lib/openpay/colombia/customers_co.rb', line 152 def each_card(customer) get("#{customer}/cards").each do |card| yield card end end |
#each_subscription(customer_id) ⇒ Object
111 112 113 114 115 |
# File 'lib/openpay/colombia/customers_co.rb', line 111 def each_subscription(customer_id) all_subscriptions(customer_id).each do |cust| yield cust end end |
#get_card(customer, card_id) ⇒ Object
135 136 137 |
# File 'lib/openpay/colombia/customers_co.rb', line 135 def get_card(customer, card_id) get("#{customer}/cards/#{card_id}") end |
#get_charge(customer_id, charge_id) ⇒ Object
gets a charge_id for a given customer_id
12 13 14 |
# File 'lib/openpay/colombia/customers_co.rb', line 12 def get_charge(customer_id, charge_id) get("#{customer_id}/charges/#{charge_id}") end |
#get_subscription(customer_id, subscription_id) ⇒ Object
99 100 101 |
# File 'lib/openpay/colombia/customers_co.rb', line 99 def get_subscription(customer_id, subscription_id) get("#{customer_id}/subscriptions/#{subscription_id}") end |
#list_cards(customer, search_params) ⇒ Object
158 159 160 |
# File 'lib/openpay/colombia/customers_co.rb', line 158 def list_cards(customer, search_params) get("#{customer}/cards#{search_params.to_s}") end |
#list_subscriptions(customer, search_params) ⇒ Object
107 108 109 |
# File 'lib/openpay/colombia/customers_co.rb', line 107 def list_subscriptions(customer, search_params) get("#{customer}/subscriptions#{search_params.to_s}") end |
#refund_charge(customer_id, charge_id, description) ⇒ Object
def cancel_charge(customer_id, charge_id)
post(charge_id, "#{customer_id}/charges/#{charge_id}/cancel")
end
30 31 32 |
# File 'lib/openpay/colombia/customers_co.rb', line 30 def refund_charge(customer_id, charge_id, description) post(description, "#{customer_id}/charges/#{charge_id}/refund") end |
#update_subscription(subscription, customer, params) ⇒ Object
117 118 119 |
# File 'lib/openpay/colombia/customers_co.rb', line 117 def update_subscription(subscription, customer, params) put(params, "#{customer}/subscriptions/#{subscription}") end |