Class: Compropago::Client
- Inherits:
-
Object
- Object
- Compropago::Client
- Defined in:
- lib/compropago/client.rb
Constant Summary collapse
- BASE_URI =
'https://api.compropago.com/v1'
Instance Method Summary collapse
- #create_charge(product_price, product_name, customer_name, customer_email, payment_type, product_id = nil, image_url = nil) ⇒ Object
-
#initialize(api_key = '', options = {}) ⇒ Client
constructor
A new instance of Client.
- #send_payment_instructions(payment_id, customer_phone, customer_company_phone) ⇒ Object
- #verify_charge(payment_id) ⇒ Object
Constructor Details
Instance Method Details
#create_charge(product_price, product_name, customer_name, customer_email, payment_type, product_id = nil, image_url = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/compropago/client.rb', line 17 def create_charge(product_price, product_name, customer_name, customer_email, payment_type, product_id=nil, image_url=nil) uri = URI.parse(BASE_URI+'/charges') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(uri.request_uri) request.basic_auth @api_key, '' params = { "product_price" => product_price, "product_name" => product_name, "customer_name" => customer_name, "customer_email" => customer_email, "payment_type" => payment_type, "product_id" => product_id, "image_url" => image_url } request.set_form_data(params) http.request(request) end |
#send_payment_instructions(payment_id, customer_phone, customer_company_phone) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/compropago/client.rb', line 46 def send_payment_instructions(payment_id, customer_phone, customer_company_phone) uri = URI.parse(BASE_URI+'/charges/'+payment_id.to_s+'/sms') http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(uri.request_uri) request.basic_auth @api_key, '' params = { "payment_id" => payment_id.to_s, "customer_phone" => customer_phone.to_s, "customer_company_phone" => customer_company_phone } request.set_form_data(params) http.request(request) end |
#verify_charge(payment_id) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/compropago/client.rb', line 36 def verify_charge(payment_id) uri = URI.parse(BASE_URI+'/charges/'+payment_id) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri.request_uri) request.basic_auth @api_key, '' http.request(request) end |