compropago 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in compropago.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 jogam5
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # Compropago
2
+
3
+ This gem helps you integrate ComproPago's API to your ruby app.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'compropago'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install compropago
18
+
19
+ ## Usage
20
+
21
+ ### Authentication
22
+
23
+ We encourage you to set your API keys in an environment variable instead of hardcoding your API keys.
24
+
25
+ compropago = Compropago::Client.new(ENV['COMPROPAGO_API_KEY'])
26
+
27
+ Once you have created an instance, you can call the methods described in the <a href="http://compropago.com/documentacion/api">api reference</a> on it.
28
+
29
+
30
+ ## Examples
31
+
32
+ ### Create a charge
33
+
34
+ Creating a charge using only the required params <code>product_price</code>, <code>product_name</code>, <code>customer_name</code>, <code>customer_email</code>, <code>payment_type</code>.
35
+
36
+ # create_charge product_price, product_name, customer_name, customer_email, payment_type
37
+
38
+ compropago.create_charge 3150.0, 'iphone5s', 'Irma Sanz', 'no-replay@compropago.com', 'OXXO'
39
+
40
+ Adding the optional params <code>product_id</code> and <code>image_url</code> to the request:
41
+
42
+ # create_charge product_price, product_name, customer_name, customer_email, payment_type, product_id, image_url
43
+
44
+ compropago.create_charge 3150.0, 'iphone5s', 'Irma Sanz', 'no-replay@email.com', 'OXXO', '5ku8g', 'image.jpg'
45
+
46
+ ### Verify a charge
47
+
48
+ Verify a charge previously made.
49
+
50
+ # verify_charge payment_id
51
+
52
+ compropago.verify_charge 'b75076ac-a94b-478a-945c-c2caf85be668'
53
+
54
+ ### SMS payment instructions
55
+
56
+ Send payment instructions over SMS.
57
+
58
+ # send_payment_instructions payment_id, customer_phone, customer_company_phone
59
+
60
+ compropago.verify_charge 'b75076ac-a94b-478a-945c-c2caf85be668', '2221515805', 'TELCEL'
61
+
62
+ ## Contributing
63
+
64
+ 1. Fork it
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'compropago/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "compropago"
8
+ spec.version = Compropago::VERSION
9
+ spec.authors = ["Jose Gabriel"]
10
+ spec.email = ["soporte@compropago.com"]
11
+ spec.description = %q{Ruby gem for making calls to ComproPago API}
12
+ spec.summary = %q{Ruby bindings for ComproPago}
13
+ spec.homepage = "http://compropago.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
data/lib/compropago.rb ADDED
@@ -0,0 +1,13 @@
1
+ # API spec at http://compropago.com/documentacion/api
2
+ require 'net/https'
3
+ require 'uri'
4
+
5
+ # Version
6
+ require 'compropago/version'
7
+
8
+ # Resources
9
+ require 'compropago/client'
10
+
11
+ module Compropago
12
+
13
+ end
@@ -0,0 +1,63 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+
4
+ module Compropago
5
+ class Client
6
+
7
+ BASE_URI = 'https://api.compropago.com/v1'
8
+
9
+ def initialize(api_key='', options={})
10
+ @api_key = api_key
11
+
12
+ #defaults
13
+ options[:base_uri] ||= BASE_URI
14
+ @base_uri = options[:base_uri]
15
+ end
16
+
17
+ def create_charge product_price, product_name, customer_name, customer_email, payment_type, product_id=nil, image_url=nil
18
+ uri = URI.parse(BASE_URI+'/charges')
19
+ http = Net::HTTP.new(uri.host, uri.port)
20
+ http.use_ssl = true
21
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
22
+ request = Net::HTTP::Post.new(uri.request_uri)
23
+ request.basic_auth @api_key, ''
24
+ params = { "product_price" => product_price,
25
+ "product_name" => product_name,
26
+ "customer_name" => customer_name,
27
+ "customer_email" => customer_email,
28
+ "payment_type" => payment_type,
29
+ "product_id" => product_id,
30
+ "image_url" => image_url,
31
+ "product_id" => product_id,
32
+ "image_url" => image_url
33
+ }
34
+ request.set_form_data(params)
35
+ response = http.request(request)
36
+ end
37
+
38
+ def verify_charge payment_id
39
+ uri = URI.parse(BASE_URI+'/charges/'+payment_id)
40
+ http = Net::HTTP.new(uri.host, uri.port)
41
+ http.use_ssl = true
42
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
+ request = Net::HTTP::Get.new(uri.request_uri)
44
+ request.basic_auth @api_key, ''
45
+ response = http.request(request)
46
+ end
47
+
48
+ def send_payment_instructions payment_id, customer_phone, customer_company_phone
49
+ uri = URI.parse(BASE_URI+'/charges/'+payment_id.to_s+'/sms')
50
+ http = Net::HTTP.new(uri.host, uri.port)
51
+ http.use_ssl = true
52
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
53
+ request = Net::HTTP::Post.new(uri.request_uri)
54
+ request.basic_auth @api_key, ''
55
+ params = { "payment_id" => payment_id.to_s,
56
+ "customer_phone" => customer_phone.to_s,
57
+ "customer_company_phone" => customer_company_phone
58
+ }
59
+ request.set_form_data(params)
60
+ response = http.request(request)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module Compropago
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compropago
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jose Gabriel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Ruby gem for making calls to ComproPago API
47
+ email:
48
+ - soporte@compropago.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - compropago.gemspec
59
+ - lib/compropago.rb
60
+ - lib/compropago/client.rb
61
+ - lib/compropago/version.rb
62
+ homepage: http://compropago.com
63
+ licenses:
64
+ - MIT
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ segments:
76
+ - 0
77
+ hash: -2316725995645849706
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ segments:
85
+ - 0
86
+ hash: -2316725995645849706
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.25
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Ruby bindings for ComproPago
93
+ test_files: []