mock_braintree 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/mock_braintree/transaction.rb +8 -2
- data/lib/mock_braintree/transaction_request.rb +25 -0
- data/lib/mock_braintree/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01e87868840fd62679b76bcda219416f0b74b72df4d37b2c61f7c03309f9ccd5
|
4
|
+
data.tar.gz: cddac19381d1b59c83800e5de323678e3f48aa66c9edaaf7d2f228c24c72c778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d103d096e4fc4844a7d0ec0ceb9579c7477f8dc1c6f1e038e12f1cc3dce3a3c865cdac47a93d3b39d5baef7d5494f7bfe450ae5e7b098228fd1339643fbd395
|
7
|
+
data.tar.gz: b30a281a1d6e99ab312d5fe3f5a7b0943fed68f8dfd17f6d532dc060643b8c8846cf1c55e9a6f86be89d4c352c29756e7b02f37cecabef4f63e3a83a951b3440
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.2.2(unreleased)
|
2
|
+
* Add `created_at` attribute to transaction object
|
3
|
+
* Add `transaction.refund` call
|
4
|
+
* Have transaction response wait within 2 to 5 seconds to more closely mimic response time
|
5
|
+
|
1
6
|
# 0.2.1
|
2
7
|
* Fix bug where transaction object would return new ID value each time called
|
3
8
|
* Removed `nonce` attribute from transaction object to match actual Braintree response
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
|
3
3
|
class Transaction
|
4
|
-
attr_reader :amount
|
4
|
+
attr_reader :amount, :created_at, :order_id, :refunded_transaction_id
|
5
5
|
|
6
6
|
def initialize(hash = {})
|
7
7
|
@amount = hash[:amount]
|
8
8
|
@options = hash.fetch(:options, nil)
|
9
|
+
@order_id = hash.fetch(:order_id, nil)
|
9
10
|
@submit_for_settlement = submit_for_settlement
|
11
|
+
@created_at = Time.now.utc
|
12
|
+
@refunded_transaction_id = hash.fetch(:id, nil)
|
13
|
+
@void = hash.fetch(:void, false)
|
10
14
|
end
|
11
15
|
|
12
16
|
def status
|
13
|
-
if
|
17
|
+
if @void == true
|
18
|
+
'voided'
|
19
|
+
elsif (amount.to_f < 2000) && (submit_for_settlement == true)
|
14
20
|
'submitted_for_settlement'
|
15
21
|
elsif (amount.to_f < 2000) && (submit_for_settlement == false)
|
16
22
|
'authorized'
|
@@ -1,5 +1,9 @@
|
|
1
1
|
class TransactionRequest
|
2
|
+
# sets time for response between 2-5 seconds (with 3 heavily weighted) to send response, adjust this to customize desired response times
|
3
|
+
# You can also reduce this to 0 if you are looking to get instant responses when running specs
|
4
|
+
# WAIT_TIME = [2, 3, 3, 3, 3, 4, 5].sample
|
2
5
|
def sale(hash = {})
|
6
|
+
#sleep(WAIT_TIME)
|
3
7
|
if hash[:amount].to_f < 2000.00
|
4
8
|
SuccessfulResult.new(hash)
|
5
9
|
elsif (hash[:amount].to_f >= 2000) && (hash[:amount].to_i < 3000)
|
@@ -10,4 +14,25 @@ class TransactionRequest
|
|
10
14
|
UnsuccessfulResult.new(hash)
|
11
15
|
end
|
12
16
|
end
|
17
|
+
|
18
|
+
def refund(id, amount = '10.00', order_id = nil)
|
19
|
+
# sleep(WAIT_TIME)
|
20
|
+
hash_args = {
|
21
|
+
id: id,
|
22
|
+
amount: amount,
|
23
|
+
order_id: order_id,
|
24
|
+
options: {
|
25
|
+
submit_for_settlement: true
|
26
|
+
}
|
27
|
+
}
|
28
|
+
SuccessfulResult.new(hash_args)
|
29
|
+
end
|
30
|
+
|
31
|
+
def void(id)
|
32
|
+
hash_args = {
|
33
|
+
id: id,
|
34
|
+
void: true
|
35
|
+
}
|
36
|
+
SuccessfulResult.new(hash_args)
|
37
|
+
end
|
13
38
|
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.3.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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|