zooz_payments 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.rbc
2
+ *.sassc
3
+ .sass-cache
4
+ capybara-*.html
5
+ .rspec
6
+ .rvmrc
7
+ /.bundle
8
+ /vendor/bundle
9
+ /log/*
10
+ /tmp/*
11
+ /db/*.sqlite3
12
+ /public/system/*
13
+ /coverage/
14
+ /spec/tmp/*
15
+ **.orig
16
+ rerun.txt
17
+ pickle-email-*.html
18
+ .project
19
+ config/initializers/secret_token.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zooz_payments.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zooz_payments (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ httparty (0.11.0)
11
+ multi_json (~> 1.0)
12
+ multi_xml (>= 0.5.2)
13
+ multi_json (1.7.9)
14
+ multi_xml (0.5.5)
15
+ rake (10.1.0)
16
+ rspec (2.12.0)
17
+ rspec-core (~> 2.12.0)
18
+ rspec-expectations (~> 2.12.0)
19
+ rspec-mocks (~> 2.12.0)
20
+ rspec-core (2.12.2)
21
+ rspec-expectations (2.12.1)
22
+ diff-lcs (~> 1.1.3)
23
+ rspec-mocks (2.12.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ httparty
30
+ rake
31
+ rspec (~> 2.6)
32
+ zooz_payments!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 vitalim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Vitali Margolin
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,46 @@
1
+ # Zooz payments
2
+
3
+ zooz_payments gem is a ruby wrapper for zooz Affiliate Network
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'zooz_payments'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install zooz_payments
18
+
19
+ ## Usage
20
+
21
+ Create initializers/zooz.rb
22
+
23
+ ZoozPayments.setup do |config|
24
+ config.sandbox = true # boolean
25
+ config.unique_id = ''
26
+ config.app_key = ''
27
+ config.response_type = '' # default 'NVP'
28
+ end
29
+
30
+
31
+ ## Sample
32
+
33
+ api = ZoozPayments::Api.new
34
+ response = api.open_transaction('openTrx',100,'USD',{})
35
+ response = verify_transaction('verifyTrx', 'transaction_id','transaction_display_id',{})
36
+
37
+
38
+
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ require 'zooz_payments/version'
2
+ require 'zooz_payments/api'
3
+
4
+ module ZoozPayments
5
+ class << self
6
+ attr_accessor :sandbox, :unique_id,:app_key,:response_type,:url
7
+
8
+ # initializer with all the configuration values
9
+ def setup
10
+ self.response_type = 'NVP'
11
+ yield self
12
+ self.url = self.sandbox ? 'https://sandbox.zooz.co/mobile/SecuredWebServlet':'https://app.zooz.com/mobile/SecuredWebServlet'
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ require 'httparty'
2
+
3
+ module ZoozPayments
4
+ class Api
5
+
6
+ def initialize
7
+ @errors = []
8
+ @params = {}
9
+ end
10
+
11
+ def open_transaction(cmd,amount,currency_code,optional_args = {})
12
+ return false unless self.valid?
13
+
14
+ args = {'cmd' => cmd, 'amount' => amount, 'currencyCode' => currency_code}.merge(optional_args)
15
+ http_response = HTTParty.post(ZoozPayments.url,
16
+ :format => :plain,
17
+ :query => args,
18
+ :headers => {
19
+ 'ZooZ-Unique-ID' => ZoozPayments.unique_id,
20
+ 'ZooZ-App-Key' => ZoozPayments.app_key,
21
+ 'ZooZ-Response-Type' => ZoozPayments.response_type,
22
+ })
23
+ CGI.parse(http_response.body)
24
+ end
25
+
26
+ def verify_transaction(cmd, transaction_id,transaction_display_id,optional_args={})
27
+ return false unless self.valid?
28
+
29
+ args = {'cmd' => cmd, 'transactionID' => transaction_id, 'transactionDisplayID' => transaction_display_id}.merge(optional_args)
30
+ http_response = HTTParty.post(ZoozPayments.url, :format => :plain,
31
+ :query => args,
32
+ :headers => {
33
+ 'ZooZ-Unique-ID' => ZoozPayments.unique_id,
34
+ 'ZooZ-App-Key' => ZoozPayments.app_key,
35
+ 'ZooZ-Response-Type' => ZoozPayments.response_type,
36
+ })
37
+ CGI.parse(http_response.body)
38
+ end
39
+
40
+ def valid?
41
+ @errors = []
42
+ @errors << 'unique_id is required' if ZoozPayments.unique_id.nil?
43
+ @errors << 'app_key is required' if ZoozPayments.app_key.nil?
44
+ @errors << 'response_type is required' if ZoozPayments.response_type.nil?
45
+ @errors.empty?
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module ZoozPayments
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'zooz_payments'
2
+
3
+ describe ZoozPayments::Api do
4
+
5
+ it 'opens transactions' do
6
+ api = ZoozPayments::Api.new
7
+ response = api.open_transaction('openTrx',100,'USD',{})
8
+ response.should_not be_nil
9
+ response.should_not be_false
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'zooz_payments'
@@ -0,0 +1,9 @@
1
+ require 'zooz_payments'
2
+
3
+ describe ZoozPayments do
4
+ it 'should have a version number' do
5
+ ZoozPayments::VERSION.should_not be_nil
6
+ end
7
+
8
+ end
9
+
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zooz_payments/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'zooz_payments'
8
+ gem.version = ZoozPayments::VERSION
9
+ gem.authors = ['Vitali Margolin']
10
+ gem.email = %w(vitali.m86@gmail.com)
11
+ gem.description = %q{Zooz payments mobile api}
12
+ gem.summary = %q{Zooz payments mobile api}
13
+ gem.homepage = ''
14
+ gem.license = 'MIT'
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = %w(lib)
20
+
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'httparty'
23
+ gem.add_development_dependency 'rspec', '~> 2.6'
24
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zooz_payments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vitali Margolin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
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: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: httparty
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
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ description: Zooz payments mobile api
63
+ email:
64
+ - vitali.m86@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rspec
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - LICENSE
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - lib/zooz_payments.rb
78
+ - lib/zooz_payments/api.rb
79
+ - lib/zooz_payments/version.rb
80
+ - spec/models/api_spec.rb
81
+ - spec/spec_helper.rb
82
+ - spec/zooz_payments_spec.rb
83
+ - zooz_payments.gemspec
84
+ homepage: ''
85
+ licenses:
86
+ - MIT
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ segments:
98
+ - 0
99
+ hash: -56754250615222887
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ segments:
107
+ - 0
108
+ hash: -56754250615222887
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 1.8.24
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Zooz payments mobile api
115
+ test_files:
116
+ - spec/models/api_spec.rb
117
+ - spec/spec_helper.rb
118
+ - spec/zooz_payments_spec.rb