bcash-ruby 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bcash/api/verify_return.rb +10 -0
- data/lib/bcash/api/verify_return_response.rb +18 -0
- data/lib/bcash/api.rb +2 -0
- data/lib/bcash/client.rb +1 -0
- data/lib/bcash/helpers/request.rb +10 -0
- data/lib/bcash/version.rb +1 -1
- data/spec/cases/api_verify_request_spec.rb +39 -0
- data/spec/vcr_cassettes/verify_return_not_verified.yml +42 -0
- data/spec/vcr_cassettes/verify_return_verified.yml +42 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56254dd2f0786d847f685f7d4985b775f279beb7
|
4
|
+
data.tar.gz: 83083decb8436e97c84a2d0429f2c3f5b52e52ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71dc86b149bdb6b468a9272c47c1cc55219a550f4f7b5cce39ea230880a70ef3956df1759211582e940f251d25e0b28509ad9414a831794e8daa89f7c3b8897e
|
7
|
+
data.tar.gz: 31973c3bd114dfca5170990785291a7ca129fb52cebae8d8389ac6d2d4ac819af1e6fd3b12b83465344f881c202a5b7d133ad62ed17978cb27cd792b9aa3d154
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Bcash::Api
|
2
|
+
module VerifyReturn
|
3
|
+
VERIFY_URL = 'https://www.bcash.com.br/checkout/verify/'
|
4
|
+
def verify_return(data={})
|
5
|
+
assert_valid_keys(data,:transacao, :status, :cod_status, :valor_original, :valor_loja, :token)
|
6
|
+
response = HTTParty.post VERIFY_URL, body: data
|
7
|
+
Bcash::Api::VerifyReturnResponse.new(response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Bcash::Api
|
2
|
+
class VerifyReturnResponse < Response
|
3
|
+
def verified?
|
4
|
+
body == 'VERIFICADO'
|
5
|
+
end
|
6
|
+
|
7
|
+
def message
|
8
|
+
body
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def parse_body(response)
|
14
|
+
@body = CGI::unescape(response.body)
|
15
|
+
@success = response.success?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/bcash/api.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Bcash::Api
|
2
2
|
autoload :Accounts, 'bcash/api/accounts'
|
3
|
+
autoload :VerifyReturn, 'bcash/api/verify_return'
|
3
4
|
autoload :Response, 'bcash/api/response'
|
4
5
|
autoload :AccountResponse, 'bcash/api/account_response'
|
5
6
|
autoload :CreateAccountResponse, 'bcash/api/create_account_response'
|
6
7
|
autoload :AccountNotValidResponse, 'bcash/api/account_not_valid_response'
|
8
|
+
autoload :VerifyReturnResponse, 'bcash/api/verify_return_response'
|
7
9
|
|
8
10
|
autoload :BaseRequest, 'bcash/api/request/base_request'
|
9
11
|
autoload :AddressRequest, 'bcash/api/request/address_request'
|
data/lib/bcash/client.rb
CHANGED
@@ -11,6 +11,16 @@ module Bcash::Helpers::Request
|
|
11
11
|
self.class.send(verb, "/#{method}/json", options)
|
12
12
|
end
|
13
13
|
|
14
|
+
def assert_valid_keys(hash, *valid_keys)
|
15
|
+
valid_keys_text = "Valid keys are: #{valid_keys.join(", ")}"
|
16
|
+
if hash.empty?
|
17
|
+
raise(ArgumentError, "Keys are required. #{valid_keys_text}")
|
18
|
+
else
|
19
|
+
unknown_keys = hash.keys - [valid_keys].flatten
|
20
|
+
raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}. #{valid_keys_text}") unless unknown_keys.empty?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
14
24
|
def ensure_email_and_token_are_set!
|
15
25
|
if email.blank?
|
16
26
|
raise StandardError, 'Bcash email is not set'
|
data/lib/bcash/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Bcash::Api::VerifyReturn do
|
5
|
+
let(:client){ Bcash::Client.new }
|
6
|
+
let(:data){
|
7
|
+
{
|
8
|
+
transacao: '2833',
|
9
|
+
status: 'Transação em Andamento',
|
10
|
+
cod_status: '0',
|
11
|
+
valor_original: '2145.23',
|
12
|
+
valor_loja: '2083.23',
|
13
|
+
token: '1211CF51917E074BC3784592C71FC'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
describe 'verify_return' do
|
18
|
+
context 'when data is valid' do
|
19
|
+
it 'must return VERIFICADO from response and return verified is true' do
|
20
|
+
VCR.use_cassette('verify_return_verified') do
|
21
|
+
response = client.verify_return(data)
|
22
|
+
expect(response).to be_verified
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when data is not valid, request is not from bcash' do
|
28
|
+
it 'must return error messages and return false for verified? method' do
|
29
|
+
VCR.use_cassette('verify_return_not_verified') do
|
30
|
+
data[:valor_loja] = '11'
|
31
|
+
response = client.verify_return(data)
|
32
|
+
expect(response).to_not be_verified
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://www.bcash.com.br/checkout/verify/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: transacao=2833&status=Transa%C3%A7%C3%A3o%20em%20Andamento&cod_status=0&valor_original=2145.23&valor_loja=11&token=1211CF51917E074BC3784592C71FC
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
17
|
+
Content-Type:
|
18
|
+
- text/html
|
19
|
+
Date:
|
20
|
+
- Thu, 02 Oct 2014 21:43:10 GMT
|
21
|
+
Expires:
|
22
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Server:
|
26
|
+
- Apache
|
27
|
+
Set-Cookie:
|
28
|
+
- PHPSESSID=v0590sqmabd33u43rre7d4r0v4; path=/; secure; HttpOnly
|
29
|
+
- ci_session_verify=PO6IiDT7bErhNmPMHLq1GAN57D9FSAbr9eBx1IWhfRn3RpkkjdPuEUNN2U%2BCthpMqC5F%2BAGeWisoluWLen52UY64%2BXGP%2BL%2Fhw2eYnJl%2FEl74WufnZbCKlll7kzGyh78PXaV0589pNh5ErCBedAARmFll7%2FEqa1cyrT1evVoHbAf238Pv23Rk%2FpLVSW1xEAzFsBQfgQeOVtC1oYrtCv6pRuQx29D%2BFFdvibQHDQZvgRucMMyJlk3K9tqdXbYDJMHryyK77H2%2Fgt%2FkN7gJEyjf6QIWKM6Wi8hJK7F2ZbJnG4WRRkZjliW9Z7OUfSRqfXHQdPEqoqu8aRB%2BUi6QeCANelY0ePjzSq2fX7U2hy6h9uUVkVN1Ye5dRpnW1esaWs1ig4PhkYhslEl1nwO7iViXBlhmbQ392lmtLYAz7MMjl5fVa%2FSuIpjeLpHrY7bM2%2BayAeqE4iFLywtfesxbrw301pS%2FFSMaHwACYJT%2B4yRTQmbkf50j4c1dQNYeGR05MllmJAlhVHN8GbhyOYNzxNJSBLjO%2BVnqyAxwOfJin2rBOpA%3D;
|
30
|
+
expires=Thu, 02-Oct-2014 23:43:10 GMT; path=/; secure; httponly
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
Content-Length:
|
34
|
+
- '40'
|
35
|
+
Connection:
|
36
|
+
- keep-alive
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
string: ERRO - Valor loja diferente do informado
|
40
|
+
http_version:
|
41
|
+
recorded_at: Thu, 02 Oct 2014 21:43:11 GMT
|
42
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://www.bcash.com.br/checkout/verify/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: transacao=2833&status=Transa%C3%A7%C3%A3o%20em%20Andamento&cod_status=0&valor_original=2145.23&valor_loja=2083.23&token=1211CF51917E074BC3784592C71FC
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
17
|
+
Content-Type:
|
18
|
+
- text/html
|
19
|
+
Date:
|
20
|
+
- Thu, 02 Oct 2014 21:43:09 GMT
|
21
|
+
Expires:
|
22
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
23
|
+
Pragma:
|
24
|
+
- no-cache
|
25
|
+
Server:
|
26
|
+
- Apache
|
27
|
+
Set-Cookie:
|
28
|
+
- PHPSESSID=p70g6rasqksjhak3lvah8ji173; path=/; secure; HttpOnly
|
29
|
+
- ci_session_verify=v0obUVVfgPV6frEHCx6LAn%2B28tBNWVqKX0sHNXPQs9QvxQNVE0lBsqaCU%2FljFaJDnZVTJbJjZTon0i87rxI9vW%2BHRyLh7XT0Typbeg7fNRTwYj4gKmdcSl30ikC6TzaSfOrxNhIU93h4tskPHtuAijavr9JBW4k6cybdF3r5lhhFoovyIBn6QYyBQTe0Qv6Z99yh3asdne%2Fib1gccGVDtdN2c1YhYuxGSBlWrW5Jenfz2E3HAKLYBVPFbLyylkNFgTrzwsYEkrNk7%2F1Bo27X0AHhawQecz454iRgh7GL13SBO9kgCxXxQ4nDxKd6KDhugD%2BgWqWlrnvaSr%2FvbmGajoxis7CJKw4xvmiamnExz4AptEHmrgqVblwoGhHonNj397z8C%2FJhVyC6M4Xafs7z8LfEp00JaurkunvnPAPOq30%2FtJMvuT5uxYNuSOmFaCP6hGzcVDLeEngHNfa7c0EAcjJhbuu2hmpyKIwakSZ7AKOgns0is2SVZ3RuqjetEeFhKrv0TzAKww7tgFDB5UkJj4CeRwLPp7baONfPRndGWYk%3D;
|
30
|
+
expires=Thu, 02-Oct-2014 23:43:09 GMT; path=/; secure; httponly
|
31
|
+
Vary:
|
32
|
+
- Accept-Encoding
|
33
|
+
Content-Length:
|
34
|
+
- '10'
|
35
|
+
Connection:
|
36
|
+
- keep-alive
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
string: VERIFICADO
|
40
|
+
http_version:
|
41
|
+
recorded_at: Thu, 02 Oct 2014 21:43:10 GMT
|
42
|
+
recorded_with: VCR 2.9.2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcash-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -194,12 +194,15 @@ files:
|
|
194
194
|
- lib/bcash/api/request/contact_request.rb
|
195
195
|
- lib/bcash/api/request/person_request.rb
|
196
196
|
- lib/bcash/api/response.rb
|
197
|
+
- lib/bcash/api/verify_return.rb
|
198
|
+
- lib/bcash/api/verify_return_response.rb
|
197
199
|
- lib/bcash/client.rb
|
198
200
|
- lib/bcash/exceptions.rb
|
199
201
|
- lib/bcash/helpers.rb
|
200
202
|
- lib/bcash/helpers/request.rb
|
201
203
|
- lib/bcash/version.rb
|
202
204
|
- spec/cases/api_account_spec.rb
|
205
|
+
- spec/cases/api_verify_request_spec.rb
|
203
206
|
- spec/cases/bcash_spec.rb
|
204
207
|
- spec/spec_helper.rb
|
205
208
|
- spec/vcr_cassettes/create_account_using_minimal_data.yml
|
@@ -207,6 +210,8 @@ files:
|
|
207
210
|
- spec/vcr_cassettes/search_account_return_mutiple.yml
|
208
211
|
- spec/vcr_cassettes/search_account_return_not_found.yml
|
209
212
|
- spec/vcr_cassettes/search_account_return_one.yml
|
213
|
+
- spec/vcr_cassettes/verify_return_not_verified.yml
|
214
|
+
- spec/vcr_cassettes/verify_return_verified.yml
|
210
215
|
homepage: http://minestore.com.br
|
211
216
|
licenses:
|
212
217
|
- GNU V2
|
@@ -233,6 +238,7 @@ specification_version: 4
|
|
233
238
|
summary: Wrapper gem to handle BCash and account creation
|
234
239
|
test_files:
|
235
240
|
- spec/cases/api_account_spec.rb
|
241
|
+
- spec/cases/api_verify_request_spec.rb
|
236
242
|
- spec/cases/bcash_spec.rb
|
237
243
|
- spec/spec_helper.rb
|
238
244
|
- spec/vcr_cassettes/create_account_using_minimal_data.yml
|
@@ -240,3 +246,5 @@ test_files:
|
|
240
246
|
- spec/vcr_cassettes/search_account_return_mutiple.yml
|
241
247
|
- spec/vcr_cassettes/search_account_return_not_found.yml
|
242
248
|
- spec/vcr_cassettes/search_account_return_one.yml
|
249
|
+
- spec/vcr_cassettes/verify_return_not_verified.yml
|
250
|
+
- spec/vcr_cassettes/verify_return_verified.yml
|