edools_mymoip 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +15 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +128 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +3 -0
- data/Rakefile +10 -0
- data/lib/mymoip.rb +57 -0
- data/lib/mymoip/bank_debit.rb +22 -0
- data/lib/mymoip/commission.rb +54 -0
- data/lib/mymoip/credit_card.rb +73 -0
- data/lib/mymoip/exceptions.rb +15 -0
- data/lib/mymoip/formatter.rb +23 -0
- data/lib/mymoip/instruction.rb +134 -0
- data/lib/mymoip/json_parser.rb +11 -0
- data/lib/mymoip/payer.rb +75 -0
- data/lib/mymoip/payment.rb +10 -0
- data/lib/mymoip/payment_methods.rb +46 -0
- data/lib/mymoip/payment_slip.rb +74 -0
- data/lib/mymoip/payments/bank_debit_payment.rb +27 -0
- data/lib/mymoip/payments/credit_card_payment.rb +53 -0
- data/lib/mymoip/payments/payment_slip_payment.rb +12 -0
- data/lib/mymoip/purchase.rb +40 -0
- data/lib/mymoip/request.rb +34 -0
- data/lib/mymoip/requests/payment_request.rb +53 -0
- data/lib/mymoip/requests/transparent_request.rb +36 -0
- data/lib/mymoip/validators.rb +12 -0
- data/lib/mymoip/version.rb +3 -0
- data/mymoip.gemspec +30 -0
- data/test/fixtures/fixture.rb +73 -0
- data/test/fixtures/vcr_cassettes/payment_request.yml +37 -0
- data/test/fixtures/vcr_cassettes/payment_request_with_payment_slip.yml +32 -0
- data/test/fixtures/vcr_cassettes/transparent_request.yml +34 -0
- data/test/fixtures/vcr_cassettes/transparent_request_with_commissions.yml +35 -0
- data/test/lib/test_bank_debit.rb +36 -0
- data/test/lib/test_bank_debit_payment.rb +32 -0
- data/test/lib/test_commission.rb +121 -0
- data/test/lib/test_credit_card_payment.rb +107 -0
- data/test/lib/test_creditcard.rb +206 -0
- data/test/lib/test_formatter.rb +49 -0
- data/test/lib/test_instruction.rb +243 -0
- data/test/lib/test_mymoip.rb +79 -0
- data/test/lib/test_payer.rb +249 -0
- data/test/lib/test_payment.rb +15 -0
- data/test/lib/test_payment_methods.rb +54 -0
- data/test/lib/test_payment_request.rb +120 -0
- data/test/lib/test_payment_slip.rb +78 -0
- data/test/lib/test_payment_slip_payment.rb +8 -0
- data/test/lib/test_purchase.rb +109 -0
- data/test/lib/test_request.rb +88 -0
- data/test/lib/test_transparent_request.rb +71 -0
- data/test/lib/test_validators.rb +13 -0
- data/test/live_test.rb +4 -0
- data/test/test_helper.rb +17 -0
- metadata +251 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class TestTransparentRequest < Test::Unit::TestCase
|
4
|
+
def test_http_method_as_post
|
5
|
+
assert_equal :post, MyMoip::TransparentRequest::HTTP_METHOD
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_path
|
9
|
+
assert_equal "/ws/alpha/EnviarInstrucao/Unica", MyMoip::TransparentRequest::PATH
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_auth_requirement
|
13
|
+
assert_equal true, MyMoip::TransparentRequest::REQUIRES_AUTH
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_success_method_with_valid_json
|
17
|
+
HTTParty.stubs(:send).returns(
|
18
|
+
{"EnviarInstrucaoUnicaResponse"=>{"xmlns:ns1"=>"http://www.moip.com.br/ws/alpha/", "Resposta"=>{"ID"=>"201208081614306080000000928569", "Status"=>"Sucesso", "Token"=>"G290E1H230N8L0M8J1K6F1F4B3T0N610K8B0S0H0I0T0T0E029Y2R8H5Y6H9"}}}
|
19
|
+
)
|
20
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
21
|
+
request_data = stub(to_xml: "<anydata></anydata>")
|
22
|
+
request.api_call request_data
|
23
|
+
assert request.success?
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_success_method_with_failed_response
|
27
|
+
HTTParty.stubs(:send).returns(
|
28
|
+
{"EnviarInstrucaoUnicaResponse"=>{"xmlns:ns1"=>"http://www.moip.com.br/ws/alpha/", "Resposta"=>{"Status"=>"Falha"}}}
|
29
|
+
)
|
30
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
31
|
+
request_data = stub(to_xml: "<anydata></anydata>")
|
32
|
+
request.api_call request_data
|
33
|
+
assert !request.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_success_method_with_requests_that_hasnt_be_made
|
37
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
38
|
+
assert !request.success?
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_provides_token_when_has_a_valid_response
|
42
|
+
HTTParty.stubs(:send).returns(
|
43
|
+
{"EnviarInstrucaoUnicaResponse"=>{"xmlns:ns1"=>"http://www.moip.com.br/ws/alpha/", "Resposta"=>{"ID"=>"201208081614306080000000928569", "Status"=>"Sucesso", "Token"=>"token"}}}
|
44
|
+
)
|
45
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
46
|
+
request_data = stub(to_xml: "<anydata></anydata>")
|
47
|
+
request.api_call request_data
|
48
|
+
assert_equal "token", request.token
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_provides_token_with_requests_that_hasnt_be_made
|
52
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
53
|
+
assert_equal nil, request.token
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_should_provide_the_transaction_id_get_by_the_request
|
57
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
58
|
+
VCR.use_cassette('transparent_request') do
|
59
|
+
request.api_call(Fixture.instruction(payer: Fixture.payer))
|
60
|
+
end
|
61
|
+
assert_equal "201210171118501100000001102691", request.id
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_should_provide_the_transaction_id_get_by_the_request_with_commissions_feature
|
65
|
+
request = MyMoip::TransparentRequest.new("some_id")
|
66
|
+
VCR.use_cassette('transparent_request_with_commissions') do
|
67
|
+
request.api_call Fixture.instruction(commissions: [Fixture.commission])
|
68
|
+
end
|
69
|
+
assert_equal "YOUR_REQUEST_ID", request.id
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class TestValidators < Test::Unit::TestCase
|
4
|
+
include MyMoip::Validators
|
5
|
+
|
6
|
+
def test_valid_url_validator
|
7
|
+
assert_equal valid_url?('http://valid.url.me'), true
|
8
|
+
assert_equal valid_url?('https://valid.url.me'), true
|
9
|
+
assert_equal valid_url?('ftp://valid.url.me'), false
|
10
|
+
assert_equal valid_url?('valid.url.me'), false
|
11
|
+
assert_equal valid_url?('me'), false
|
12
|
+
end
|
13
|
+
end
|
data/test/live_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'mocha/setup'
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
VCR.configure do |c|
|
6
|
+
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
7
|
+
c.hook_into :webmock
|
8
|
+
end
|
9
|
+
|
10
|
+
require_relative 'live_test'
|
11
|
+
require_relative 'fixtures/fixture'
|
12
|
+
Dir[File.dirname(__FILE__) + "/lib/*.rb"].each { |file| require file }
|
13
|
+
|
14
|
+
MyMoip.sandbox_key = 'YOUR_MOIP_KEY'
|
15
|
+
MyMoip.sandbox_token = 'YOUR_MOIP_TOKEN'
|
16
|
+
MyMoip.logger = Logger.new('/dev/null')
|
17
|
+
$VERBOSE = nil
|
metadata
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: edools_mymoip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vinicius Magalhaes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: builder
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rdoc
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.12'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.12'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: vcr
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: The easier way to use Moip's transparent checkout.
|
140
|
+
email:
|
141
|
+
- viniciusmkm@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".document"
|
147
|
+
- ".gitignore"
|
148
|
+
- ".travis.yml"
|
149
|
+
- CHANGELOG.md
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE.txt
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- lib/mymoip.rb
|
155
|
+
- lib/mymoip/bank_debit.rb
|
156
|
+
- lib/mymoip/commission.rb
|
157
|
+
- lib/mymoip/credit_card.rb
|
158
|
+
- lib/mymoip/exceptions.rb
|
159
|
+
- lib/mymoip/formatter.rb
|
160
|
+
- lib/mymoip/instruction.rb
|
161
|
+
- lib/mymoip/json_parser.rb
|
162
|
+
- lib/mymoip/payer.rb
|
163
|
+
- lib/mymoip/payment.rb
|
164
|
+
- lib/mymoip/payment_methods.rb
|
165
|
+
- lib/mymoip/payment_slip.rb
|
166
|
+
- lib/mymoip/payments/bank_debit_payment.rb
|
167
|
+
- lib/mymoip/payments/credit_card_payment.rb
|
168
|
+
- lib/mymoip/payments/payment_slip_payment.rb
|
169
|
+
- lib/mymoip/purchase.rb
|
170
|
+
- lib/mymoip/request.rb
|
171
|
+
- lib/mymoip/requests/payment_request.rb
|
172
|
+
- lib/mymoip/requests/transparent_request.rb
|
173
|
+
- lib/mymoip/validators.rb
|
174
|
+
- lib/mymoip/version.rb
|
175
|
+
- mymoip.gemspec
|
176
|
+
- test/fixtures/fixture.rb
|
177
|
+
- test/fixtures/vcr_cassettes/payment_request.yml
|
178
|
+
- test/fixtures/vcr_cassettes/payment_request_with_payment_slip.yml
|
179
|
+
- test/fixtures/vcr_cassettes/transparent_request.yml
|
180
|
+
- test/fixtures/vcr_cassettes/transparent_request_with_commissions.yml
|
181
|
+
- test/lib/test_bank_debit.rb
|
182
|
+
- test/lib/test_bank_debit_payment.rb
|
183
|
+
- test/lib/test_commission.rb
|
184
|
+
- test/lib/test_credit_card_payment.rb
|
185
|
+
- test/lib/test_creditcard.rb
|
186
|
+
- test/lib/test_formatter.rb
|
187
|
+
- test/lib/test_instruction.rb
|
188
|
+
- test/lib/test_mymoip.rb
|
189
|
+
- test/lib/test_payer.rb
|
190
|
+
- test/lib/test_payment.rb
|
191
|
+
- test/lib/test_payment_methods.rb
|
192
|
+
- test/lib/test_payment_request.rb
|
193
|
+
- test/lib/test_payment_slip.rb
|
194
|
+
- test/lib/test_payment_slip_payment.rb
|
195
|
+
- test/lib/test_purchase.rb
|
196
|
+
- test/lib/test_request.rb
|
197
|
+
- test/lib/test_transparent_request.rb
|
198
|
+
- test/lib/test_validators.rb
|
199
|
+
- test/live_test.rb
|
200
|
+
- test/test_helper.rb
|
201
|
+
homepage: https://github.com/Edools/mymoip
|
202
|
+
licenses:
|
203
|
+
- MIT
|
204
|
+
metadata: {}
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.2.2
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: MoIP transactions in a gem to call your own.
|
225
|
+
test_files:
|
226
|
+
- test/fixtures/fixture.rb
|
227
|
+
- test/fixtures/vcr_cassettes/payment_request.yml
|
228
|
+
- test/fixtures/vcr_cassettes/payment_request_with_payment_slip.yml
|
229
|
+
- test/fixtures/vcr_cassettes/transparent_request.yml
|
230
|
+
- test/fixtures/vcr_cassettes/transparent_request_with_commissions.yml
|
231
|
+
- test/lib/test_bank_debit.rb
|
232
|
+
- test/lib/test_bank_debit_payment.rb
|
233
|
+
- test/lib/test_commission.rb
|
234
|
+
- test/lib/test_credit_card_payment.rb
|
235
|
+
- test/lib/test_creditcard.rb
|
236
|
+
- test/lib/test_formatter.rb
|
237
|
+
- test/lib/test_instruction.rb
|
238
|
+
- test/lib/test_mymoip.rb
|
239
|
+
- test/lib/test_payer.rb
|
240
|
+
- test/lib/test_payment.rb
|
241
|
+
- test/lib/test_payment_methods.rb
|
242
|
+
- test/lib/test_payment_request.rb
|
243
|
+
- test/lib/test_payment_slip.rb
|
244
|
+
- test/lib/test_payment_slip_payment.rb
|
245
|
+
- test/lib/test_purchase.rb
|
246
|
+
- test/lib/test_request.rb
|
247
|
+
- test/lib/test_transparent_request.rb
|
248
|
+
- test/lib/test_validators.rb
|
249
|
+
- test/live_test.rb
|
250
|
+
- test/test_helper.rb
|
251
|
+
has_rdoc:
|