mock_braintree 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +10 -2
- data/TODO.md +14 -0
- data/lib/mock_braintree.rb +2 -0
- data/lib/mock_braintree/successful_result.rb +10 -0
- data/lib/mock_braintree/transaction.rb +3 -11
- data/lib/mock_braintree/transaction_request.rb +9 -1
- data/lib/mock_braintree/unsuccessful_result.rb +10 -0
- data/lib/mock_braintree/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aea598969fad5aa0fdf866645af6b3204dca000d59304c4d53faab6f5b0704de
|
4
|
+
data.tar.gz: 1b90d38ecd6c5acea7ceed0d851f6990c34412f7a9fe01e858f6aebf87357943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cfcf2f6e956d19cb29669d476e57f4338de3250de07aae0d2f6746f693fa3b41ecb20d4e47b4ec0af3852ec54b29bada5163f3159e043bf35290d6d5403b782
|
7
|
+
data.tar.gz: f704db440ec0ddac52b1f6d57c5898987721d67e67dc15c14efcdb0a7817150266e82ce847412fdedfb2a7896cb6dd0ba054139c090a3b9e62228971eb8d2b18
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
* BREAKING CHANGE - separated transaction and result object. Depending on success, the result will now be either a `SuccessfulResult` or `UnsuccessfulResult` object that contains a transaction object. This was changed to better match an actual Braintree response.
|
3
|
+
|
4
|
+
# 0.1.0
|
5
|
+
* Add basic `transaction.sale` functionality with result object and `transaction` object
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
First, configure your mock Braintree integration by switching out your real Braintree configuration with `MockBraintree.new`
|
25
|
+
First, configure your mock Braintree integration by switching out your real Braintree configuration with `MockBraintree::Gateway.new`
|
26
26
|
|
27
27
|
example:
|
28
28
|
|
@@ -38,9 +38,13 @@ MockBraintree lets you test simple result handling just like Braintree responses
|
|
38
38
|
result = gateway.transaction.sale(nonce: 'fake-valid-nonce', amount: '10.00', options: { submit_for_settlement: true })
|
39
39
|
|
40
40
|
puts result.success?
|
41
|
+
#=> true
|
41
42
|
puts result.transaction.status
|
43
|
+
#=> submitted_for_settlement
|
42
44
|
puts result.transaction.amount
|
45
|
+
#=> '10.00'
|
43
46
|
puts result.transaction.id
|
47
|
+
#=> 'ej6a32'
|
44
48
|
```
|
45
49
|
|
46
50
|
## Development
|
@@ -49,9 +53,13 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
|
|
49
53
|
|
50
54
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
51
55
|
|
56
|
+
|
57
|
+
## Disclaimer
|
58
|
+
While I work at Braintree, this library was neither built by Braintree, nor is it maintained by Braintree. If there is a feature you are looking for PRs are always welcome, or feel free to fork your own branch and make it your own. If you find a bug please open an issue on this repo and do not contact Braintree directly.
|
59
|
+
|
52
60
|
## Contributing
|
53
61
|
|
54
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/buzzamus/mock_braintree.
|
55
63
|
|
56
64
|
## License
|
57
65
|
|
data/TODO.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Todo
|
2
|
+
|
3
|
+
##### Add additional `transaction` type calls
|
4
|
+
* refund
|
5
|
+
* void
|
6
|
+
* submit_for_settlement
|
7
|
+
|
8
|
+
##### Add more attributes to result and transaction objects to resemble all of, or most of Braintree's attributes
|
9
|
+
|
10
|
+
##### Add option to gateway reject (possibly based off of fake nonce value somehow) - revise documentation to list what values to change nonce in `transaction.sale` request to
|
11
|
+
|
12
|
+
#### Make requests wait several seconds before returning response to match actual request times
|
13
|
+
|
14
|
+
#### Add ability to create customer and/or payment method in transaction requests, return customer and payment method objects
|
data/lib/mock_braintree.rb
CHANGED
@@ -11,14 +11,6 @@ class Transaction
|
|
11
11
|
@submit_for_settlement = submit_for_settlement
|
12
12
|
end
|
13
13
|
|
14
|
-
def success?
|
15
|
-
if (status == 'authorized') || (status == 'submitted_for_settlement')
|
16
|
-
true
|
17
|
-
else
|
18
|
-
false
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
14
|
def status
|
23
15
|
if (amount.to_f < 2000) && (submit_for_settlement == true)
|
24
16
|
'submitted_for_settlement'
|
@@ -33,9 +25,9 @@ class Transaction
|
|
33
25
|
end
|
34
26
|
end
|
35
27
|
|
36
|
-
def transaction
|
37
|
-
|
38
|
-
end
|
28
|
+
# def transaction
|
29
|
+
# self
|
30
|
+
# end
|
39
31
|
|
40
32
|
def id
|
41
33
|
SecureRandom.hex(3)
|
@@ -1,5 +1,13 @@
|
|
1
1
|
class TransactionRequest
|
2
2
|
def sale(hash = {})
|
3
|
-
|
3
|
+
if hash[:amount].to_f < 2000.00
|
4
|
+
SuccessfulResult.new(hash)
|
5
|
+
elsif (hash[:amount].to_f >= 2000) && (hash[:amount].to_i < 3000)
|
6
|
+
UnsuccessfulResult.new(hash)
|
7
|
+
elsif (hash[:amount].to_f >= 3000) && (hash[:amount].to_i <= 3000.99)
|
8
|
+
UnsuccessfulResult.new(hash)
|
9
|
+
else
|
10
|
+
UnsuccessfulResult.new(hash)
|
11
|
+
end
|
4
12
|
end
|
5
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mock_braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Busby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,16 +46,20 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
49
50
|
- Gemfile
|
50
51
|
- Gemfile.lock
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
55
|
+
- TODO.md
|
54
56
|
- bin/console
|
55
57
|
- bin/setup
|
56
58
|
- lib/mock_braintree.rb
|
59
|
+
- lib/mock_braintree/successful_result.rb
|
57
60
|
- lib/mock_braintree/transaction.rb
|
58
61
|
- lib/mock_braintree/transaction_request.rb
|
62
|
+
- lib/mock_braintree/unsuccessful_result.rb
|
59
63
|
- lib/mock_braintree/version.rb
|
60
64
|
- mock_braintree.gemspec
|
61
65
|
homepage: https://github.com/buzzamus/mock-braintree
|