finswitz 1.0.0 → 1.1.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 +4 -4
- data/README.md +99 -18
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff7e66f15c0e05025c3c2f6cd9c0c32d972bbc3fbe4d13faae1dff8d91d6960b
|
|
4
|
+
data.tar.gz: afd04594a00f3cb76983d9aeedc6ce3500c731bd0affdb1c426a7335370c2222
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9103ff9bd1c7929a10f3c86e01f750c7359d2c4d809a5f5cc4dea84f6e6285b25a6030d5cf521d5767390740944f1081e081fe72e457f9845b248a8c42bc214
|
|
7
|
+
data.tar.gz: 06f58232bec6a63c5b0f550ad46c9b574ff358cca2da416276e78e5a4a36a8507ce6f27b56bf738399d5afc7fe38b5d945c21a6ef6bf5068164de9398cbe774b
|
data/README.md
CHANGED
|
@@ -1,35 +1,116 @@
|
|
|
1
|
-
# Finswitz
|
|
1
|
+
# Finswitz Ruby SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/finswitz`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
3
|
+
Ruby client for the Finswitz API.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
The Ruby SDK is currently distributed as a source client. Add `finswitz.rb` to your application and require it from your server-side code.
|
|
8
|
+
|
|
9
|
+
When a gem is published, this README should be updated with the gem install command.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Ruby 3.0 or newer
|
|
14
|
+
- A Finswitz test or live secret key
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
```ruby
|
|
19
|
+
require_relative "finswitz"
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
client = Finswitz::Client.new(api_key: ENV.fetch("FINSWITZ_SECRET_KEY"))
|
|
22
|
+
|
|
23
|
+
link = client.create_payment_link(
|
|
24
|
+
{
|
|
25
|
+
amount: 5000,
|
|
26
|
+
currency: "NGN",
|
|
27
|
+
title: "Order #1234",
|
|
28
|
+
email: "buyer@example.com",
|
|
29
|
+
callback_url: "https://merchant.example/complete"
|
|
30
|
+
},
|
|
31
|
+
idempotency_key: "order-1234-link"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
puts link["checkoutUrl"]
|
|
15
35
|
```
|
|
16
36
|
|
|
17
|
-
|
|
37
|
+
## Custom Base URL
|
|
18
38
|
|
|
19
|
-
```
|
|
20
|
-
|
|
39
|
+
```ruby
|
|
40
|
+
client = Finswitz::Client.new(
|
|
41
|
+
api_key: ENV.fetch("FINSWITZ_SECRET_KEY"),
|
|
42
|
+
base_url: "http://localhost:4000"
|
|
43
|
+
)
|
|
21
44
|
```
|
|
22
45
|
|
|
23
|
-
##
|
|
46
|
+
## Payments
|
|
24
47
|
|
|
25
|
-
|
|
48
|
+
```ruby
|
|
49
|
+
client.transfer(
|
|
50
|
+
{
|
|
51
|
+
amount: 5000,
|
|
52
|
+
currency: "NGN",
|
|
53
|
+
bank_code: "058",
|
|
54
|
+
account_number: "0123456789",
|
|
55
|
+
narration: "Vendor payout"
|
|
56
|
+
},
|
|
57
|
+
idempotency_key: "transfer-001"
|
|
58
|
+
)
|
|
26
59
|
|
|
27
|
-
|
|
60
|
+
client.mobile_money(
|
|
61
|
+
{
|
|
62
|
+
amount: 1500,
|
|
63
|
+
currency: "GHS",
|
|
64
|
+
phone: "+233501112222",
|
|
65
|
+
country: "GH"
|
|
66
|
+
},
|
|
67
|
+
idempotency_key: "momo-001"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
transaction = client.get_transaction("reference")
|
|
71
|
+
```
|
|
28
72
|
|
|
29
|
-
|
|
73
|
+
## Dashboard JWT Helpers
|
|
30
74
|
|
|
31
|
-
|
|
75
|
+
```ruby
|
|
76
|
+
client = Finswitz::Client.new(
|
|
77
|
+
api_key: ENV.fetch("FINSWITZ_SECRET_KEY"),
|
|
78
|
+
dashboard_token: ENV.fetch("FINSWITZ_DASHBOARD_TOKEN")
|
|
79
|
+
)
|
|
32
80
|
|
|
33
|
-
|
|
81
|
+
client.update_webhooks({
|
|
82
|
+
mode: "test",
|
|
83
|
+
url: "https://merchant.example/webhooks/finswitz"
|
|
84
|
+
})
|
|
34
85
|
|
|
35
|
-
|
|
86
|
+
wallets = client.wallets
|
|
87
|
+
treasury = client.treasury
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Collections
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
collection = client.public_collection("school-fees")
|
|
94
|
+
|
|
95
|
+
payment = client.pay_collection(
|
|
96
|
+
"school-fees",
|
|
97
|
+
{
|
|
98
|
+
fullName: "Grace Johnson",
|
|
99
|
+
email: "grace@example.com",
|
|
100
|
+
amount: 10000,
|
|
101
|
+
phone: "+2348012345678"
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Error Handling
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
begin
|
|
110
|
+
client.get_transaction("missing-reference")
|
|
111
|
+
rescue Finswitz::ApiError => error
|
|
112
|
+
warn error.status
|
|
113
|
+
warn error.response
|
|
114
|
+
raise
|
|
115
|
+
end
|
|
116
|
+
```
|