paykassa 0.1.9 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 549ba54de35ce291dd1e3dd71f6351ba300957474ca0886ecf6032fa41aaa991
4
- data.tar.gz: 686d351cd9644adf2a9ec042404a5466319534ba263c2013692032973b94f33f
3
+ metadata.gz: 66e7ca1344f94243c132cb9b2c33e795d0df597f4230f1d2d1d7f19c1900fe0d
4
+ data.tar.gz: 1d859254cb366502c46c58b98941b413d0eaf421faccffa3d0685ee06a1d3567
5
5
  SHA512:
6
- metadata.gz: 68d1a068554da02bb2b70ef7ce5a73d885f5f57131094b06b104b61dd165d2c21175fc5317ea28fa846223adf437f1b3f9169281be54b556f302fe3766b98a9d
7
- data.tar.gz: 8bd5aae30b84c14a7b748338f58e31a38e3155b04b029bbbd00c6d675731a52cc8372b7fddb6a307ab13d857ed952d94c63b307c76cb482038a0709a5c2dd086
6
+ metadata.gz: 95b4388874b808ace088fe7f9f1639fd251fb3f02c445d4c1c935e0da6680aa50f8019b19ed48f1ed06cb484b92c53074d52351db5065be1405e29c9494f74d1
7
+ data.tar.gz: 95cfeacd0ddc674b4ef9761c6bdf354732a18f0c2acd806f3c476fed8200882327e1e1838b7037ef307b127f722df9fada8818f3ee7756db443a69ae99de6f04
@@ -6,7 +6,8 @@ class PaykassaOrder
6
6
 
7
7
  # def initialize(auth)
8
8
  # where auth has keys: sci_id, sci_key, domain
9
- def initialize(auth)
9
+ def initialize(auth, logger = nil)
10
+ @logger = logger
10
11
  @_auth = auth
11
12
  end
12
13
 
data/lib/paykassa/pay.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'net/http'
2
2
 
3
3
  class PaykassaPay
4
- BASE_URL = "https://paykassa.app/api/0.5/index.php"
5
- RATE_URL = "https://currency.paykassa.pro/index.php"
6
- BASE_SCI_URI = 'https://paykassa.pro/sci/0.3/index.php'
4
+ BASE_URL = URI("https://paykassa.app/api/0.5/index.php")
5
+ RATE_URL = URI("https://currency.paykassa.pro/index.php")
6
+ BASE_SCI_URI = URI('https://paykassa.pro/sci/0.3/index.php')
7
7
  CURRENCIES=[
8
8
  "USD", "RUB", "BTC", "ETH", "LTC", "DOGE", "DASH", "BCH", "ZEC",
9
9
  "XRP", "TRX", "XLM", "BNB", "USDT", "ADA", "EOS", "GBP", "EUR",
@@ -27,7 +27,8 @@ class PaykassaPay
27
27
  binancesmartchain_bep20: 31, # available currencies USDT, BUSD, USDC, ADA, EOS, BTC, ETH, DOGE
28
28
  ethereum_erc20: 32
29
29
  }
30
- def initialize(domain:, api_id:, api_key:, test: false)
30
+ def initialize(domain:, api_id:, api_key:, test: false, logger: nil)
31
+ @logger.info("Initialize class Pay with params: domain: #{domain}, api_id: #{api_id}, api_key: #{api_key}, test: #{test}") if !@logger.nil?
31
32
  @token = api_key
32
33
  @_auth = {domain: domain, api_id: api_id, api_key: api_key, test: test}
33
34
  end
@@ -42,6 +43,7 @@ class PaykassaPay
42
43
  tag: tag,
43
44
  priority: priority
44
45
  }
46
+ @logger.info("Pay.pay with data: #{data.inspect}") if !@logger.nil?
45
47
  make_request("api_payment",data)
46
48
  end
47
49
  def balance(shop: )
@@ -50,6 +52,7 @@ class PaykassaPay
50
52
  pi_id: @_auth[:api_id],
51
53
  api_key: @_auth[:api_key]
52
54
  }
55
+ @logger.info("Pay.balance with data: #{data.inspect}") if !@logger.nil?
53
56
  make_request("api_get_shop_balance", data, false)
54
57
  end
55
58
  def currency_rate(inn:,out:)
@@ -63,6 +66,7 @@ class PaykassaPay
63
66
  currency_in: inn,
64
67
  currency_out: out
65
68
  }
69
+ @logger.info("Pay.currency_rate with data: #{data.inspect}") if !@logger.nil?
66
70
  make_request(
67
71
  nil,
68
72
  data,
@@ -72,10 +76,12 @@ class PaykassaPay
72
76
  end
73
77
  private
74
78
  def make_request(func,data,merge_auth = true, url= nil)
75
- data = data.merge({func: func}) if func
79
+ data = data.merge({func: func}) if !func.nil?
76
80
  data = data.merge(@_auth) if merge_auth
77
- url = BASE_SCI_URI if url.nil?
81
+ url = BASE_URL if url.nil?
82
+ @logger.info("private Pay.make_request with params: url: #{url.inspect}, data: #{data.inspect}") if !@logger.nil?
78
83
  res = Net::HTTP.post_form(url, data)
84
+ @logger.info("private Pay.make_request: result: #{res.inspect}") if !@logger.nil?
79
85
  JSON.parse(res.body).deep_symbolize_keys
80
86
  end
81
87
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paykassa
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.12"
5
5
  end
data/lib/paykassa.rb CHANGED
@@ -6,14 +6,15 @@ require_relative "paykassa/pay"
6
6
  module Paykassa
7
7
  class Error < StandardError; end
8
8
  class Paykassa
9
- def initialize(domain:, sci_id:, sci_key:, api_id: nil, api_key: nil, test:)
10
- @paykassa_order = PaykassaOrder.new({domain: domain, sci_id: sci_id, sci_key: sci_key})
9
+ def initialize(domain:, sci_id:, sci_key:, api_id: nil, api_key: nil, test:, logger: nil)
10
+ @logger=logger
11
+ @paykassa_order = PaykassaOrder.new({domain: domain, sci_id: sci_id, sci_key: sci_key}, logger)
11
12
  if api_id.nil?
12
13
  @paykassa_pay = nil
13
14
  else
14
15
  @paykassa_pay = PaykassaPay.new(
15
16
  domain: domain, api_id: api_id,
16
- api_key: api_key, test: test
17
+ api_key: api_key, test: test, logger: logger
17
18
  )
18
19
  end
19
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paykassa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - nottewae