fat_zebra 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDJhZWQ1OWM3ZmNmNWMzMjA0M2FmNDE0MDlhY2Q1MWUxOWMwZWU1NQ==
4
+ OWI3NDI2ZTQ2MjAxYWFiMmU4MTQ2Nzk5NjY5ODBmZDg0YmNlM2U4Yw==
5
5
  data.tar.gz: !binary |-
6
- NThkMWRhM2JhODk4M2Q1YjI4NzgwZmQ5M2YyMmM5MWFiZTA0MDdlYw==
6
+ YzYyYTVhZjg5NzFkODk3ZjZhZTJlYzY4M2EwNDllYzYxZDNmZWFmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjM0MTc3YjI0NDRjZTBlZTA1ZDQzMDZhOTZkZDU3MTY4YmVjZDNlNzI5MjZj
10
- OWYyOGZhY2U3ZjQ0ODlmOTZkMWQ2ZmI1ODg2NDU1ZTIxNzMyYWVmZTI0ZDY1
11
- ZDA0ZjJiMTQ5MDVkMmNiZGMxZWQwMmFhZDZhODU3NzliMzg0MTY=
9
+ ZGYwNTM1OTFhYWY3ZmRjYmRmNGE1NzMyMjJkNWYzOTQ1ZmJhMTEwYzQyYjVl
10
+ NTAyNWYxNzg0NzFiNDFlY2M5M2E1MTk5MWE0NGQyYzMyOGVhZTFiMDMxY2E3
11
+ YjFhMmM0ZTA4ZDIwNjNlMzVlY2RlMTAwOGYxOTNmNDEyMGJjMzI=
12
12
  data.tar.gz: !binary |-
13
- NDZmZGYzMzlkYzFkNmQ3OTMwZTFlZDE2ZTllY2M4N2QyNTQ0NmNiYTRmYzIz
14
- Y2E0MzMxNmRjYjg0YzJhZTdiOTlhMDk2NjRjZTA5YmU2ZWJlMDliOTVkYTFl
15
- ZTI5ZGNlMjQzNzAxNDhjMWNhMTQyZTBhODI0NTk5YTdiOGYyY2E=
13
+ OTJjZWY1NGE2ZGVlYmI2ZjViNDY5YTNhYWFhZWZiYzIwYmFjMDlkOTAzNmZi
14
+ Y2M1NmIwMjAwNDVhYmE3M2E4MTQxYWViZjc5OTU1NjkzMDU4OWRkYjhjYTFi
15
+ NzIxZTM3N2U1YWVkN2M1NTI5YjBlNGNjMTQ2YjE5NmFmZjc3MGE=
@@ -1,5 +1,5 @@
1
1
  module FatZebra
2
- class Config
2
+ class Config
3
3
 
4
4
  # Returns the config values in a hash
5
5
  def config
@@ -34,5 +34,5 @@ module FatZebra
34
34
 
35
35
  c
36
36
  end
37
- end
37
+ end
38
38
  end
@@ -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, #{response['errors'].inspect}"
143
+ raise StandardError, "Unable to query purchases - #{response['errors'].inspect}"
118
144
  end
119
145
  end
120
146
  end
@@ -1,3 +1,3 @@
1
1
  module FatZebra
2
- VERSION = "2.0.5"
2
+ VERSION = "2.0.6"
3
3
  end
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
- require 'fat_zebra/config'
7
- require 'fat_zebra/errors'
8
- require 'fat_zebra/version'
9
- require 'fat_zebra/constants'
10
- require 'fat_zebra/gateway'
11
- require 'fat_zebra/models/base'
12
- require 'fat_zebra/models/purchase'
13
- require 'fat_zebra/models/refund'
14
- require 'fat_zebra/models/card'
15
- require 'fat_zebra/models/response'
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.5
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-03-04 00:00:00.000000000 Z
11
+ date: 2015-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec