fat_zebra_multi 3.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +0 -0
- data/.rubocop.yml +44 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/README.md +104 -0
- data/Rakefile +11 -0
- data/fat_zebra_multi.gemspec +27 -0
- data/lib/fat_zebra.rb +65 -0
- data/lib/fat_zebra/api_helper.rb +91 -0
- data/lib/fat_zebra/api_operation/delete.rb +38 -0
- data/lib/fat_zebra/api_operation/find.rb +30 -0
- data/lib/fat_zebra/api_operation/save.rb +67 -0
- data/lib/fat_zebra/api_operation/search.rb +39 -0
- data/lib/fat_zebra/api_operation/void.rb +52 -0
- data/lib/fat_zebra/api_resource.rb +88 -0
- data/lib/fat_zebra/bank_account.rb +20 -0
- data/lib/fat_zebra/batch.rb +60 -0
- data/lib/fat_zebra/card.rb +23 -0
- data/lib/fat_zebra/config.rb +90 -0
- data/lib/fat_zebra/customer.rb +26 -0
- data/lib/fat_zebra/direct_credit.rb +26 -0
- data/lib/fat_zebra/direct_debit.rb +26 -0
- data/lib/fat_zebra/errors.rb +37 -0
- data/lib/fat_zebra/fat_zebra_object.rb +68 -0
- data/lib/fat_zebra/information.rb +29 -0
- data/lib/fat_zebra/object_helper.rb +119 -0
- data/lib/fat_zebra/payment_plan.rb +61 -0
- data/lib/fat_zebra/purchase.rb +96 -0
- data/lib/fat_zebra/refund.rb +27 -0
- data/lib/fat_zebra/request.rb +174 -0
- data/lib/fat_zebra/request/multipart/epilogue.rb +23 -0
- data/lib/fat_zebra/request/multipart/file_io.rb +40 -0
- data/lib/fat_zebra/request/multipart/param.rb +37 -0
- data/lib/fat_zebra/request/multipart/part.rb +28 -0
- data/lib/fat_zebra/request/multipart/stream.rb +57 -0
- data/lib/fat_zebra/util.rb +71 -0
- data/lib/fat_zebra/validation.rb +67 -0
- data/lib/fat_zebra/version.rb +3 -0
- data/lib/fat_zebra/web_hook.rb +22 -0
- data/spec/cassettes/FatZebra_BankAccount/_create/1_1_1.yml +53 -0
- data/spec/cassettes/FatZebra_BankAccount/_create/1_1_2.yml +53 -0
- data/spec/cassettes/FatZebra_BankAccount/_search/1_2_1.yml +164 -0
- data/spec/cassettes/FatZebra_BankAccount/_search/1_2_2.yml +164 -0
- data/spec/cassettes/FatZebra_BankAccount/_search/1_2_3.yml +164 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_1.yml +61 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_file/1_1_1_2.yml +61 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_1.yml +61 -0
- data/spec/cassettes/FatZebra_Batch/_create/with_path/1_1_2_2.yml +61 -0
- data/spec/cassettes/FatZebra_Batch/_find/1_2_1.yml +112 -0
- data/spec/cassettes/FatZebra_Batch/_find/1_2_2.yml +112 -0
- data/spec/cassettes/FatZebra_Batch/_result/1_4_1.yml +163 -0
- data/spec/cassettes/FatZebra_Batch/_search/1_3_1.yml +54 -0
- data/spec/cassettes/FatZebra_Batch/_search/1_3_2.yml +54 -0
- data/spec/cassettes/FatZebra_Batch/_search/1_3_3.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_1.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_2.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_3.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_4.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_5.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_create/1_1_6.yml +54 -0
- data/spec/cassettes/FatZebra_Card/_update/1_2_1.yml +105 -0
- data/spec/cassettes/FatZebra_Card/_update/1_2_2.yml +105 -0
- data/spec/cassettes/FatZebra_Card/_update/1_2_3.yml +105 -0
- data/spec/cassettes/FatZebra_Card/_update/validations/1_2_4_1.yml +54 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_1.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_2.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_3.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_4.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_5.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_create/1_1_6.yml +55 -0
- data/spec/cassettes/FatZebra_Customer/_delete/1_5_1.yml +103 -0
- data/spec/cassettes/FatZebra_Customer/_find/1_3_1.yml +107 -0
- data/spec/cassettes/FatZebra_Customer/_find/1_3_2.yml +107 -0
- data/spec/cassettes/FatZebra_Customer/_search/1_2_1.yml +60 -0
- data/spec/cassettes/FatZebra_Customer/_search/1_2_2.yml +60 -0
- data/spec/cassettes/FatZebra_Customer/_search/1_2_3.yml +60 -0
- data/spec/cassettes/FatZebra_Customer/_update/1_4_1.yml +106 -0
- data/spec/cassettes/FatZebra_Customer/_update/1_4_2.yml +106 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_1.yml +52 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_2.yml +52 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_3.yml +52 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/1_1_4.yml +52 -0
- data/spec/cassettes/FatZebra_DirectCredit/_create/validations/valid/1_1_5_1_1.yml +52 -0
- data/spec/cassettes/FatZebra_DirectCredit/_delete/1_4_1.yml +99 -0
- data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_1.yml +103 -0
- data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_2.yml +103 -0
- data/spec/cassettes/FatZebra_DirectCredit/_find/1_2_3.yml +103 -0
- data/spec/cassettes/FatZebra_DirectCredit/_search/1_3_1.yml +152 -0
- data/spec/cassettes/FatZebra_DirectCredit/_search/1_3_2.yml +152 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_1.yml +52 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_2.yml +52 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_3.yml +52 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/1_1_4.yml +52 -0
- data/spec/cassettes/FatZebra_DirectDebit/_create/validations/valid/1_1_5_1_1.yml +52 -0
- data/spec/cassettes/FatZebra_DirectDebit/_delete/1_4_1.yml +99 -0
- data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_1.yml +103 -0
- data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_2.yml +103 -0
- data/spec/cassettes/FatZebra_DirectDebit/_find/1_2_3.yml +103 -0
- data/spec/cassettes/FatZebra_DirectDebit/_search/1_3_1.yml +152 -0
- data/spec/cassettes/FatZebra_DirectDebit/_search/1_3_2.yml +152 -0
- data/spec/cassettes/FatZebra_Information/_ping/1_1_1.yml +54 -0
- data/spec/cassettes/FatZebra_Information/_ping/1_1_2.yml +54 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_8_1.yml +222 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_active_/1_8_2.yml +222 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_1.yml +110 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_2.yml +110 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_create/1_1_3.yml +110 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_delete/1_5_1.yml +158 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_destroy/1_6_1.yml +158 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_1.yml +167 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_2.yml +167 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_find/1_2_3.yml +167 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_7_1.yml +166 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_suspend_/1_7_2.yml +166 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_1.yml +160 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_2.yml +160 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_3_3.yml +160 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_4_1.yml +166 -0
- data/spec/cassettes/FatZebra_PaymentPlan/_update/1_4_2.yml +166 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_5_1.yml +115 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_5_2.yml +115 -0
- data/spec/cassettes/FatZebra_Purchase/_capture/1_5_3.yml +115 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_1.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_10.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_11.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_12.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_13.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_2.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_3.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_4.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_5.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_6.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_7.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_8.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/1_1_9.yml +53 -0
- data/spec/cassettes/FatZebra_Purchase/_create/bad_request/1_1_14_1.yml +55 -0
- data/spec/cassettes/FatZebra_Purchase/_create/bad_request/1_1_14_2.yml +55 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_1.yml +117 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_2.yml +117 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_3.yml +117 -0
- data/spec/cassettes/FatZebra_Purchase/_find/1_2_4.yml +117 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_4_1.yml +115 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_4_2.yml +115 -0
- data/spec/cassettes/FatZebra_Purchase/_refund/1_4_3.yml +115 -0
- data/spec/cassettes/FatZebra_Purchase/_search/1_3_1.yml +164 -0
- data/spec/cassettes/FatZebra_Purchase/_search/1_3_2.yml +164 -0
- data/spec/cassettes/FatZebra_Purchase/_search/1_3_3.yml +164 -0
- data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_1.yml +652 -0
- data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_2.yml +652 -0
- data/spec/cassettes/FatZebra_Purchase/_settlement/1_8_3.yml +652 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_1.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_2.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_3.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_6_4.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_1.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_2.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_3.yml +103 -0
- data/spec/cassettes/FatZebra_Purchase/_void/1_7_4.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_1.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_10.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_2.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_3.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_4.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_5.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_6.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_7.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_8.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_create/1_1_9.yml +103 -0
- data/spec/cassettes/FatZebra_Refund/_find/1_2_1.yml +155 -0
- data/spec/cassettes/FatZebra_Refund/_find/1_2_2.yml +155 -0
- data/spec/cassettes/FatZebra_Refund/_find/1_2_3.yml +155 -0
- data/spec/cassettes/FatZebra_Refund/_search/responds_with_the_newly-created_refunds.yml +214 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_1.yml +153 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_2.yml +153 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_3.yml +153 -0
- data/spec/cassettes/FatZebra_Refund/_void/1_4_4.yml +153 -0
- data/spec/cassettes/FatZebra_WebHook/_create/1_1_1.yml +53 -0
- data/spec/cassettes/FatZebra_WebHook/_create/1_1_2.yml +53 -0
- data/spec/cassettes/FatZebra_WebHook/_create/1_1_3.yml +53 -0
- data/spec/cassettes/FatZebra_WebHook/_delete/1_4_1.yml +101 -0
- data/spec/cassettes/FatZebra_WebHook/_search/1_2_1.yml +298 -0
- data/spec/cassettes/FatZebra_WebHook/_search/1_2_2.yml +300 -0
- data/spec/cassettes/FatZebra_WebHook/_update/1_3_1.yml +104 -0
- data/spec/cassettes/FatZebra_WebHook/_update/1_3_2.yml +104 -0
- data/spec/cassettes/Multiple_accounts/The_basics/1_1_5.yml +59 -0
- data/spec/cassettes/Multiple_accounts/The_basics/1_1_6.yml +59 -0
- data/spec/fixtures/batch_test.csv +4 -0
- data/spec/lib/fat_zebra/api_resource_spec.rb +25 -0
- data/spec/lib/fat_zebra/bank_account_spec.rb +34 -0
- data/spec/lib/fat_zebra/batch_spec.rb +59 -0
- data/spec/lib/fat_zebra/card_spec.rb +41 -0
- data/spec/lib/fat_zebra/config_spec.rb +69 -0
- data/spec/lib/fat_zebra/customer_spec.rb +53 -0
- data/spec/lib/fat_zebra/direct_credit_spec.rb +74 -0
- data/spec/lib/fat_zebra/direct_debit_spec.rb +74 -0
- data/spec/lib/fat_zebra/fat_zebra_object_spec.rb +117 -0
- data/spec/lib/fat_zebra/information_spec.rb +13 -0
- data/spec/lib/fat_zebra/multiple_accounts_spec.rb +69 -0
- data/spec/lib/fat_zebra/payment_plan_spec.rb +94 -0
- data/spec/lib/fat_zebra/purchase_spec.rb +105 -0
- data/spec/lib/fat_zebra/refund_spec.rb +95 -0
- data/spec/lib/fat_zebra/request_spec.rb +59 -0
- data/spec/lib/fat_zebra/util_spec.rb +43 -0
- data/spec/lib/fat_zebra/validation_spec.rb +22 -0
- data/spec/lib/fat_zebra/web_hook_spec.rb +50 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/support/payloads.rb +43 -0
- data/vendor/cacert.pem +3390 -0
- metadata +338 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee47c7e08352ee5db3f0648ccbb0331af1e0cbf6e2364cddbae5525f747cf5a0
|
4
|
+
data.tar.gz: 57a95b2cd2f58cd814798f990bb5b03267dd42e607febcfd7c568f57a44709ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7914d2d1e23cdce79db77fb6ea0aeab26039344b2cc5a1d3157089ebad6e577d693048f3c901d1a70345a1ff97063b165e89f579c29120e475507bb81134b2eb
|
7
|
+
data.tar.gz: 1fd30cea517d76df7612752972f83089a33a201092d8b3dd6483a5ece8faa01eecb3bb895d534d09c52ce9471bff407b8d030b64fcab3b82692f876164dd0e6b
|
data/.gitignore
ADDED
data/.rspec
ADDED
File without changes
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Layout/EmptyLinesAroundClassBody:
|
2
|
+
Enabled: false
|
3
|
+
Layout/EmptyLinesAroundModuleBody:
|
4
|
+
Enabled: false
|
5
|
+
Layout/EmptyLinesAroundBlockBody:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Style/MissingRespondToMissing:
|
9
|
+
Enabled: false
|
10
|
+
Style/MethodMissingSuper:
|
11
|
+
Enabled: false
|
12
|
+
Style/NumericPredicate:
|
13
|
+
Enabled: false
|
14
|
+
Style/FrozenStringLiteralComment:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/AbcSize:
|
18
|
+
# The ABC size is a calculated magnitude, so this number can be a Fixnum or
|
19
|
+
# a Float.
|
20
|
+
Max: 27
|
21
|
+
Metrics/LineLength:
|
22
|
+
Max: 200
|
23
|
+
Metrics/ClassLength:
|
24
|
+
CountComments: false
|
25
|
+
Max: 200
|
26
|
+
Metrics/MethodLength:
|
27
|
+
CountComments: false
|
28
|
+
Max: 25
|
29
|
+
Metrics/ModuleLength:
|
30
|
+
CountComments: false
|
31
|
+
Max: 200
|
32
|
+
Metrics/CyclomaticComplexity:
|
33
|
+
Max: 7
|
34
|
+
|
35
|
+
Documentation:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
AllCops:
|
39
|
+
TargetRubyVersion: 2.3
|
40
|
+
Exclude:
|
41
|
+
- bin/**/*
|
42
|
+
- vendor/**/*
|
43
|
+
- tmp/**/*
|
44
|
+
- spec/**/*
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
Ruby API Library for Fat Zebra
|
2
|
+
==============================
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/supporterhub/fat-zebra-api-client.svg?branch=master)](https://travis-ci.org/supporterhub/fat-zebra-api-client)
|
5
|
+
|
6
|
+
A Ruby client for the [Fat Zebra](https://www.fatzebra.com.au) Online Payment Gateway (for Australian Merchants)
|
7
|
+
|
8
|
+
This is an unofficial fork of the Fat Zebra API client. This version has been patched to allow multiple accounts to be used simultaneously.
|
9
|
+
|
10
|
+
Version 3.1.0.1 of this gem aims to be a drop-in replacement for version 3.1.0 of the official gem.
|
11
|
+
|
12
|
+
It aims to maintain parity with the [official Fat Zebra API client](https://github.com/fatzebra/Ruby-Library).
|
13
|
+
|
14
|
+
Dependencies
|
15
|
+
------------
|
16
|
+
|
17
|
+
* Ruby (tested on 2.3, 2.4, 2.5, 2.6)
|
18
|
+
* Rest Client
|
19
|
+
|
20
|
+
Installing
|
21
|
+
----------
|
22
|
+
|
23
|
+
gem install fat_zebra_multi
|
24
|
+
|
25
|
+
Or in a Rails App (or similar, with Bundler), in your Gemfile:
|
26
|
+
|
27
|
+
gem "fat_zebra_multi"
|
28
|
+
|
29
|
+
Usage
|
30
|
+
-----
|
31
|
+
|
32
|
+
With one account:
|
33
|
+
```ruby
|
34
|
+
require 'fat_zebra_multi'
|
35
|
+
|
36
|
+
# Configuration only needs to be done once, usually in your rails initializers
|
37
|
+
FatZebra.configure do |config|
|
38
|
+
config.username = 'TEST'
|
39
|
+
config.token = 'TEST'
|
40
|
+
end
|
41
|
+
|
42
|
+
purchase = FatZebra::Purchase.create(
|
43
|
+
amount: 10000,
|
44
|
+
card_holder: 'Bill Simpson',
|
45
|
+
card_number: '5123456789012346',
|
46
|
+
card_expiry: '05/2023',
|
47
|
+
cvv: '123',
|
48
|
+
reference: 'ORDER-23',
|
49
|
+
customer_ip: '203.99.87.4'
|
50
|
+
)
|
51
|
+
|
52
|
+
if purchase.successful?
|
53
|
+
puts "Transaction ID: #{purchase.id}"
|
54
|
+
else
|
55
|
+
abort "Error in transaction: #{purchase.errors}"
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
With multiple accounts:
|
60
|
+
```ruby
|
61
|
+
require 'fat_zebra_multi'
|
62
|
+
|
63
|
+
account_1 = FatZebra::Config.new(
|
64
|
+
username: 'USERNAME_1',
|
65
|
+
token: 'API_TOKEN_1',
|
66
|
+
)
|
67
|
+
|
68
|
+
account_2 = FatZebra::Config.new(
|
69
|
+
username: 'USERNAME_2',
|
70
|
+
token: 'API_TOKEN_2',
|
71
|
+
)
|
72
|
+
|
73
|
+
purchase = FatZebra::Purchase.create({
|
74
|
+
amount: 10000,
|
75
|
+
card_holder: 'Bill Simpson',
|
76
|
+
card_number: '5123456789012346',
|
77
|
+
card_expiry: '05/2023',
|
78
|
+
cvv: '123',
|
79
|
+
reference: 'ORDER-23',
|
80
|
+
customer_ip: '203.99.87.4'
|
81
|
+
}, {
|
82
|
+
account: account_1
|
83
|
+
})
|
84
|
+
|
85
|
+
if purchase.successful?
|
86
|
+
puts "Transaction ID: #{purchase.id}"
|
87
|
+
else
|
88
|
+
abort "Error in transaction: #{purchase.errors}"
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
|
93
|
+
Documentation
|
94
|
+
-------------
|
95
|
+
|
96
|
+
Full API reference can be found at http://docs.fatzebra.com.au
|
97
|
+
|
98
|
+
Support
|
99
|
+
-------
|
100
|
+
If you have any issue with the Fat Zebra Ruby Client please contact us at support@fatzebra.com.au and we will be more then happy to help out. Alternatively you may raise an issue in github.
|
101
|
+
|
102
|
+
Pull Requests
|
103
|
+
-------------
|
104
|
+
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.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'fat_zebra/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'fat_zebra_multi'
|
8
|
+
s.version = FatZebra::VERSION
|
9
|
+
s.authors = ['Matthew Savage']
|
10
|
+
s.email = ['matt@amasses.net']
|
11
|
+
s.homepage = ''
|
12
|
+
s.summary = 'Unofficial fork of the Fat Zebra API client - integrate your Ruby app with Fat Zebra'
|
13
|
+
s.description = 'Provides integration with the Fat Zebra internet payment gateway (www.fatzebra.com.au), including purchase, refund, auth, capture and recurring billing functionality.'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
|
+
s.require_paths = %w[lib]
|
18
|
+
|
19
|
+
s.add_development_dependency 'pry'
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.6'
|
22
|
+
s.add_development_dependency 'rubocop', '~> 0.58.1'
|
23
|
+
s.add_development_dependency 'vcr', '~> 3.0'
|
24
|
+
s.add_development_dependency 'webmock', '~> 3.0'
|
25
|
+
|
26
|
+
s.required_ruby_version = '~> 2.3'
|
27
|
+
end
|
data/lib/fat_zebra.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Libraries
|
2
|
+
require 'securerandom'
|
3
|
+
require 'json'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'net/http'
|
6
|
+
require 'cgi'
|
7
|
+
require 'date'
|
8
|
+
|
9
|
+
require 'fat_zebra/version'
|
10
|
+
require 'fat_zebra/util'
|
11
|
+
require 'fat_zebra/config'
|
12
|
+
require 'fat_zebra/errors'
|
13
|
+
require 'fat_zebra/validation'
|
14
|
+
require 'fat_zebra/object_helper'
|
15
|
+
require 'fat_zebra/fat_zebra_object'
|
16
|
+
require 'fat_zebra/request'
|
17
|
+
require 'fat_zebra/api_helper'
|
18
|
+
require 'fat_zebra/api_resource'
|
19
|
+
|
20
|
+
# API Operations
|
21
|
+
require 'fat_zebra/api_operation/find'
|
22
|
+
require 'fat_zebra/api_operation/search'
|
23
|
+
require 'fat_zebra/api_operation/save'
|
24
|
+
require 'fat_zebra/api_operation/delete'
|
25
|
+
require 'fat_zebra/api_operation/void'
|
26
|
+
|
27
|
+
# API Resources
|
28
|
+
require 'fat_zebra/purchase'
|
29
|
+
require 'fat_zebra/information'
|
30
|
+
require 'fat_zebra/card'
|
31
|
+
require 'fat_zebra/refund'
|
32
|
+
require 'fat_zebra/payment_plan'
|
33
|
+
require 'fat_zebra/customer'
|
34
|
+
require 'fat_zebra/direct_debit'
|
35
|
+
require 'fat_zebra/direct_credit'
|
36
|
+
require 'fat_zebra/bank_account'
|
37
|
+
require 'fat_zebra/web_hook'
|
38
|
+
require 'fat_zebra/batch'
|
39
|
+
|
40
|
+
##
|
41
|
+
# Implementation of the FatZebra
|
42
|
+
module FatZebra
|
43
|
+
class << self
|
44
|
+
|
45
|
+
##
|
46
|
+
# @return [FatZebra::Config] configurations
|
47
|
+
attr_reader :configurations
|
48
|
+
|
49
|
+
##
|
50
|
+
# Configures the FatZebra API
|
51
|
+
#
|
52
|
+
# @example Default configuration
|
53
|
+
# FatZebra.configure do |config|
|
54
|
+
# config.username = 'my-username'
|
55
|
+
# config.token = 'my-token'
|
56
|
+
# end
|
57
|
+
def configure
|
58
|
+
yield @configurations = FatZebra::Config.new
|
59
|
+
|
60
|
+
FatZebra.configurations.valid!
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module FatZebra
|
2
|
+
##
|
3
|
+
# == FatZebra \Helper
|
4
|
+
#
|
5
|
+
# Help for the api resource
|
6
|
+
module APIHelper
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
##
|
11
|
+
# @return [String] resource path
|
12
|
+
def resource_path(path = nil)
|
13
|
+
(path || @resource_name || CGI.escape(resource_name)).to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# @return [String] resource name
|
18
|
+
def resource_name
|
19
|
+
Util.underscore("#{class_name}s")
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# @return [String] the class name
|
24
|
+
def class_name
|
25
|
+
name.split('::').last
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Send a request to the API
|
30
|
+
def request
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_endpoint_url(base_url, path, params = nil, options = {})
|
35
|
+
host, port = base_url.split(':')
|
36
|
+
port = port.to_i if port
|
37
|
+
|
38
|
+
url_params = Util.compact(
|
39
|
+
host: host,
|
40
|
+
path: path,
|
41
|
+
port: port,
|
42
|
+
query: params
|
43
|
+
)
|
44
|
+
|
45
|
+
return URI::HTTPS.build(url_params) if options[:http_secure]
|
46
|
+
URI::HTTP.build(url_params)
|
47
|
+
end
|
48
|
+
|
49
|
+
def default_headers
|
50
|
+
{
|
51
|
+
headers: {
|
52
|
+
accept: 'application/json',
|
53
|
+
content_type: 'application/json'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# @return [String] resource name
|
62
|
+
def resource_name
|
63
|
+
self.class.resource_name
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# @return [String] resource path
|
68
|
+
def resource_path(path = nil)
|
69
|
+
self.class.resource_path(path)
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Send a request to the API
|
74
|
+
#
|
75
|
+
# @param [Symbol] method for the request
|
76
|
+
# @param [String] endpoint for the request
|
77
|
+
# @param [Hash] options
|
78
|
+
# @param [Hash] Payload
|
79
|
+
#
|
80
|
+
# @return [Hash] response
|
81
|
+
# @raise [FatZebra::RequestError] if the request is invalid
|
82
|
+
def request(method, resource_path, payload = {}, options = {})
|
83
|
+
self.class.request(method, resource_path, payload, options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.included(base)
|
87
|
+
base.extend(ClassMethods)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Delete a resource for the API
|
5
|
+
#
|
6
|
+
module Delete
|
7
|
+
module ClassMethods
|
8
|
+
##
|
9
|
+
# Delete an API Resource
|
10
|
+
#
|
11
|
+
# @param [String] id for the request
|
12
|
+
# @param [Hash] Additional options for the request
|
13
|
+
#
|
14
|
+
# @return [FatZebra::Object] response from the API
|
15
|
+
def delete(id, options = {})
|
16
|
+
response = request(:delete, "#{resource_path}/#{id}", options)
|
17
|
+
initialize_from(response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Delete an API Resources
|
23
|
+
#
|
24
|
+
# @param [Hash] Additional options for the request
|
25
|
+
#
|
26
|
+
# @return [FatZebra::Object] response from the API
|
27
|
+
def destroy(options = {})
|
28
|
+
response = request(:delete, "#{resource_path}/#{id}", {}, options)
|
29
|
+
update_from(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.included(base)
|
33
|
+
base.extend(ClassMethods)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module FatZebra
|
2
|
+
class APIOperation
|
3
|
+
##
|
4
|
+
# == Find a resource for the API
|
5
|
+
#
|
6
|
+
module Find
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
##
|
10
|
+
# Find an API Resource
|
11
|
+
#
|
12
|
+
# @param [String] id for the request
|
13
|
+
# @param [Hash] params for the request
|
14
|
+
# @param [Hash] Additional options for the request
|
15
|
+
#
|
16
|
+
# @return [FatZebra::Object] response from the API
|
17
|
+
def find(id, params = {}, options = {})
|
18
|
+
response = request(:get, "#{resource_path}/#{id}", params, options)
|
19
|
+
initialize_from(response)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.included(base)
|
25
|
+
base.extend(ClassMethods)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|