Module: Proxypay
- Includes:
- HTTParty
- Defined in:
- lib/proxypay.rb,
lib/proxypay/version.rb
Constant Summary collapse
- VERSION =
"0.2.6"
Class Method Summary collapse
-
.get_customer(id, options = {}) ⇒ Object
get a customer by id.
-
.get_customers(options = {}) ⇒ Object
Get a list of customers.
-
.get_payments(options = {}) ⇒ Object
Fetch all availables payments that have not been acknowledged.
-
.get_reference(id, options = {}) ⇒ Object
Fetch a specific reference by his ID string.
-
.get_references(options = {}) ⇒ Object
Fetch all available references.
-
.new_customer(id, nome, telemovel, email, options = {}) ⇒ Object
Store a new customer or update one.
-
.new_payment(id, options = {}) ⇒ Object
Acknowledge a payment by submitting his ID.
-
.new_payments(ids, options = {}) ⇒ Object
Acknowledge multiple payments by submitting an array of ids.
-
.new_reference(amount, expiry_date, options = {}) ⇒ Object
Submit a request to create a new reference.
- .set_base_url(is_test = false) ⇒ Object
Class Method Details
.get_customer(id, options = {}) ⇒ Object
get a customer by id
64 65 66 67 68 |
# File 'lib/proxypay.rb', line 64 def self.get_customer(id, = {}) set_base_url(.delete(:is_test)) content = set_headers() get("/customers/#{id}", content).parsed_response end |
.get_customers(options = {}) ⇒ Object
Get a list of customers
56 57 58 59 60 61 |
# File 'lib/proxypay.rb', line 56 def self.get_customers( = {}) set_base_url(.delete(:is_test)) content = set_headers() content[:query] = .delete(:query) || {} get("/customers", content).parsed_response end |
.get_payments(options = {}) ⇒ Object
Fetch all availables payments that have not been acknowledged.
33 34 35 36 37 38 |
# File 'lib/proxypay.rb', line 33 def self.get_payments(={}) set_base_url(.delete(:is_test)) content = set_headers() content[:query] = .delete(:query) || {} get("/events/payments", content).parsed_response end |
.get_reference(id, options = {}) ⇒ Object
Fetch a specific reference by his ID string
18 19 20 21 22 |
# File 'lib/proxypay.rb', line 18 def self.get_reference(id, = {}) set_base_url(.delete(:is_test)) content = set_headers() get("/references/#{id}", content).parsed_response end |
.get_references(options = {}) ⇒ Object
Fetch all available references
10 11 12 13 14 15 |
# File 'lib/proxypay.rb', line 10 def self.get_references( = {}) set_base_url(.delete(:is_test)) content = set_headers() content[:query] = .delete(:query) || {} get("/references", content).parsed_response end |
.new_customer(id, nome, telemovel, email, options = {}) ⇒ Object
Store a new customer or update one
71 72 73 74 75 76 |
# File 'lib/proxypay.rb', line 71 def self.new_customer(id, nome, telemovel, email, = {}) set_base_url(.delete(:is_test)) content = set_headers() content[:body] = {:customer => {:name => nome.to_s, :mobile => telemovel.to_s, :email => email.to_s}}.to_json put("/customers/#{id}", content).parsed_response end |
.new_payment(id, options = {}) ⇒ Object
Acknowledge a payment by submitting his ID
41 42 43 44 45 |
# File 'lib/proxypay.rb', line 41 def self.new_payment(id, = {}) set_base_url(.delete(:is_test)) content = set_headers() delete("/events/payments/#{id}", content).parsed_response end |
.new_payments(ids, options = {}) ⇒ Object
Acknowledge multiple payments by submitting an array of ids
48 49 50 51 52 53 |
# File 'lib/proxypay.rb', line 48 def self.new_payments(ids, = {}) set_base_url(.delete(:is_test)) content = set_headers() content[:body] = { :ids => ids }.to_json delete("/events/payments", content).parsed_response end |
.new_reference(amount, expiry_date, options = {}) ⇒ Object
Submit a request to create a new reference
25 26 27 28 29 30 |
# File 'lib/proxypay.rb', line 25 def self.new_reference(amount, expiry_date, ={}) set_base_url(.delete(:is_test)) content = set_headers() content[:body] = {:reference => {:amount => amount.to_s, :expiry_date => expiry_date.to_s, custom_fields: (.delete(:custom_fields) || {})}}.to_json post("/references", content).parsed_response end |
.set_base_url(is_test = false) ⇒ Object
78 79 80 |
# File 'lib/proxypay.rb', line 78 def self.set_base_url(is_test = false) self.base_uri is_test == true ? "https://api.sandbox.proxypay.co.ao" : "https://api.proxypay.co.ao" end |