mono-merchant 0.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 +7 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +8 -0
- data/lib/mono-merchant/api_request.rb +84 -0
- data/lib/mono-merchant/invoice/cancel.rb +25 -0
- data/lib/mono-merchant/invoice/create.rb +60 -0
- data/lib/mono-merchant/invoice/finalize.rb +31 -0
- data/lib/mono-merchant/invoice/item.rb +36 -0
- data/lib/mono-merchant/invoice/payment_info.rb +25 -0
- data/lib/mono-merchant/invoice/remove.rb +22 -0
- data/lib/mono-merchant/invoice/status.rb +15 -0
- data/lib/mono-merchant/pubkey.rb +28 -0
- data/lib/mono-merchant/version.rb +5 -0
- data/lib/mono-merchant/webhook_validator.rb +47 -0
- data/lib/mono-merchant.rb +19 -0
- data/mono-merchant.gemspec +41 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 860b077a7edd26128447c2a0060fed0306052cf77c0407e1962820162458e4f2
|
4
|
+
data.tar.gz: 137cbd38e0e13f0e236a022806e75eb1d20afe2ac39779776a9ee0a1515a1505
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec0b7c50d1d580835ab9058d683ba8a305f475acbe991e1d82f2d971c4d14818e51fb6ee0bcc67b51e9114e6236cbcb8854d63ca1cfceabe9ac051838290d2e2
|
7
|
+
data.tar.gz: 53ab66068dcd5728e68f614dd9c2f7091798912d59828e8c27dcf7b456c7b8f017968b543d440d1f2a391d44850faa6521815bbe6f1cb076aa6b4640fce61b3f
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mono-merchant (1.0.0)
|
5
|
+
activesupport (~> 7)
|
6
|
+
base64 (~> 0.2)
|
7
|
+
json (~> 2.5)
|
8
|
+
money (~> 6.16)
|
9
|
+
rest-client (~> 2.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activesupport (7.1.3.2)
|
15
|
+
base64
|
16
|
+
bigdecimal
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
connection_pool (>= 2.2.5)
|
19
|
+
drb
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
minitest (>= 5.1)
|
22
|
+
mutex_m
|
23
|
+
tzinfo (~> 2.0)
|
24
|
+
base64 (0.2.0)
|
25
|
+
bigdecimal (3.1.6)
|
26
|
+
concurrent-ruby (1.2.3)
|
27
|
+
connection_pool (2.4.1)
|
28
|
+
domain_name (0.6.20240107)
|
29
|
+
drb (2.2.0)
|
30
|
+
ruby2_keywords
|
31
|
+
http-accept (1.7.0)
|
32
|
+
http-cookie (1.0.5)
|
33
|
+
domain_name (~> 0.5)
|
34
|
+
i18n (1.14.1)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
json (2.7.1)
|
37
|
+
mime-types (3.5.2)
|
38
|
+
mime-types-data (~> 3.2015)
|
39
|
+
mime-types-data (3.2024.0206)
|
40
|
+
minitest (5.22.2)
|
41
|
+
money (6.16.0)
|
42
|
+
i18n (>= 0.6.4, <= 2)
|
43
|
+
mutex_m (0.2.0)
|
44
|
+
netrc (0.11.0)
|
45
|
+
rake (13.1.0)
|
46
|
+
rest-client (2.1.0)
|
47
|
+
http-accept (>= 1.7.0, < 2.0)
|
48
|
+
http-cookie (>= 1.0.2, < 2.0)
|
49
|
+
mime-types (>= 1.16, < 4.0)
|
50
|
+
netrc (~> 0.8)
|
51
|
+
ruby2_keywords (0.0.5)
|
52
|
+
tzinfo (2.0.6)
|
53
|
+
concurrent-ruby (~> 1.0)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
mono-merchant!
|
60
|
+
rake
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 okliv
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# MonoMerchant
|
2
|
+
|
3
|
+
The "mono-merchant" gem simplifies [Monobank API](https://api.monobank.ua/docs/acquiring.html) usage in Ruby applications.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
bundle add "mono-merchant"
|
11
|
+
```
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem install "mono-merchant"
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add API token to the environment variable:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
# .env
|
25
|
+
MONOBANK_API_TOKEN=your_api_token
|
26
|
+
```
|
27
|
+
|
28
|
+
#### You can get the API token depending on the environment:
|
29
|
+
|
30
|
+
Development: [https://api.monobank.ua/](https://api.monobank.ua/)
|
31
|
+
|
32
|
+
Production: [https://fop.monobank.ua/](https://fop.monobank.ua/)
|
33
|
+
|
34
|
+
### Create invoice request
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
|
38
|
+
amount = 100 # in cents
|
39
|
+
MonoMerchant::Invoice::Create.new(amount) # see other params in code comments
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
### Verify webhook transaction
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
|
47
|
+
request_to_validate = MonoMerchant::WebhookValidator.new(request)
|
48
|
+
request_to_validate.valid?
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/okliv/mono-merchant.
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
class ApiRequest
|
5
|
+
|
6
|
+
API_URL = "https://api.monobank.ua/api"
|
7
|
+
DEFAULT_CURRENCY = "UAH"
|
8
|
+
|
9
|
+
attr_reader :errors, :type
|
10
|
+
|
11
|
+
def initialize(type: :post)
|
12
|
+
@type = type
|
13
|
+
@errors = []
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
def url
|
18
|
+
"#{API_URL}/#{self.class.name.underscore.dasherize.sub('mono-', '')}#{url_query}"
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
# Required headers for Monobank API
|
24
|
+
#
|
25
|
+
# @return [Hash] headers
|
26
|
+
def headers
|
27
|
+
warn 'ENV["MONOBANK_API_TOKEN"] is absent' unless ENV["MONOBANK_API_TOKEN"]
|
28
|
+
{
|
29
|
+
content_type: :json,
|
30
|
+
accept: :json,
|
31
|
+
"X-Token": ENV["MONOBANK_API_TOKEN"]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def url_query
|
36
|
+
"#{'?' if params.presence}#{URI.encode_www_form(params.to_hash)}" if type == :get
|
37
|
+
end
|
38
|
+
|
39
|
+
def params
|
40
|
+
{}
|
41
|
+
end
|
42
|
+
|
43
|
+
def body
|
44
|
+
{}
|
45
|
+
end
|
46
|
+
|
47
|
+
def convert_to_cents(amount)
|
48
|
+
if amount.is_a?(BigDecimal)
|
49
|
+
Money.from_amount(amount, currency).cents
|
50
|
+
else
|
51
|
+
amount
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# @return [Hash] response body or false in case of errors
|
58
|
+
def response
|
59
|
+
@response ||= begin
|
60
|
+
response = case type
|
61
|
+
when :post
|
62
|
+
RestClient.post(url, body.compact.to_json, headers)
|
63
|
+
when :get
|
64
|
+
RestClient.get(url, headers)
|
65
|
+
when :delete
|
66
|
+
RestClient.delete(url, headers)
|
67
|
+
end
|
68
|
+
body = JSON.parse(response.body)
|
69
|
+
Hash[data.map { |rp| [rp, body[rp]] }]
|
70
|
+
rescue StandardError => e
|
71
|
+
response_body = JSON.parse(e.response.body) rescue {}
|
72
|
+
@errors << [e.message, { response_body['errCode'] => response_body['errText'] }]
|
73
|
+
warn @errors
|
74
|
+
false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
def method_missing(name, *args)
|
78
|
+
cam_name = name.to_s.camelize(:lower)
|
79
|
+
return super unless data.include?(cam_name)
|
80
|
+
|
81
|
+
response[cam_name] if response
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MonoMerchant
|
2
|
+
module Invoice
|
3
|
+
|
4
|
+
# Cancel successful payment
|
5
|
+
class Cancel < ApiRequest
|
6
|
+
|
7
|
+
attr_reader :ext_ref, :invoice_id, :amount, :items
|
8
|
+
|
9
|
+
def initialize(invoice_id, amount, ext_ref: nil, items: [])
|
10
|
+
@invoice_id, @amount, @items, @ext_ref = invoice_id, amount, items, ext_ref
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def body
|
16
|
+
{ invoiceId: invoice_id,
|
17
|
+
amount: amount,
|
18
|
+
extRef: ext_ref,
|
19
|
+
items: items.presence
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
module Invoice
|
5
|
+
# Create invoice
|
6
|
+
class Create < ApiRequest
|
7
|
+
attr_reader :amount, :currency, :payment_type, :customer_emails, :items, :destination, :comment, :reference, :redirect_url, :webhook_url
|
8
|
+
|
9
|
+
# @param [BigDecimal,Integer] amount (cents) to request payment
|
10
|
+
# @param [String] destination - additional info about payment
|
11
|
+
# @param [String] reference - bill number or other reference
|
12
|
+
# @param [String] comment - internal service info
|
13
|
+
# @param [String] currency - currency iso code
|
14
|
+
# @param [Boolean] hold - if payment type is 'hold' (default: 'debit')
|
15
|
+
# @param [String] email - client email
|
16
|
+
# @param [Array] items - cart content
|
17
|
+
# @param [String] redirect_url - url where user will be redirected after payment
|
18
|
+
# @param [String] webhook_url - url where Monobank will send webhook after payment
|
19
|
+
def initialize(amount, destination: nil, reference: nil, currency: DEFAULT_CURRENCY, hold: false, email: nil, items: [], redirect_url: nil, webhook_url: nil, comment: nil)
|
20
|
+
@amount = convert_to_cents(amount)
|
21
|
+
@destination = destination
|
22
|
+
@reference = reference
|
23
|
+
@comment = comment
|
24
|
+
@currency = Money::Currency.new(currency)
|
25
|
+
@payment_type = hold ? 'hold' : 'debit'
|
26
|
+
@customer_emails = [email] if email
|
27
|
+
@items = items.map { |i| Item.new(i).to_hash.presence }
|
28
|
+
@redirect_url = redirect_url
|
29
|
+
@webhook_url = webhook_url
|
30
|
+
super()
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
delegate :iso_numeric, to: :currency, prefix: true
|
36
|
+
alias_method :ccy, :currency_iso_numeric
|
37
|
+
def body
|
38
|
+
{
|
39
|
+
ccy: ccy.to_i,
|
40
|
+
amount: amount,
|
41
|
+
paymentType: payment_type,
|
42
|
+
redirectUrl: redirect_url,
|
43
|
+
webHookUrl: webhook_url,
|
44
|
+
merchantPaymInfo: {
|
45
|
+
basketOrder: items.presence,
|
46
|
+
reference: reference,
|
47
|
+
comment: comment,
|
48
|
+
destination: destination,
|
49
|
+
customerEmails: customer_emails
|
50
|
+
}.compact
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def data
|
55
|
+
%w[pageUrl invoiceId]
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
module Invoice
|
5
|
+
|
6
|
+
# Finalize holding amount
|
7
|
+
class Finalize < ApiRequest
|
8
|
+
attr_reader :invoice_id, :amount, :items
|
9
|
+
|
10
|
+
def initialize(invoice_id, amount, items: [])
|
11
|
+
@invoice_id = invoice_id
|
12
|
+
@amount = amount
|
13
|
+
@items = items.map { |i| Item.new(i).to_hash }
|
14
|
+
super()
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def body
|
20
|
+
{ invoiceId: invoice_id,
|
21
|
+
amount: amount,
|
22
|
+
items: items.presence
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def data
|
27
|
+
%w[status]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
module Invoice
|
5
|
+
class Item
|
6
|
+
|
7
|
+
REQUIRED_ATTRS = %i[name qty sum code]
|
8
|
+
|
9
|
+
attr_reader *REQUIRED_ATTRS, :icon, :unit, :header, :footer
|
10
|
+
|
11
|
+
def initialize(i)
|
12
|
+
# TODO: check required?
|
13
|
+
@name = i[:name]
|
14
|
+
@qty = i[:qty]
|
15
|
+
@sum = i[:sum]
|
16
|
+
@code = i[:code]
|
17
|
+
# optional
|
18
|
+
@icon = i[:icon]
|
19
|
+
@unit = i[:unit]
|
20
|
+
@header = i[:header]
|
21
|
+
@footer = i[:footer]
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_hash
|
25
|
+
{ name: name,
|
26
|
+
qty: qty,
|
27
|
+
sum: sum,
|
28
|
+
code: code,
|
29
|
+
icon: icon,
|
30
|
+
unit: unit,
|
31
|
+
header: header,
|
32
|
+
footer: footer }.compact
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
module Invoice
|
5
|
+
|
6
|
+
class PaymentInfo < ApiRequest
|
7
|
+
|
8
|
+
attr_reader :invoice_id
|
9
|
+
|
10
|
+
def initialize(invoice_id)
|
11
|
+
@invoice_id = invoice_id
|
12
|
+
super(type: :get)
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def params
|
17
|
+
{ invoiceId: invoice_id }
|
18
|
+
end
|
19
|
+
|
20
|
+
def data
|
21
|
+
%w[maskedPan approvalCode rrn amount ccy finalAmount createdDate terminal paymentScheme paymentMethod fee domesticCard domesticCard cancelList]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MonoMerchant
|
2
|
+
module Invoice
|
3
|
+
|
4
|
+
# Invalidate invoice
|
5
|
+
class Remove < ApiRequest
|
6
|
+
|
7
|
+
attr_reader :invoice_id
|
8
|
+
|
9
|
+
def initialize(invoice_id)
|
10
|
+
@invoice_id = invoice_id
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def body
|
16
|
+
{ invoiceId: invoice_id }
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
module Invoice
|
5
|
+
|
6
|
+
class Status < PaymentInfo
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def data
|
11
|
+
%w[status failureReason errCode amount ccy finalAmount createdDate modifiedDate reference cancelList walletData]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MonoMerchant
|
4
|
+
class Pubkey < ApiRequest
|
5
|
+
|
6
|
+
def self.get
|
7
|
+
@@get ||= begin
|
8
|
+
key = new.key
|
9
|
+
Base.decode key if key
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.reset
|
14
|
+
@@get = nil
|
15
|
+
self.get
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
super(type: :get)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def data
|
25
|
+
%w[key]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module MonoMerchant
|
2
|
+
class WebhookValidator
|
3
|
+
|
4
|
+
def initialize(request)
|
5
|
+
@request = request
|
6
|
+
@webhook_data = @request.raw_post
|
7
|
+
end
|
8
|
+
|
9
|
+
def public_key
|
10
|
+
Pubkey.get
|
11
|
+
end
|
12
|
+
|
13
|
+
# Validate webhook data signature with public key
|
14
|
+
#
|
15
|
+
# @return [Boolean] valid?
|
16
|
+
def valid?
|
17
|
+
return false if @webhook_data.nil?
|
18
|
+
return false if signature.nil?
|
19
|
+
return false unless public_key
|
20
|
+
|
21
|
+
openssl_ec = OpenSSL::PKey::EC.new(public_key)
|
22
|
+
openssl_ec.check_key
|
23
|
+
|
24
|
+
return true if openssl_ec.verify(digest, signature, @webhook_data)
|
25
|
+
|
26
|
+
warn "Webhook isn't authorized. Might be wrong signature or inconsistent webhook data."
|
27
|
+
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# Get signature from request headers
|
34
|
+
#
|
35
|
+
# @return [String] signature
|
36
|
+
def signature
|
37
|
+
@signature ||= Base.decode(@request.headers["X-Sign"])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get digest from OpenSSL
|
41
|
+
#
|
42
|
+
# @return [OpenSSL::Digest] digest
|
43
|
+
def digest
|
44
|
+
@digest ||= OpenSSL::Digest.new("SHA256")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
require "base64"
|
6
|
+
require "bigdecimal"
|
7
|
+
require "json"
|
8
|
+
require "money"
|
9
|
+
require "rest-client"
|
10
|
+
|
11
|
+
module MonoMerchant
|
12
|
+
class Base
|
13
|
+
def self.decode(str)
|
14
|
+
Base64.decode64(str)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Dir.glob(File.join(__dir__, "mono-merchant", "/**/*.rb")).sort.each { |file| require file }
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# to load all /lib files
|
4
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
5
|
+
|
6
|
+
require_relative "lib/mono-merchant/version"
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "mono-merchant"
|
10
|
+
spec.version = MonoMerchant::VERSION
|
11
|
+
spec.authors = ['okliv']
|
12
|
+
spec.email = ["ok@entitative.com"]
|
13
|
+
|
14
|
+
spec.summary = "The \"mono-merchant\" gem is a powerful Ruby library designed for seamless integration with Monobank's acquiring system. It provides a convenient way to handle Monobank payments."
|
15
|
+
spec.description = "The \"mono-merchant\" gem simplifies Monobank payment integration in Ruby applications. It provides an simplified interface and essential functionalities for generating invoice requests, verifying transactions, handling webhooks to ensure data integrity. With this gem, you can quickly and securely implement Monobank payments."
|
16
|
+
spec.homepage = "https://github.com/okliv/mono-merchant"
|
17
|
+
spec.license = "MIT"
|
18
|
+
spec.required_ruby_version = ">= 2.7.0"
|
19
|
+
|
20
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
spec.metadata["source_code_uri"] = "https://github.com/okliv/mono-merchant"
|
22
|
+
spec.metadata["changelog_uri"] = "https://github.com/okliv/mono-merchant/blob/master/CHANGELOG.md"
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(__dir__) do
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
28
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
# Uncomment to register a new dependency of your gem
|
36
|
+
spec.add_dependency "rest-client", "~> 2.1"
|
37
|
+
spec.add_dependency "base64", "~> 0.2"
|
38
|
+
spec.add_dependency "json", "~> 2.5"
|
39
|
+
spec.add_dependency "money", "~> 6.16"
|
40
|
+
spec.add_dependency "activesupport", "~> 7"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mono-merchant
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- okliv
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: base64
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: money
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '6.16'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '7'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '7'
|
83
|
+
description: The "mono-merchant" gem simplifies Monobank payment integration in Ruby
|
84
|
+
applications. It provides an simplified interface and essential functionalities
|
85
|
+
for generating invoice requests, verifying transactions, handling webhooks to ensure
|
86
|
+
data integrity. With this gem, you can quickly and securely implement Monobank payments.
|
87
|
+
email:
|
88
|
+
- ok@entitative.com
|
89
|
+
executables: []
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".rspec"
|
94
|
+
- ".ruby-version"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- lib/mono-merchant.rb
|
101
|
+
- lib/mono-merchant/api_request.rb
|
102
|
+
- lib/mono-merchant/invoice/cancel.rb
|
103
|
+
- lib/mono-merchant/invoice/create.rb
|
104
|
+
- lib/mono-merchant/invoice/finalize.rb
|
105
|
+
- lib/mono-merchant/invoice/item.rb
|
106
|
+
- lib/mono-merchant/invoice/payment_info.rb
|
107
|
+
- lib/mono-merchant/invoice/remove.rb
|
108
|
+
- lib/mono-merchant/invoice/status.rb
|
109
|
+
- lib/mono-merchant/pubkey.rb
|
110
|
+
- lib/mono-merchant/version.rb
|
111
|
+
- lib/mono-merchant/webhook_validator.rb
|
112
|
+
- mono-merchant.gemspec
|
113
|
+
homepage: https://github.com/okliv/mono-merchant
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
homepage_uri: https://github.com/okliv/mono-merchant
|
118
|
+
source_code_uri: https://github.com/okliv/mono-merchant
|
119
|
+
changelog_uri: https://github.com/okliv/mono-merchant/blob/master/CHANGELOG.md
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 2.7.0
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubygems_version: 3.1.4
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: The "mono-merchant" gem is a powerful Ruby library designed for seamless
|
139
|
+
integration with Monobank's acquiring system. It provides a convenient way to handle
|
140
|
+
Monobank payments.
|
141
|
+
test_files: []
|