tazapay 0.1.0 → 0.1.2
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/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +92 -2
- data/lib/tazapay/bank.rb +30 -0
- data/lib/tazapay/client.rb +9 -3
- data/lib/tazapay/errors.rb +2 -1
- data/lib/tazapay/user.rb +26 -0
- data/lib/tazapay/version.rb +1 -1
- data/lib/tazapay.rb +2 -0
- metadata +4 -3
- data/LICENSE +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11df37a78614be73791738660b0c7b8c449101ea8e920bfff7b30b0f5e752a03
|
4
|
+
data.tar.gz: 2f72d20bdc2498e817e3d7a2e4e202fc5e97c164f106b4c5fdbb639ab8a53bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ab6bdad83dc4f993114f82d152da5683a0c8f20153e71e0fbfdc5b6baebca426dbb2e27fcba7cb006f18803e78e0f924c82fc4c50005c456ee99815730d3e4
|
7
|
+
data.tar.gz: 2e3b49a30e61533b7ecf4ca7c43f47b2aefb5a0213c939e9e4d5ffe9cd55182b7eb76c39ca8108c36d1861aff5acd49209fab4f573a4e0bae698da972934ff30
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,97 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
-
|
19
|
+
### Setup Tazapay client
|
20
|
+
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require "tazapay"
|
24
|
+
|
25
|
+
Tazapay.configure do |config|
|
26
|
+
config.base_url = "<SANDBOX_API_URL / PRODUCTION_API_URL>"
|
27
|
+
config.access_key = "<API_Key>"
|
28
|
+
config.secret_key = "<API_Secret>"
|
29
|
+
end
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
### Checkout
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
|
37
|
+
tazapay_checkout = Tazapay::Checkout.new
|
38
|
+
|
39
|
+
# Create payment transaction
|
40
|
+
tx_number = tazapay_checkout.pay(data)["data"]["txn_no"]
|
41
|
+
|
42
|
+
# Check transaction status
|
43
|
+
data = tazapay_checkout.get_status(tx_number)
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
### User
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
|
51
|
+
tazapay_user = Tazapay::User.new
|
52
|
+
|
53
|
+
data = {
|
54
|
+
email: "sometest+12@mail.io",
|
55
|
+
country: "SG",
|
56
|
+
ind_bus_type: "Business",
|
57
|
+
business_name: "TEST SANDBOX",
|
58
|
+
contact_code: "+65",
|
59
|
+
contact_number: "9999999999",
|
60
|
+
partners_customer_id: "test-123"
|
61
|
+
}
|
62
|
+
|
63
|
+
# Create user
|
64
|
+
user_id = tazapay_user.create(data)["data"]["account_id"]
|
65
|
+
|
66
|
+
# Update user
|
67
|
+
tazapay_user.update(user_id, new_data)
|
68
|
+
|
69
|
+
# Find user by ID
|
70
|
+
tazapay_user.find(user_id)
|
71
|
+
|
72
|
+
# Find user by Email
|
73
|
+
tazapay_user.find(email)
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
See more details in tests
|
78
|
+
|
79
|
+
### Bank
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
|
83
|
+
tazapay_bank = Tazapay::Bank.new
|
84
|
+
|
85
|
+
data = {
|
86
|
+
email: "sometest+12@mail.io",
|
87
|
+
country: "SG",
|
88
|
+
ind_bus_type: "Business",
|
89
|
+
business_name: "TEST SANDBOX",
|
90
|
+
contact_code: "+65",
|
91
|
+
contact_number: "9999999999",
|
92
|
+
partners_customer_id: "test-123"
|
93
|
+
}
|
94
|
+
|
95
|
+
# Add bank account
|
96
|
+
bank_id = tazapay_bank.add(
|
97
|
+
account_id: user_id, bank_data: new_data
|
98
|
+
)['data']['bank_id']
|
99
|
+
|
100
|
+
# List user banks
|
101
|
+
tazapay_bank.list(user_id)
|
102
|
+
|
103
|
+
# Make bank account primary
|
104
|
+
tazapay_bank.make_primary(bank_id: bank_id, account_id: user_id)
|
105
|
+
|
106
|
+
```
|
107
|
+
|
108
|
+
See more details in tests
|
109
|
+
|
20
110
|
|
21
111
|
## Development
|
22
112
|
|
@@ -26,7 +116,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
26
116
|
|
27
117
|
## Contributing
|
28
118
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
119
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lxkuz/tazapay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tazapay/blob/main/CODE_OF_CONDUCT.md).
|
30
120
|
|
31
121
|
## License
|
32
122
|
|
data/lib/tazapay/bank.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Implementation of the MTN API remittances client
|
4
|
+
|
5
|
+
require "tazapay/config"
|
6
|
+
require "tazapay/client"
|
7
|
+
|
8
|
+
module Tazapay
|
9
|
+
# Bank API
|
10
|
+
class Bank < Client
|
11
|
+
def add(account_id:, bank_data:)
|
12
|
+
path = "v1/bank"
|
13
|
+
data = bank_data.merge(account_id: account_id)
|
14
|
+
send_request(method: :post, path: path, body: data)
|
15
|
+
end
|
16
|
+
|
17
|
+
def list(account_id)
|
18
|
+
path = "v1/bank/#{account_id}"
|
19
|
+
send_request(method: :get, path: path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def make_primary(account_id:, bank_id:)
|
23
|
+
path = "v1/bank/primary"
|
24
|
+
send_request(method: :put, path: path, body: {
|
25
|
+
account_id: account_id,
|
26
|
+
bank_id: bank_id
|
27
|
+
})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/tazapay/client.rb
CHANGED
@@ -13,12 +13,11 @@ module Tazapay
|
|
13
13
|
# Base API client
|
14
14
|
class Client
|
15
15
|
def send_request(method:, path:, headers: default_headers, body: {})
|
16
|
-
conn =
|
17
|
-
conn.headers = headers
|
18
|
-
conn.basic_auth(Tazapay.config.access_key, Tazapay.config.secret_key)
|
16
|
+
conn = prepare_connection(headers)
|
19
17
|
case method.to_s
|
20
18
|
when "get" then response = conn.get(path)
|
21
19
|
when "post" then response = conn.post(path, body.to_json)
|
20
|
+
when "put" then response = conn.put(path, body.to_json)
|
22
21
|
end
|
23
22
|
interpret_response(response)
|
24
23
|
end
|
@@ -39,6 +38,13 @@ module Tazapay
|
|
39
38
|
|
40
39
|
private
|
41
40
|
|
41
|
+
def prepare_connection(headers)
|
42
|
+
conn = faraday_with_block(url: Tazapay.config.base_url)
|
43
|
+
conn.headers = headers
|
44
|
+
conn.basic_auth(Tazapay.config.access_key, Tazapay.config.secret_key)
|
45
|
+
conn
|
46
|
+
end
|
47
|
+
|
42
48
|
def faraday_with_block(options)
|
43
49
|
Faraday.new(options)
|
44
50
|
block = Tazapay.config.faraday_block
|
data/lib/tazapay/errors.rb
CHANGED
@@ -5,10 +5,11 @@
|
|
5
5
|
module Tazapay
|
6
6
|
# Stanadrd API error
|
7
7
|
class Error < StandardError
|
8
|
-
attr_reader :code
|
8
|
+
attr_reader :code, :response_body
|
9
9
|
|
10
10
|
def initialize(message, code)
|
11
11
|
@code = code
|
12
|
+
@response_body = message
|
12
13
|
super("Error code #{code} #{message}")
|
13
14
|
end
|
14
15
|
end
|
data/lib/tazapay/user.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Implementation of the MTN API remittances client
|
4
|
+
|
5
|
+
require "tazapay/config"
|
6
|
+
require "tazapay/client"
|
7
|
+
|
8
|
+
module Tazapay
|
9
|
+
# Users API
|
10
|
+
class User < Client
|
11
|
+
def create(data)
|
12
|
+
path = "v1/user"
|
13
|
+
send_request(method: :post, path: path, body: data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(id, data)
|
17
|
+
path = "v1/user"
|
18
|
+
send_request(method: :post, path: path, body: data.merge(account_id: id))
|
19
|
+
end
|
20
|
+
|
21
|
+
def find(id_or_email)
|
22
|
+
path = "v1/user/#{id_or_email}"
|
23
|
+
send_request(method: :get, path: path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/tazapay/version.rb
CHANGED
data/lib/tazapay.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tazapay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Kuznetsov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -79,15 +79,16 @@ files:
|
|
79
79
|
- CODE_OF_CONDUCT.md
|
80
80
|
- Gemfile
|
81
81
|
- Gemfile.lock
|
82
|
-
- LICENSE
|
83
82
|
- LICENSE.txt
|
84
83
|
- README.md
|
85
84
|
- Rakefile
|
86
85
|
- lib/tazapay.rb
|
86
|
+
- lib/tazapay/bank.rb
|
87
87
|
- lib/tazapay/checkout.rb
|
88
88
|
- lib/tazapay/client.rb
|
89
89
|
- lib/tazapay/config.rb
|
90
90
|
- lib/tazapay/errors.rb
|
91
|
+
- lib/tazapay/user.rb
|
91
92
|
- lib/tazapay/version.rb
|
92
93
|
- sig/tazapay.rbs
|
93
94
|
- tazapay.gemspec
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2023 Alexey
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|