smartcoin 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/LICENSE.txt +17 -18
- data/README.md +29 -20
- data/lib/smartcoin/version.rb +1 -1
- data/smartcoin.gemspec +3 -3
- data/test/smartcoin/charge_spec.rb +17 -17
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f72832894149fc78f99702aa3a4f81194c8132
|
4
|
+
data.tar.gz: bd039af97a4ffb1140b7c3da97bf6c10974f9c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a77869308812991abb7f33d858a8b786ccc3e3f9644adce903d52a1fba8166705a4b44ad46a0405d06ac1bd14e43d3771245ea378391cbbf11002d99ba3384
|
7
|
+
data.tar.gz: 9bce5d19ccb87ddf2b9914e1730ab1c7890c71ce0f9f2b721d532d9c5000f69633448fc2906ebc0bafc0c5b8c94b099ab8937138d1ddfea6180c8fba233dc685
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.1.
|
1
|
+
ruby-2.1.2
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2014 Smartcoin
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
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:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
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
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,29 +1,38 @@
|
|
1
|
-
|
1
|
+
Visit [Smartcoin](https://smartcoin.com.br/) to request an account.
|
2
2
|
|
3
|
-
|
3
|
+
Getting Started
|
4
|
+
===============
|
4
5
|
|
5
|
-
|
6
|
+
Sample usage:
|
6
7
|
|
7
|
-
|
8
|
+
```ruby
|
9
|
+
SmartCoin.api_key('pk_live_e73e1d46a263fe')
|
10
|
+
SmartCoin.api_secret('sk_live_6bef1b7867ecbf')
|
8
11
|
|
9
|
-
|
12
|
+
#Credit Card Charge
|
13
|
+
card_params = {number: 4242424242424242,
|
14
|
+
exp_month: 11,
|
15
|
+
exp_year: 2017,
|
16
|
+
cvc: '111',
|
17
|
+
name: 'Arthur Granado'
|
18
|
+
}
|
10
19
|
|
11
|
-
|
20
|
+
token = SmartCoin::Token.create(token_params)
|
21
|
+
charge_params = { amount: 100, currency: 'brl', card: token.id, }
|
22
|
+
charge = SmartCoin::Charge.create(charge_params)
|
23
|
+
puts charge.to_json
|
12
24
|
|
13
|
-
|
25
|
+
#Bank Slip Charge
|
26
|
+
charge_params = {amount: 1000, currency: 'brl', type: 'bank_slip'}
|
27
|
+
charge = SmartCoin::Charge.create(charge_params)
|
28
|
+
puts charge.to_json
|
29
|
+
```
|
14
30
|
|
15
|
-
|
31
|
+
Test
|
32
|
+
====
|
16
33
|
|
17
|
-
|
34
|
+
To run test the suite:
|
18
35
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it ( https://github.com/[my-github-username]/smartcoin/fork )
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create a new Pull Request
|
36
|
+
```
|
37
|
+
rspec ./test
|
38
|
+
```
|
data/lib/smartcoin/version.rb
CHANGED
data/smartcoin.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.
|
21
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.6', '>= 1.6.7'
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec",
|
24
|
+
spec.add_development_dependency "rake", '~> 10.3', '>= 10.3.0'
|
25
|
+
spec.add_development_dependency "rspec", '~> 2.14', '>= 2.14.0'
|
26
26
|
end
|
@@ -23,14 +23,14 @@ describe SmartCoin::Charge do
|
|
23
23
|
charge = SmartCoin::Charge.create(charge_params)
|
24
24
|
expect(charge.id).to match(/ch_(.*)/)
|
25
25
|
expect(charge.amount).to eq(charge_params[:amount])
|
26
|
-
expect(charge.paid).to
|
27
|
-
expect(charge.captured).to
|
26
|
+
expect(charge.paid).to be_truthy
|
27
|
+
expect(charge.captured).to be_truthy
|
28
28
|
expect(charge.card.id).to match(/card_(.*)/)
|
29
29
|
expect(charge.card.type).to eq('Visa')
|
30
|
-
expect(charge.fees).to
|
31
|
-
expect(charge.fees.first.type).to eq('
|
30
|
+
expect(charge.fees.size).to be >= 2
|
31
|
+
expect(charge.fees.first.type).to eq('Smartcoin fee: flat')
|
32
32
|
expect(charge.fees.first.class).to eq(SmartCoin::Fee)
|
33
|
-
expect(charge.installments).to
|
33
|
+
expect(charge.installments.size).to be >= 1
|
34
34
|
expect(charge.installments.first.class).to eq(SmartCoin::Installment)
|
35
35
|
end
|
36
36
|
|
@@ -39,7 +39,7 @@ describe SmartCoin::Charge do
|
|
39
39
|
charge = SmartCoin::Charge.create(charge_params)
|
40
40
|
expect(charge.id).to match(/ch_(.*)/)
|
41
41
|
expect(charge.amount).to eq(charge_params[:amount])
|
42
|
-
expect(charge.paid).to
|
42
|
+
expect(charge.paid).to be_falsey
|
43
43
|
expect(charge.card).to be_nil
|
44
44
|
expect(charge.bank_slip).to_not be_nil
|
45
45
|
expect(charge.bank_slip.link).to match(/https:\/\/api\.smartcoin\.com\.br\/v1\/charges\/ch_(.*)\/bank_slip\/test/)
|
@@ -82,9 +82,9 @@ describe SmartCoin::Charge do
|
|
82
82
|
}
|
83
83
|
|
84
84
|
charge_created = SmartCoin::Charge.create(charge_params)
|
85
|
-
expect(charge_created.captured).to
|
85
|
+
expect(charge_created.captured).to be_falsey
|
86
86
|
charge_created.capture()
|
87
|
-
expect(charge_created.captured).to
|
87
|
+
expect(charge_created.captured).to be_truthy
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should partial capture charge that has already created' do
|
@@ -103,10 +103,10 @@ describe SmartCoin::Charge do
|
|
103
103
|
}
|
104
104
|
|
105
105
|
charge_created = SmartCoin::Charge.create(charge_params)
|
106
|
-
expect(charge_created.captured).to
|
106
|
+
expect(charge_created.captured).to be_falsey
|
107
107
|
amount_captured = 300
|
108
108
|
charge_created.capture(amount_captured)
|
109
|
-
expect(charge_created.captured).to
|
109
|
+
expect(charge_created.captured).to be_truthy
|
110
110
|
expect(charge_created.amount).to eq(charge_params[:amount])
|
111
111
|
expect(charge_created.amount_refunded).to eq(charge_params[:amount] - amount_captured)
|
112
112
|
end
|
@@ -126,13 +126,13 @@ describe SmartCoin::Charge do
|
|
126
126
|
}
|
127
127
|
|
128
128
|
charge_created = SmartCoin::Charge.create(charge_params)
|
129
|
-
expect(charge_created.refunded).to
|
129
|
+
expect(charge_created.refunded).to be_falsey
|
130
130
|
|
131
131
|
charge_created.refund()
|
132
|
-
expect(charge_created.refunded).to
|
132
|
+
expect(charge_created.refunded).to be_truthy
|
133
133
|
expect(charge_created.amount).to eq(charge_params[:amount])
|
134
134
|
expect(charge_created.amount_refunded).to eq(charge_params[:amount])
|
135
|
-
expect(charge_created.refunds).to
|
135
|
+
expect(charge_created.refunds.size).to eq(1)
|
136
136
|
end
|
137
137
|
|
138
138
|
it 'should partial refund charge that has already created' do
|
@@ -150,14 +150,14 @@ describe SmartCoin::Charge do
|
|
150
150
|
}
|
151
151
|
|
152
152
|
charge_created = SmartCoin::Charge.create(charge_params)
|
153
|
-
expect(charge_created.refunded).to
|
153
|
+
expect(charge_created.refunded).to be_falsey
|
154
154
|
|
155
155
|
amount_refunded = 600
|
156
156
|
charge_created.refund(amount_refunded)
|
157
|
-
expect(charge_created.refunded).to
|
157
|
+
expect(charge_created.refunded).to be_falsey
|
158
158
|
expect(charge_created.amount).to eq(charge_params[:amount])
|
159
159
|
expect(charge_created.amount_refunded).to eq(amount_refunded)
|
160
|
-
expect(charge_created.refunds).to
|
160
|
+
expect(charge_created.refunds.size).to eq(1)
|
161
161
|
expect(charge_created.refunds[0].amount).to eq(amount_refunded)
|
162
162
|
end
|
163
163
|
|
@@ -166,7 +166,7 @@ describe SmartCoin::Charge do
|
|
166
166
|
charge_list = SmartCoin::Charge.list_all(params)
|
167
167
|
expect(charge_list.object).to eq('list')
|
168
168
|
expect(charge_list.count).to eq(3)
|
169
|
-
expect(charge_list.data).to
|
169
|
+
expect(charge_list.data.size).to eq(3)
|
170
170
|
expect(charge_list.data[0].class).to eq(SmartCoin::Charge)
|
171
171
|
end
|
172
172
|
end
|
metadata
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartcoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Granado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 1.6.7
|
20
23
|
type: :runtime
|
@@ -22,6 +25,9 @@ dependencies:
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.6'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 1.6.7
|
27
33
|
- !ruby/object:Gem::Dependency
|
@@ -42,21 +48,30 @@ dependencies:
|
|
42
48
|
name: rake
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.3'
|
45
54
|
- - ">="
|
46
55
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
56
|
+
version: 10.3.0
|
48
57
|
type: :development
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '10.3'
|
52
64
|
- - ">="
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
66
|
+
version: 10.3.0
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: rspec
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
58
70
|
requirements:
|
59
71
|
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '2.14'
|
74
|
+
- - ">="
|
60
75
|
- !ruby/object:Gem::Version
|
61
76
|
version: 2.14.0
|
62
77
|
type: :development
|
@@ -64,6 +79,9 @@ dependencies:
|
|
64
79
|
version_requirements: !ruby/object:Gem::Requirement
|
65
80
|
requirements:
|
66
81
|
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.14'
|
84
|
+
- - ">="
|
67
85
|
- !ruby/object:Gem::Version
|
68
86
|
version: 2.14.0
|
69
87
|
description: Ruby library to SmartCoin API - https://smartcoin.com.br
|