payoneer 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /public/system
8
+ /coverage/
9
+ /spec/tmp
10
+ **.orig
11
+ rerun.txt
12
+ pickle-email-*.html
13
+ config/initializers/secret_token.rb
14
+ config/secrets.yml
15
+ .idea
16
+ *.gem
17
+ ## Environment normalisation:
18
+ /.bundle
19
+ /vendor/bundle
20
+
21
+ # these should all be checked in to normalise the environment:
22
+ # Gemfile.lock, .ruby-version, .ruby-gemset
23
+
24
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
25
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ payoneer (0.1.0)
5
+ httparty (~> 0.13, >= 0.13.1)
6
+ nokogiri (~> 1.6, >= 1.6.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.6)
12
+ cane (2.6.2)
13
+ parallel
14
+ crack (0.4.2)
15
+ safe_yaml (~> 1.0.0)
16
+ diff-lcs (1.2.5)
17
+ httparty (0.13.1)
18
+ json (~> 1.8)
19
+ multi_xml (>= 0.5.2)
20
+ json (1.8.1)
21
+ mini_portile (0.5.3)
22
+ multi_xml (0.5.5)
23
+ nokogiri (1.6.1)
24
+ mini_portile (~> 0.5.0)
25
+ parallel (1.0.0)
26
+ rake (10.3.1)
27
+ rspec (3.0.0.beta2)
28
+ rspec-core (= 3.0.0.beta2)
29
+ rspec-expectations (= 3.0.0.beta2)
30
+ rspec-mocks (= 3.0.0.beta2)
31
+ rspec-core (3.0.0.beta2)
32
+ rspec-support (= 3.0.0.beta2)
33
+ rspec-expectations (3.0.0.beta2)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (= 3.0.0.beta2)
36
+ rspec-mocks (3.0.0.beta2)
37
+ rspec-support (= 3.0.0.beta2)
38
+ rspec-support (3.0.0.beta2)
39
+ safe_yaml (1.0.3)
40
+ timecop (0.7.1)
41
+ webmock (1.17.4)
42
+ addressable (>= 2.2.7)
43
+ crack (>= 0.3.2)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ cane (~> 2.6)
50
+ payoneer!
51
+ rake (~> 10.3)
52
+ rspec (~> 3.0.0.beta1)
53
+ timecop (~> 0.7)
54
+ webmock (~> 1.17)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Envato
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ payoneer-masspay
2
+ ================
3
+
4
+ Ruby Payoneer API
@@ -0,0 +1,16 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ require 'irb'
10
+ require 'irb/completion'
11
+
12
+ require 'payoneer'
13
+
14
+ ARGV.clear
15
+ IRB.start
16
+ end
@@ -0,0 +1,6 @@
1
+ require 'payoneer/configuration'
2
+ require 'payoneer/request'
3
+ require 'payoneer/perform_payout_payment_request'
4
+ require 'payoneer/get_token_request'
5
+ require 'payoneer/perform_payout_payment_response'
6
+ require 'payoneer/get_token_response'
@@ -0,0 +1,13 @@
1
+ module Payoneer
2
+ class Configuration
3
+ class << self
4
+ attr_accessor :environment, :partner_id, :username, :password, :program_id, :client_cert, :client_cert_passwd
5
+
6
+ def configure
7
+ @configuration ||= Payoneer::Configuration.tap do |config|
8
+ yield config
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'payoneer/configuration'
2
+
3
+ module Payoneer
4
+ class GetTokenRequest
5
+ def get_token(payee_id, callback_url)
6
+ Payoneer::Request.new.execute "GetToken", Payoneer::GetTokenResponse, credentials.merge({
7
+ :p4 => payee_id, :p6 => callback_url
8
+ })
9
+ end
10
+
11
+ def credentials
12
+ { :p1 => Payoneer::Configuration.username,
13
+ :p2 => Payoneer::Configuration.password,
14
+ :p3 => Payoneer::Configuration.partner_id }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Payoneer
2
+ class GetTokenResponse
3
+ attr_accessor :url
4
+
5
+ def initialize(payload)
6
+ @url = payload
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require 'payoneer/configuration'
2
+
3
+ module Payoneer
4
+ class PerformPayoutPaymentRequest
5
+ def perform_payment(internal_payment_id, internal_payee_id, amount, description)
6
+ Payoneer::Request.new.execute "PerformPayoutPayment", Payoneer::PerformPayoutPaymentResponse, credentials.merge({
7
+ :p5 => internal_payment_id, :p6 => internal_payee_id, :p7 => amount,
8
+ :p8 => description, :p9 => payment_date
9
+ })
10
+ end
11
+
12
+ def credentials
13
+ { :p1 => Payoneer::Configuration.username,
14
+ :p2 => Payoneer::Configuration.password,
15
+ :p3 => Payoneer::Configuration.partner_id,
16
+ :p4 => Payoneer::Configuration.program_id }
17
+ end
18
+
19
+ def payment_date
20
+ Time.now.utc.strftime("%m/%d/%Y %H:%M:%S")
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'nokogiri'
2
+
3
+ module Payoneer
4
+ class PerformPayoutPaymentResponse
5
+ def initialize(payload)
6
+ @doc = Nokogiri::Slop(payload)
7
+ end
8
+
9
+ def success?
10
+ status_code === "000"
11
+ end
12
+
13
+ def status_code
14
+ @doc.PerformPayoutPayment.Status.content
15
+ end
16
+
17
+ def error_message
18
+ @doc.PerformPayoutPayment.Description.content
19
+ end
20
+
21
+ def payoneer_id
22
+ @doc.PerformPayoutPayment.PayoneerID.content
23
+ end
24
+
25
+ def payment_id
26
+ @doc.PerformPayoutPayment.PaymentID.content
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'payoneer/configuration'
2
+ require 'httparty'
3
+
4
+ module Payoneer
5
+ API_PATH = "/payouts/HttpApi/Api.aspx"
6
+
7
+ class Request
8
+ def execute(method_name, response_klass, params = {})
9
+ HTTParty.pkcs12(Payoneer::Configuration.client_cert, Payoneer::Configuration.client_cert_passwd) if Payoneer::Configuration.client_cert
10
+
11
+ response = HTTParty.get(full_url, :query => { :mname => method_name }.merge(params))
12
+ response_klass.new(response.body)
13
+ end
14
+
15
+ def full_url
16
+ api_url + API_PATH
17
+ end
18
+
19
+ def api_url
20
+ if Payoneer::Configuration.environment == :production
21
+ "https://api.payoneer.com"
22
+ else
23
+ "https://api.sandbox.payoneer.com"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'payoneer'
3
+ s.version = '0.1.' + (ENV['BUILD_VERSION'] || '0')
4
+ s.date = '2014-04-23'
5
+ s.summary = "Payoneer API"
6
+ s.description = "Interface to the Payoneer API"
7
+ s.authors = ["Envato"]
8
+ s.email = 'studio.dev@envato.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.license = 'MIT'
11
+ s.homepage = 'https://github.com/envato/payoneer'
12
+
13
+ s.add_dependency 'httparty', '~> 0.13', '>= 0.13.1'
14
+ s.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.1'
15
+
16
+ s.add_development_dependency 'rake', '~> 10.3'
17
+ s.add_development_dependency 'rspec', '~> 3.0.0.beta1'
18
+ s.add_development_dependency 'cane', '~> 2.6'
19
+ s.add_development_dependency 'webmock', '~> 1.17'
20
+ s.add_development_dependency 'timecop', '~> 0.7'
21
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'performing a payout' do
4
+ let(:success_body) { '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><PerformPayoutPayment><Description></Description><PaymentID>333</PaymentID><Status>000</Status><PayoneerID>1234</PayoneerID></PerformPayoutPayment>' }
5
+ let(:fail_body) { '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><PerformPayoutPayment><Description>Payee does not exist</Description><PaymentID>666</PaymentID><Status>002</Status><PayoneerID>8888</PayoneerID></PerformPayoutPayment>' }
6
+
7
+ before do
8
+ Timecop.freeze
9
+
10
+ Payoneer::Configuration.environment = :sandbox
11
+ Payoneer::Configuration.partner_id = 'p90001'
12
+ Payoneer::Configuration.username = 'frankie'
13
+ Payoneer::Configuration.password = 'bloggs'
14
+ Payoneer::Configuration.program_id = 'program12345'
15
+
16
+ stub_request(:get, "https://api.sandbox.payoneer.com/payouts/HttpApi/Api.aspx?" + request_params).to_return(:body => response_body)
17
+ end
18
+
19
+ context 'when a successful payout is made' do
20
+ let(:response_body) { success_body }
21
+ let(:request_params) { "mname=PerformPayoutPayment&p1=frankie&p2=bloggs&p3=p90001&p4=program12345&p5=1234&p6=44&p7=300&p8=Hello Worlds&p9=#{Time.now.utc.strftime("%m/%d/%Y %H:%M:%S")}" }
22
+
23
+ it 'returns success' do
24
+ response = Payoneer::PerformPayoutPaymentRequest.new.perform_payment 1234, 44, 300, 'Hello Worlds'
25
+ expect(response.success?).to eq(true)
26
+ end
27
+ end
28
+
29
+ context 'when a failed payout is made' do
30
+ let(:response_body) { fail_body }
31
+ let(:request_params) { "mname=PerformPayoutPayment&p1=frankie&p2=bloggs&p3=p90001&p4=program12345&p5=1234&p6=44&p7=300&p8=Hello Worlds&p9=#{Time.now.utc.strftime("%m/%d/%Y %H:%M:%S")}" }
32
+
33
+ it 'returns failure' do
34
+ response = Payoneer::PerformPayoutPaymentRequest.new.perform_payment 1234, 44, 300, 'Hello Worlds'
35
+ expect(response.success?).to eq(false)
36
+ expect(response.error_message).to eq("Payee does not exist")
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'payoneer'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
7
+ require 'timecop'
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: payoneer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Envato
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.13'
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.13.1
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.13'
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.13.1
36
+ - !ruby/object:Gem::Dependency
37
+ name: nokogiri
38
+ requirement: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '1.6'
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.6.1
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: 1.6.1
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '10.3'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ version: '10.3'
74
+ - !ruby/object:Gem::Dependency
75
+ name: rspec
76
+ requirement: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: 3.0.0.beta1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0.beta1
90
+ - !ruby/object:Gem::Dependency
91
+ name: cane
92
+ requirement: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '2.6'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: '2.6'
106
+ - !ruby/object:Gem::Dependency
107
+ name: webmock
108
+ requirement: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ~>
112
+ - !ruby/object:Gem::Version
113
+ version: '1.17'
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: '1.17'
122
+ - !ruby/object:Gem::Dependency
123
+ name: timecop
124
+ requirement: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ version: '0.7'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ~>
136
+ - !ruby/object:Gem::Version
137
+ version: '0.7'
138
+ description: Interface to the Payoneer API
139
+ email: studio.dev@envato.com
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - .gitignore
145
+ - Gemfile
146
+ - Gemfile.lock
147
+ - LICENSE
148
+ - README.md
149
+ - Rakefile
150
+ - lib/payoneer.rb
151
+ - lib/payoneer/configuration.rb
152
+ - lib/payoneer/get_token_request.rb
153
+ - lib/payoneer/get_token_response.rb
154
+ - lib/payoneer/perform_payout_payment_request.rb
155
+ - lib/payoneer/perform_payout_payment_response.rb
156
+ - lib/payoneer/request.rb
157
+ - payoneer.gemspec
158
+ - spec/integration/payoneer/perform_payout_payment_request_spec.rb
159
+ - spec/spec_helper.rb
160
+ homepage: https://github.com/envato/payoneer
161
+ licenses:
162
+ - MIT
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ none: false
169
+ requirements:
170
+ - - ! '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
174
+ none: false
175
+ requirements:
176
+ - - ! '>='
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 1.8.21
182
+ signing_key:
183
+ specification_version: 3
184
+ summary: Payoneer API
185
+ test_files: []