multicard 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/CHANGELOG.md +22 -0
- data/LICENSE +21 -0
- data/README.md +405 -0
- data/lib/multicard/client.rb +60 -0
- data/lib/multicard/configuration.rb +41 -0
- data/lib/multicard/errors.rb +41 -0
- data/lib/multicard/http_client.rb +146 -0
- data/lib/multicard/resources/base.rb +36 -0
- data/lib/multicard/resources/cards.rb +80 -0
- data/lib/multicard/resources/holds.rb +60 -0
- data/lib/multicard/resources/invoices.rb +53 -0
- data/lib/multicard/resources/payments.rb +133 -0
- data/lib/multicard/resources/payouts.rb +37 -0
- data/lib/multicard/resources/registry.rb +37 -0
- data/lib/multicard/response.rb +33 -0
- data/lib/multicard/signature.rb +53 -0
- data/lib/multicard/token_manager.rb +50 -0
- data/lib/multicard/version.rb +5 -0
- data/lib/multicard.rb +42 -0
- metadata +124 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Multicard
|
|
4
|
+
class TokenManager
|
|
5
|
+
TOKEN_TTL = 23 * 3600 # Refresh 1 hour before 24h expiry
|
|
6
|
+
|
|
7
|
+
def initialize(http_client, config)
|
|
8
|
+
@http_client = http_client
|
|
9
|
+
@config = config
|
|
10
|
+
@token = nil
|
|
11
|
+
@expires_at = nil
|
|
12
|
+
@mutex = Mutex.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def token
|
|
16
|
+
@mutex.synchronize do
|
|
17
|
+
refresh! if expired?
|
|
18
|
+
@token
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def reset!
|
|
23
|
+
@mutex.synchronize do
|
|
24
|
+
@token = nil
|
|
25
|
+
@expires_at = nil
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def refresh!
|
|
32
|
+
response = @http_client.post(
|
|
33
|
+
'/auth',
|
|
34
|
+
body: {
|
|
35
|
+
application_id: @config.application_id,
|
|
36
|
+
secret: @config.secret
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
# Auth endpoint returns {"token": "..."} directly, not wrapped in {"success": true, "data": {...}}
|
|
40
|
+
@token = response.body[:token]
|
|
41
|
+
raise AuthenticationError, 'Auth response missing token' unless @token
|
|
42
|
+
|
|
43
|
+
@expires_at = Time.now + TOKEN_TTL
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def expired?
|
|
47
|
+
@token.nil? || @expires_at.nil? || Time.now >= @expires_at
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/multicard.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'multicard/version'
|
|
4
|
+
require_relative 'multicard/configuration'
|
|
5
|
+
require_relative 'multicard/errors'
|
|
6
|
+
require_relative 'multicard/response'
|
|
7
|
+
require_relative 'multicard/http_client'
|
|
8
|
+
require_relative 'multicard/token_manager'
|
|
9
|
+
require_relative 'multicard/signature'
|
|
10
|
+
require_relative 'multicard/client'
|
|
11
|
+
require_relative 'multicard/resources/base'
|
|
12
|
+
require_relative 'multicard/resources/invoices'
|
|
13
|
+
require_relative 'multicard/resources/payments'
|
|
14
|
+
require_relative 'multicard/resources/cards'
|
|
15
|
+
require_relative 'multicard/resources/holds'
|
|
16
|
+
require_relative 'multicard/resources/payouts'
|
|
17
|
+
require_relative 'multicard/resources/registry'
|
|
18
|
+
|
|
19
|
+
module Multicard
|
|
20
|
+
class << self
|
|
21
|
+
attr_reader :configuration
|
|
22
|
+
|
|
23
|
+
# Configure the gem globally (optional — you can also pass config per-client).
|
|
24
|
+
#
|
|
25
|
+
# Multicard.configure do |config|
|
|
26
|
+
# config.application_id = ENV["MULTICARD_APPLICATION_ID"]
|
|
27
|
+
# config.secret = ENV["MULTICARD_SECRET"]
|
|
28
|
+
# config.store_id = 123
|
|
29
|
+
# end
|
|
30
|
+
#
|
|
31
|
+
def configure
|
|
32
|
+
@configuration = Configuration.new
|
|
33
|
+
yield(@configuration) if block_given?
|
|
34
|
+
@configuration
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Reset global configuration (useful in tests).
|
|
38
|
+
def reset_configuration!
|
|
39
|
+
@configuration = nil
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: multicard
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Honey Murena
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-02-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '13.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '13.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rubocop
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: webmock
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
description: Ruby SDK for Multicard.uz — payment gateway supporting Uzcard, Humo,
|
|
70
|
+
and 9 wallet apps (Payme, Click, Uzum, etc.). Invoices, card payments, splits, holds,
|
|
71
|
+
payouts, card binding, and webhook verification.
|
|
72
|
+
email:
|
|
73
|
+
- dev@honeymurena.com
|
|
74
|
+
executables: []
|
|
75
|
+
extensions: []
|
|
76
|
+
extra_rdoc_files: []
|
|
77
|
+
files:
|
|
78
|
+
- CHANGELOG.md
|
|
79
|
+
- LICENSE
|
|
80
|
+
- README.md
|
|
81
|
+
- lib/multicard.rb
|
|
82
|
+
- lib/multicard/client.rb
|
|
83
|
+
- lib/multicard/configuration.rb
|
|
84
|
+
- lib/multicard/errors.rb
|
|
85
|
+
- lib/multicard/http_client.rb
|
|
86
|
+
- lib/multicard/resources/base.rb
|
|
87
|
+
- lib/multicard/resources/cards.rb
|
|
88
|
+
- lib/multicard/resources/holds.rb
|
|
89
|
+
- lib/multicard/resources/invoices.rb
|
|
90
|
+
- lib/multicard/resources/payments.rb
|
|
91
|
+
- lib/multicard/resources/payouts.rb
|
|
92
|
+
- lib/multicard/resources/registry.rb
|
|
93
|
+
- lib/multicard/response.rb
|
|
94
|
+
- lib/multicard/signature.rb
|
|
95
|
+
- lib/multicard/token_manager.rb
|
|
96
|
+
- lib/multicard/version.rb
|
|
97
|
+
homepage: https://github.com/pashgo/multicard-ruby
|
|
98
|
+
licenses:
|
|
99
|
+
- MIT
|
|
100
|
+
metadata:
|
|
101
|
+
homepage_uri: https://github.com/pashgo/multicard-ruby
|
|
102
|
+
source_code_uri: https://github.com/pashgo/multicard-ruby
|
|
103
|
+
changelog_uri: https://github.com/pashgo/multicard-ruby/blob/main/CHANGELOG.md
|
|
104
|
+
rubygems_mfa_required: 'true'
|
|
105
|
+
post_install_message:
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '3.0'
|
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
requirements: []
|
|
120
|
+
rubygems_version: 3.5.11
|
|
121
|
+
signing_key:
|
|
122
|
+
specification_version: 4
|
|
123
|
+
summary: Ruby client for the Multicard payment gateway (Uzbekistan)
|
|
124
|
+
test_files: []
|