paykassa 0.1.13 → 0.1.16

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: 97ac6966e736f2779ec3b847fc2bf88ee3b3192d1601512ecc94118078942d54
4
- data.tar.gz: bdf6715b98585c00d3a6705e1043dcebdbf7a3995d6a4c11230f994bd5677b7c
3
+ metadata.gz: 8f08dc918608da07c348a716eb133e57187372b3158adc369bbbb0cb41a6cf53
4
+ data.tar.gz: 68bc52b31422fb2786d8ee7e0f998ecac762e2b4143114e92cdb876e6986075d
5
5
  SHA512:
6
- metadata.gz: 1e74e4b7e184840bc564c28937f1f858d18a8a373e641b23dd0e700fc908242d8da7d0adb45bd774801730e4f6b92dcf07d7211508ae8108708f8f4d4918c208
7
- data.tar.gz: 2d300c7b4fc22958285a2625deeff6d9e4f263faf19765d4a263f3e317c8a6f734d96751a8fa1c3395b446f1ecc99b57a16971cf3245b1aebcb406bc0e63866b
6
+ metadata.gz: 1c4d4c81018e7276636b68f2c1b73950ba31725c9704ebd35b8e357543c2b65fe50a0f37b15a2842dfd685e6a19e8ce6e9db559b42ad9f136828f2cf20a5b10e
7
+ data.tar.gz: bf549917ae04e06a5c85be261b1d3003ceae524e20c29e6afc6587898bca17b4cf008b6e262734ceedcfd230c336ca11b50fc8632e3fcb7856bb2610cbd9bb93
data/Gemfile CHANGED
@@ -8,3 +8,4 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
+ gem 'logger', "~> 1.4.3"
@@ -6,20 +6,37 @@ class PaykassaOrder
6
6
 
7
7
  # def initialize(auth)
8
8
  # where auth has keys: sci_id, sci_key, domain
9
- def initialize(auth, logger = nil)
9
+ def initialize(auth, logger = nil, test = false)
10
10
  @logger = logger
11
11
  @_auth = auth
12
+ @test = test
12
13
  end
13
14
 
14
15
  # Request for create order
15
- def create_order(amount:, currency:, order_id:, comment:, system:)
16
+ def create_order(amount: , currency:, order_id:, paid_commision: , comment:, system:)
16
17
  make_request(
17
18
  func: :sci_create_order,
18
19
  amount: amount,
19
20
  currency: currency,
20
21
  order_id: order_id,
22
+ phone: "false",
23
+ paid_commission: paid_commision,
21
24
  comment: comment,
22
- system: system
25
+ system: system,
26
+ test: @test.to_s
27
+ )
28
+ end
29
+ def get_data(amount: , currency:, order_id:, paid_commision: , comment:, system:)
30
+ make_request(
31
+ func: :sci_create_order_get_data,
32
+ amount: amount,
33
+ currency: currency,
34
+ order_id: order_id,
35
+ phone: "false",
36
+ paid_commission: paid_commision,
37
+ comment: comment,
38
+ system: system,
39
+ test: @test.to_s
23
40
  )
24
41
  end
25
42
 
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,17 +44,21 @@ class PaykassaPay
43
44
  tag: tag,
44
45
  priority: priority
45
46
  }
46
- @logger.info("Pay.pay with data: #{data.inspect}") if !@logger.nil?
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: )
50
51
  data = {
51
52
  shop: shop,
52
- pi_id: @_auth[:api_id],
53
+ api_id: @_auth[:api_id],
53
54
  api_key: @_auth[:api_key]
54
55
  }
55
- @logger.info("Pay.balance with data: #{data.inspect}") if !@logger.nil?
56
- make_request("api_get_shop_balance", data, false)
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,data,merge_auth = true, url= nil)
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}") if !@logger.nil?
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}") if !@logger.nil?
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paykassa
4
- VERSION = "0.1.13"
4
+ VERSION = "0.1.16"
5
5
  end
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
- @logger=logger
12
- puts "logger paykassa: #{@logger.inspect}"
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,24 @@ 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
- def create_order(amount:, currency:, order_id:, system:, comment: "from paykassa gem")
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
+ end
55
+ def create_order(amount: , currency:, order_id:, paid_commision: , comment: "from paykassa gem", system:)
47
56
  order = @paykassa_order.create_order(
48
- amount: amount,
49
- currency: currency,
50
- order_id: order_id,
51
- comment: comment,
57
+ amount: amount,
58
+ currency: currency,
59
+ order_id: order_id,
60
+ phone: "false",
61
+ paid_commission: paid_commision,
62
+ comment: comment,
52
63
  system: system
53
64
  )
54
65
  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.13
4
+ version: 0.1.16
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-06 00:00:00.000000000 Z
11
+ date: 2022-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redcarpet