paykassa 0.1.14 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/paykassa/order.rb +41 -4
- data/lib/paykassa/pay.rb +16 -11
- data/lib/paykassa/version.rb +1 -1
- data/lib/paykassa.rb +24 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e3593a8efb9f87d15ae638745fa20b92222155605b70b51114fbaf77afe28d2
|
4
|
+
data.tar.gz: 3b0113e6185dbd9fa1e62109fd6e9e4c7adea32546cefcdbd61b9bf27ec001f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0012c0e1e99aea0ed3473c76f6fd2825456d124f22d9fed61cc3946110c4fb70e206f32bb47ffa687fbe7db94c41c7cd50edeed79c62f352bb351f71a1e364d
|
7
|
+
data.tar.gz: f48c8bfed4f650ac94a26bdf0a03304b03df16fcb18c1f81f8a4580ee93dddf45c3e34e63c2a7803f48eeae93a5e977382ce0f552ebee5f3a248b1f8073c9d53
|
data/Gemfile
CHANGED
data/lib/paykassa/order.rb
CHANGED
@@ -2,24 +2,61 @@ require 'net/http'
|
|
2
2
|
|
3
3
|
class PaykassaOrder
|
4
4
|
BASE_SCI_URI = URI('https://paykassa.pro/sci/0.3/index.php')
|
5
|
-
|
5
|
+
CURRENCIES=[
|
6
|
+
"USD", "RUB", "BTC", "ETH", "LTC", "DOGE", "DASH", "BCH", "ZEC",
|
7
|
+
"XRP", "TRX", "XLM", "BNB", "USDT", "ADA", "EOS", "GBP", "EUR",
|
8
|
+
"USDC", "BUSD"
|
9
|
+
]
|
10
|
+
SYSTEM_IDS = {
|
11
|
+
perfectmoney: 2,
|
12
|
+
berty: 7,
|
13
|
+
bitcoin: 11,
|
14
|
+
ethereum: 12,
|
15
|
+
litecoin: 14,
|
16
|
+
dogecoin: 15,
|
17
|
+
dash: 16,
|
18
|
+
bitcoincash: 18,
|
19
|
+
zcash: 19,
|
20
|
+
ripple: 22,
|
21
|
+
tron: 27,
|
22
|
+
stellar: 28,
|
23
|
+
binancecoin: 29,
|
24
|
+
tron_trc20: 30,
|
25
|
+
binancesmartchain_bep20: 31, # available currencies USDT, BUSD, USDC, ADA, EOS, BTC, ETH, DOGE
|
26
|
+
ethereum_erc20: 32
|
27
|
+
}
|
6
28
|
|
7
29
|
# def initialize(auth)
|
8
30
|
# where auth has keys: sci_id, sci_key, domain
|
9
|
-
def initialize(auth, logger = nil)
|
31
|
+
def initialize(auth, logger = nil, test = false)
|
10
32
|
@logger = logger
|
11
33
|
@_auth = auth
|
34
|
+
@test = test
|
12
35
|
end
|
13
36
|
|
14
37
|
# Request for create order
|
15
|
-
def create_order(amount
|
38
|
+
def create_order(amount: , currency:, order_id:, paid_commision: , comment:, system:)
|
16
39
|
make_request(
|
17
40
|
func: :sci_create_order,
|
18
41
|
amount: amount,
|
19
42
|
currency: currency,
|
20
43
|
order_id: order_id,
|
44
|
+
phone: "false",
|
45
|
+
paid_commission: paid_commision,
|
46
|
+
comment: comment,
|
47
|
+
system: SYSTEM_IDS[system]
|
48
|
+
)
|
49
|
+
end
|
50
|
+
def get_data(amount: , currency:, order_id:, paid_commision: , comment:, system:)
|
51
|
+
make_request(
|
52
|
+
func: :sci_create_order_get_data,
|
53
|
+
amount: amount,
|
54
|
+
currency: currency,
|
55
|
+
order_id: order_id,
|
56
|
+
phone: "false",
|
57
|
+
paid_commission: paid_commision,
|
21
58
|
comment: comment,
|
22
|
-
system: system
|
59
|
+
system: SYSTEM_IDS[system]
|
23
60
|
)
|
24
61
|
end
|
25
62
|
|
data/lib/paykassa/pay.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
|
2
|
+
require 'logger'
|
3
3
|
class PaykassaPay
|
4
4
|
BASE_URL = URI("https://paykassa.app/api/0.5/index.php")
|
5
5
|
RATE_URL = URI("https://currency.paykassa.pro/index.php")
|
@@ -28,6 +28,7 @@ class PaykassaPay
|
|
28
28
|
ethereum_erc20: 32
|
29
29
|
}
|
30
30
|
def initialize(domain:, api_id:, api_key:, test: false, logger: nil)
|
31
|
+
@logger = logger
|
31
32
|
@logger.info("Initialize class Pay with params: domain: #{domain}, api_id: #{api_id}, api_key: #{api_key}, test: #{test}") if !@logger.nil?
|
32
33
|
@token = api_key
|
33
34
|
@_auth = {domain: domain, api_id: api_id, api_key: api_key, test: test}
|
@@ -43,7 +44,7 @@ class PaykassaPay
|
|
43
44
|
tag: tag,
|
44
45
|
priority: priority
|
45
46
|
}
|
46
|
-
@logger.info("Pay.pay with data: #{data.inspect}")
|
47
|
+
@logger.info("Pay.pay with data: #{data.inspect}") unless @logger.nil?
|
47
48
|
make_request("api_payment",data)
|
48
49
|
end
|
49
50
|
def balance(shop: )
|
@@ -52,8 +53,12 @@ class PaykassaPay
|
|
52
53
|
api_id: @_auth[:api_id],
|
53
54
|
api_key: @_auth[:api_key]
|
54
55
|
}
|
55
|
-
@logger.info("Pay.balance with data: #{data.inspect}")
|
56
|
-
make_request(
|
56
|
+
@logger.info("Pay.balance with data: #{data.inspect}") unless @logger.nil?
|
57
|
+
make_request(
|
58
|
+
func: "api_get_shop_balance",
|
59
|
+
data: data,
|
60
|
+
merge_auth: false
|
61
|
+
)
|
57
62
|
end
|
58
63
|
def currency_rate(inn:,out:)
|
59
64
|
if !CURRENCIES.include? inn
|
@@ -68,20 +73,20 @@ class PaykassaPay
|
|
68
73
|
}
|
69
74
|
@logger.info("Pay.currency_rate with data: #{data.inspect}") if !@logger.nil?
|
70
75
|
make_request(
|
71
|
-
nil,
|
72
|
-
data,
|
73
|
-
false,
|
74
|
-
RATE_URL
|
76
|
+
func: nil,
|
77
|
+
data: data,
|
78
|
+
merge_auth: false,
|
79
|
+
url: RATE_URL
|
75
80
|
)
|
76
81
|
end
|
77
82
|
private
|
78
|
-
def make_request(func
|
83
|
+
def make_request(func:,data: ,merge_auth: , url: nil)
|
79
84
|
data = data.merge({func: func}) if !func.nil?
|
80
85
|
data = data.merge(@_auth) if merge_auth
|
81
86
|
url = BASE_URL if url.nil?
|
82
|
-
@logger.info("private Pay.make_request with params: url: #{url.inspect}, data: #{data.inspect}")
|
87
|
+
@logger.info("private Pay.make_request with params: url: #{url.inspect}, data: #{data.inspect}") unless @logger.nil?
|
83
88
|
res = Net::HTTP.post_form(url, data)
|
84
|
-
@logger.info("private Pay.make_request: result: #{res.inspect}")
|
89
|
+
@logger.info("private Pay.make_request: result: #{res.inspect}") unless @logger.nil?
|
85
90
|
JSON.parse(res.body).deep_symbolize_keys
|
86
91
|
end
|
87
92
|
|
data/lib/paykassa/version.rb
CHANGED
data/lib/paykassa.rb
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
require_relative "paykassa/version"
|
4
4
|
require_relative "paykassa/order"
|
5
5
|
require_relative "paykassa/pay"
|
6
|
+
require 'logger'
|
6
7
|
module Paykassa
|
7
8
|
class Error < StandardError; end
|
8
9
|
class Paykassa
|
9
10
|
def initialize(domain:, sci_id:, sci_key:, api_id: nil, api_key: nil, test:, logger: nil)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@paykassa_order = PaykassaOrder.new({domain: domain, sci_id: sci_id, sci_key: sci_key}, logger)
|
11
|
+
@logger = Logger.new(logger) unless logger.nil?
|
12
|
+
|
13
|
+
@paykassa_order = PaykassaOrder.new({domain: domain, sci_id: sci_id, sci_key: sci_key}, @logger, test)
|
14
14
|
if api_id.nil?
|
15
15
|
@paykassa_pay = nil
|
16
16
|
else
|
17
17
|
@paykassa_pay = PaykassaPay.new(
|
18
18
|
domain: domain, api_id: api_id,
|
19
|
-
api_key: api_key, test: test, logger: logger
|
19
|
+
api_key: api_key, test: test, logger: @logger
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
@@ -42,13 +42,26 @@ module Paykassa
|
|
42
42
|
def rate(c_in, c_out)
|
43
43
|
@paykassa_pay.currency_rate(c_in, c_out)
|
44
44
|
end
|
45
|
-
|
46
|
-
|
45
|
+
def get_order_address(amount: , currency:, order_id:, paid_commision: , comment: "from paykassa gem", system:)
|
46
|
+
order = @paykassa_order.get_data( amount: amount,
|
47
|
+
currency: currency,
|
48
|
+
order_id: order_id,
|
49
|
+
phone: "false",
|
50
|
+
paid_commission: paid_commision,
|
51
|
+
comment: comment,
|
52
|
+
system: system
|
53
|
+
)
|
54
|
+
raise StandardError.new(order[:message]) if order[:error]
|
55
|
+
order
|
56
|
+
end
|
57
|
+
def create_order(amount: , currency:, order_id:, paid_commision: , comment: "from paykassa gem", system:)
|
47
58
|
order = @paykassa_order.create_order(
|
48
|
-
amount: amount,
|
49
|
-
currency: currency,
|
50
|
-
order_id: order_id,
|
51
|
-
|
59
|
+
amount: amount,
|
60
|
+
currency: currency,
|
61
|
+
order_id: order_id,
|
62
|
+
phone: "false",
|
63
|
+
paid_commission: paid_commision,
|
64
|
+
comment: comment,
|
52
65
|
system: system
|
53
66
|
)
|
54
67
|
raise StandardError.new(order[:message]) if order[:error]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paykassa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nottewae
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|