fat_zebra 1.1.4 → 2.0.0
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 +8 -8
- data/FatZebra.gemspec +1 -0
- data/README.markdown +13 -7
- data/lib/fat_zebra/models/purchase.rb +17 -1
- data/lib/fat_zebra/version.rb +1 -1
- data/lib/fat_zebra.rb +2 -0
- data/spec/gateway_spec.rb +13 -10
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
YjQwNDkxMDlhMzhjYmM0YTUxOWVjYjU5NDM1OGVlYjkwN2YwM2Q0YQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
MjhmNjdkODhiMTE0MTcwODAzZWE0Y2ZlMDhlN2U5YjJlYzEyYWQzNw==
|
|
7
7
|
!binary "U0hBNTEy":
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
N2RkZTcyYzliMTA1MmE5NzY5OGMwMzliYzZmYjFlOTczM2ZmYjNiNzE4NjJl
|
|
10
|
+
YmViZTgwN2ZkNTNiN2RhOWExMmNmN2IzZTRkZGM0YzY3OWViNzRkNWFkZjQx
|
|
11
|
+
MmI3ZTFhZjk2ODJhYWU3MWJhNjUzNGJmODFiMGU4MmU1MTU3MTE=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
MjQ2NzA2N2ViNzI0YzQzYmJkNWQ0Mzc2MmFhMGJjZTE2NTFhZDY4YzMyNDI3
|
|
14
|
+
OWY1MjFjOTBhNGNhNjA2NDQ4Mjg0ZGQ3ODM4ZjM5ZTJjNTBjYTE3NjIxOGZj
|
|
15
|
+
MjI4NzY2M2JjM2M3NGI4MDg2OWFhOGE4YzEzNDVjMTBiNWM0NjM=
|
data/FatZebra.gemspec
CHANGED
data/README.markdown
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Ruby API Library for Fat Zebra
|
|
2
2
|
==============================
|
|
3
3
|
|
|
4
|
-
Release
|
|
4
|
+
Release 2.0.0 for API version 1.0
|
|
5
5
|
|
|
6
6
|
A Ruby client for the [Fat Zebra](https://www.fatzebra.com.au) Online Payment Gateway (for Australian Merchants)
|
|
7
7
|
|
|
8
8
|
Dependencies
|
|
9
9
|
------------
|
|
10
10
|
|
|
11
|
-
* Ruby (tested on 1.
|
|
11
|
+
* Ruby (tested on 1.9.2, 1.9.3)
|
|
12
12
|
* Rest Client
|
|
13
13
|
* JSON
|
|
14
14
|
|
|
@@ -29,15 +29,21 @@ Usage
|
|
|
29
29
|
```ruby
|
|
30
30
|
require 'fat_zebra'
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
# Configuration only needs to be done once, usually in your rails initializers
|
|
33
|
+
FatZebra.configure do |config|
|
|
34
|
+
config.username "TEST"
|
|
35
|
+
config.token "TEST"
|
|
36
|
+
config.gateway "gateway.fatzebra.com.au"
|
|
37
|
+
end
|
|
33
38
|
|
|
34
39
|
card_data = {
|
|
35
|
-
|
|
40
|
+
number: "5123456789012346",
|
|
36
41
|
card_holder: "Bill Simpson",
|
|
37
|
-
|
|
42
|
+
expiry: "05/2023",
|
|
38
43
|
ccv: "123"
|
|
39
44
|
}
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
response = FatZebra::Purchase.create(10000, card_data, "ORDER-23", "203.99.87.4")
|
|
41
47
|
|
|
42
48
|
if response.successful? && response.result.successful
|
|
43
49
|
puts "Transaction ID: #{response.result.id}"
|
|
@@ -57,4 +63,4 @@ If you have any issue with the Fat Zebra Ruby Client please contact us at suppor
|
|
|
57
63
|
|
|
58
64
|
Pull Requests
|
|
59
65
|
-------------
|
|
60
|
-
If you would like to contribute to the plugin please fork the project, make your changes within a feature branch and then submit a pull request. All pull requests will be reviewed as soon as possible and integrated into the main branch if deemed suitable.
|
|
66
|
+
If you would like to contribute to the plugin please fork the project, make your changes within a feature branch and then submit a pull request. All pull requests will be reviewed as soon as possible and integrated into the main branch if deemed suitable.
|
|
@@ -42,7 +42,7 @@ module FatZebra
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
params.delete_if {|key, value| value.nil? } # If token is nil, remove, otherwise, remove card values
|
|
45
|
-
|
|
45
|
+
validate_params!(params)
|
|
46
46
|
response = FatZebra.gateway.make_request(:post, "purchases", params)
|
|
47
47
|
Response.new(response)
|
|
48
48
|
end
|
|
@@ -106,6 +106,22 @@ module FatZebra
|
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
+
# Private: Validates the parameters provided meet the gateway requirements
|
|
110
|
+
#
|
|
111
|
+
# params - the parameter hash to be validated
|
|
112
|
+
#
|
|
113
|
+
# Returns nil
|
|
114
|
+
# Raises FatZebra::RequestError if errors are present.
|
|
115
|
+
def validate_params!(params)
|
|
116
|
+
@errors = []
|
|
117
|
+
@errors << "number or token must be provided" unless params[:card_number].present? || params[:card_token].present?
|
|
118
|
+
@errors << "amount must be provided or greater then 0" unless params[:amount].present? && params[:amount].to_f > 0
|
|
119
|
+
@errors << "expiry must be provided" unless params[:card_token].present? || params[:card_expiry].present?
|
|
120
|
+
@errors << "reference must be provided" unless params[:reference].present?
|
|
121
|
+
@errors << "customer_ip must be procided" unless params[:customer_ip].present?
|
|
122
|
+
|
|
123
|
+
raise FatZebra::RequestError.new("The following errors prevent the transaction from being submitted: #{@errors.to_sentence}") if @errors.any?
|
|
124
|
+
end
|
|
109
125
|
end
|
|
110
126
|
end
|
|
111
127
|
end
|
data/lib/fat_zebra/version.rb
CHANGED
data/lib/fat_zebra.rb
CHANGED
data/spec/gateway_spec.rb
CHANGED
|
@@ -5,6 +5,9 @@ TEST_TOKEN = "TEST"
|
|
|
5
5
|
TEST_LOCAL = ENV["TEST_LOCAL"] == "true" || false
|
|
6
6
|
|
|
7
7
|
describe FatZebra::Gateway do
|
|
8
|
+
let(:valid_card) { "5123456789012346" }
|
|
9
|
+
let(:valid_expiry) { 1.year.from_now.strftime("%m/%Y") }
|
|
10
|
+
|
|
8
11
|
before :each do
|
|
9
12
|
# Setup the gateway for testing
|
|
10
13
|
server = TEST_LOCAL == true ? "fatapi.dev" : "gateway.sandbox.fatzebra.com.au"
|
|
@@ -32,20 +35,20 @@ describe FatZebra::Gateway do
|
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
it "should perform a purchase" do
|
|
35
|
-
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number =>
|
|
38
|
+
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number => valid_card, :expiry => valid_expiry, :cvv => 123}, "TEST#{rand}", "1.2.3.4")
|
|
36
39
|
result.should be_successful
|
|
37
40
|
result.errors.should be_empty
|
|
38
41
|
end
|
|
39
42
|
|
|
40
43
|
it "should fetch a purchase" do
|
|
41
|
-
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number =>
|
|
44
|
+
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number => valid_card, :expiry => valid_expiry, :cvv => 123}, "TES#{rand}T", "1.2.3.4")
|
|
42
45
|
purchase = FatZebra::Models::Purchase.find(:id => result.purchase.id)
|
|
43
46
|
purchase.id.should == result.purchase.id
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
it "should fetch a purchase via reference" do
|
|
47
50
|
ref = "TES#{rand}T"
|
|
48
|
-
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number =>
|
|
51
|
+
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number => valid_card, :expiry => valid_expiry, :cvv => 123}, ref, "1.2.3.4")
|
|
49
52
|
|
|
50
53
|
purchases = FatZebra::Models::Purchase.find(:reference => ref)
|
|
51
54
|
purchases.id.should == result.purchase.id
|
|
@@ -54,7 +57,7 @@ describe FatZebra::Gateway do
|
|
|
54
57
|
# it "should fetch purchases within a date range" do
|
|
55
58
|
# start = Time.now
|
|
56
59
|
# 5.times do |i|
|
|
57
|
-
# @gw.purchase(10000, {:card_holder => "Matthew Savage", :card_number =>
|
|
60
|
+
# @gw.purchase(10000, {:card_holder => "Matthew Savage", :card_number => valid_card, :card_expiry => valid_expiry, :cvv => 123}, "TEST#{rand(1000)}-#{i}", "1.2.3.4")
|
|
58
61
|
# end
|
|
59
62
|
|
|
60
63
|
# purchases = @gw.purchases(:from => start - 300, :to => Time.now + 300)
|
|
@@ -64,7 +67,7 @@ describe FatZebra::Gateway do
|
|
|
64
67
|
it "should fetch purchases with a from date" do
|
|
65
68
|
start = Time.now
|
|
66
69
|
5.times do |i|
|
|
67
|
-
FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number =>
|
|
70
|
+
FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number => valid_card, :expiry => valid_expiry, :cvv => 123}, "TEST#{rand(1000)}-#{i}", "1.2.3.4")
|
|
68
71
|
end
|
|
69
72
|
|
|
70
73
|
purchases = FatZebra::Models::Purchase.find(:from => start)
|
|
@@ -72,7 +75,7 @@ describe FatZebra::Gateway do
|
|
|
72
75
|
end
|
|
73
76
|
|
|
74
77
|
it "should refund a transaction" do
|
|
75
|
-
purchase = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number =>
|
|
78
|
+
purchase = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number => valid_card, :expiry => valid_expiry, :cvv => 123}, "TES#{rand}T", "1.2.3.4")
|
|
76
79
|
result = FatZebra::Models::Refund.create(purchase.result.id, 100, "REFUND-#{purchase.result.id}")
|
|
77
80
|
|
|
78
81
|
result.should be_successful
|
|
@@ -80,13 +83,13 @@ describe FatZebra::Gateway do
|
|
|
80
83
|
end
|
|
81
84
|
|
|
82
85
|
it "should tokenize a card" do
|
|
83
|
-
response = @gw.tokenize("M Smith", "5123456789012346",
|
|
86
|
+
response = @gw.tokenize("M Smith", "5123456789012346", valid_expiry, "123")
|
|
84
87
|
response.should be_successful
|
|
85
88
|
response.result.token.should_not be_nil
|
|
86
89
|
end
|
|
87
90
|
|
|
88
91
|
# it "should fetch a tokenized card" do
|
|
89
|
-
# token = @gw.tokenize("M Smith", "5123456789012346",
|
|
92
|
+
# token = @gw.tokenize("M Smith", "5123456789012346", valid_expiry, "123").result.token
|
|
90
93
|
# card_response = @gw.tokenized_card(token)
|
|
91
94
|
|
|
92
95
|
# card_response.should be_successful
|
|
@@ -101,7 +104,7 @@ describe FatZebra::Gateway do
|
|
|
101
104
|
# end
|
|
102
105
|
|
|
103
106
|
it "should perform a purchase with a tokenized card" do
|
|
104
|
-
token = @gw.tokenize("M Smith", "5123456789012346",
|
|
107
|
+
token = @gw.tokenize("M Smith", "5123456789012346", valid_expiry, "123").result.token
|
|
105
108
|
purchase = @gw.purchase(10000, {:token => token}, "TEST#{rand}}", "127.0.0.1")
|
|
106
109
|
|
|
107
110
|
purchase.should be_successful
|
|
@@ -109,7 +112,7 @@ describe FatZebra::Gateway do
|
|
|
109
112
|
end
|
|
110
113
|
|
|
111
114
|
it "should transact in USD" do
|
|
112
|
-
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number =>
|
|
115
|
+
result = FatZebra::Models::Purchase.create(10000, {:card_holder => "Matthew Savage", :number => valid_card, :expiry => valid_expiry, :cvv => 123}, "TEST#{rand}", "1.2.3.4", 'USD')
|
|
113
116
|
result.should be_successful, result.raw
|
|
114
117
|
result.errors.should be_empty
|
|
115
118
|
result.result.currency.should == 'USD'
|
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:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Savage
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-11-
|
|
11
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -108,6 +108,20 @@ dependencies:
|
|
|
108
108
|
- - ! '>='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: activesupport
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ! '>='
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
111
125
|
description: Provides integration with the Fat Zebra internet payment gateway (www.fatzebra.com.au),
|
|
112
126
|
including purchase, refund, auth, capture and recurring billing functionality.
|
|
113
127
|
email:
|