fat_zebra 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/fat_zebra/config.rb +2 -2
- data/lib/fat_zebra/models/purchase.rb +30 -4
- data/lib/fat_zebra/version.rb +1 -1
- data/lib/fat_zebra.rb +13 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWI3NDI2ZTQ2MjAxYWFiMmU4MTQ2Nzk5NjY5ODBmZDg0YmNlM2U4Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzYyYTVhZjg5NzFkODk3ZjZhZTJlYzY4M2EwNDllYzYxZDNmZWFmZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGYwNTM1OTFhYWY3ZmRjYmRmNGE1NzMyMjJkNWYzOTQ1ZmJhMTEwYzQyYjVl
|
10
|
+
NTAyNWYxNzg0NzFiNDFlY2M5M2E1MTk5MWE0NGQyYzMyOGVhZTFiMDMxY2E3
|
11
|
+
YjFhMmM0ZTA4ZDIwNjNlMzVlY2RlMTAwOGYxOTNmNDEyMGJjMzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTJjZWY1NGE2ZGVlYmI2ZjViNDY5YTNhYWFhZWZiYzIwYmFjMDlkOTAzNmZi
|
14
|
+
Y2M1NmIwMjAwNDVhYmE3M2E4MTQxYWViZjc5OTU1NjkzMDU4OWRkYjhjYTFi
|
15
|
+
NzIxZTM3N2U1YWVkN2M1NTI5YjBlNGNjMTQ2YjE5NmFmZjc3MGE=
|
data/lib/fat_zebra/config.rb
CHANGED
@@ -2,8 +2,8 @@ module FatZebra
|
|
2
2
|
module Models
|
3
3
|
class Purchase < Base
|
4
4
|
attribute :id, :amount, :reference, :message, :authorization, :transaction_id, :card_number,
|
5
|
-
:card_holder, :card_expiry, :authorized, :successful, :card_token, :currency, :raw, :captured,
|
6
|
-
:response_code, :rrn, :cvv_match, :fraud_result, :fraud_messages
|
5
|
+
:card_holder, :card_expiry, :authorized, :successful, :card_token, :currency, :raw, :captured, :captured_amount,
|
6
|
+
:response_code, :rrn, :cvv_match, :fraud_result, :fraud_messages, :metadata
|
7
7
|
|
8
8
|
# Refunds the current transaction
|
9
9
|
#
|
@@ -15,6 +15,30 @@ module FatZebra
|
|
15
15
|
Refund.create(self.id, amount, reference)
|
16
16
|
end
|
17
17
|
|
18
|
+
# Captures an authorization
|
19
|
+
#
|
20
|
+
# @param [Integer] amount the amount to capture. (Optional)
|
21
|
+
#
|
22
|
+
# @return [Response] Purchase response object
|
23
|
+
def capture(amount = nil)
|
24
|
+
if amount.nil?
|
25
|
+
params = {}
|
26
|
+
else
|
27
|
+
params = {
|
28
|
+
:amount => amount
|
29
|
+
}
|
30
|
+
end
|
31
|
+
response = FatZebra.gateway.make_request(:post, "purchases/#{self.id}/capture", params)
|
32
|
+
resp = Response.new(response)
|
33
|
+
|
34
|
+
if resp.successful && resp.purchase.successful
|
35
|
+
self.captured_amount = amount || self.amount
|
36
|
+
return true
|
37
|
+
else
|
38
|
+
raise StandardError, "Unable to capture purchase - #{resp.errors.join(',')}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
18
42
|
# Returns the record as a Hash
|
19
43
|
#
|
20
44
|
# @return [Hash]
|
@@ -33,11 +57,13 @@ module FatZebra
|
|
33
57
|
authorized: self.authorized,
|
34
58
|
successful: self.successful,
|
35
59
|
captured: self.captured,
|
60
|
+
captured_amount: self.captured_amount,
|
36
61
|
response_code: self.response_code,
|
37
62
|
cvv_match: self.cvv_match,
|
38
63
|
rrn: self.rrn,
|
39
64
|
fraud_result: self.fraud_result,
|
40
|
-
fraud_messages: self.fraud_messages
|
65
|
+
fraud_messages: self.fraud_messages,
|
66
|
+
metadata: self.metadata || {}
|
41
67
|
}
|
42
68
|
end
|
43
69
|
|
@@ -114,7 +140,7 @@ module FatZebra
|
|
114
140
|
if response['successful']
|
115
141
|
Purchase.new(response['response'])
|
116
142
|
else
|
117
|
-
raise StandardError, "Unable to query purchases
|
143
|
+
raise StandardError, "Unable to query purchases - #{response['errors'].inspect}"
|
118
144
|
end
|
119
145
|
end
|
120
146
|
end
|
data/lib/fat_zebra/version.rb
CHANGED
data/lib/fat_zebra.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
require 'json'
|
3
3
|
require 'rest_client'
|
4
|
+
require 'active_support'
|
4
5
|
require 'active_support/core_ext'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
require 'forwardable'
|
7
|
+
|
8
|
+
require_relative 'fat_zebra/config'
|
9
|
+
require_relative 'fat_zebra/errors'
|
10
|
+
require_relative 'fat_zebra/version'
|
11
|
+
require_relative 'fat_zebra/constants'
|
12
|
+
require_relative 'fat_zebra/gateway'
|
13
|
+
require_relative 'fat_zebra/models/base'
|
14
|
+
require_relative 'fat_zebra/models/purchase'
|
15
|
+
require_relative 'fat_zebra/models/refund'
|
16
|
+
require_relative 'fat_zebra/models/card'
|
17
|
+
require_relative 'fat_zebra/models/response'
|
16
18
|
|
17
19
|
module FatZebra
|
18
20
|
extend self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_zebra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Savage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|