ruby-gpwebpay 0.0.1 → 0.1.1

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: 0536ecb57b136380a6c1662e93b0cec5439bd59c655fa524a82ac14c0ac33117
4
- data.tar.gz: 325be4295cd941abffa4d5e7569572fe8f93de3799f2a529bb2f5f85228b2540
3
+ metadata.gz: dbb8572d1c96414b1da43ea890111fbf7a776a0fd2845b96d07730f32365b79f
4
+ data.tar.gz: bd03b5e106f58cc6557da15a3eae58505e88e47e333d4daa0197e8f475ed0b71
5
5
  SHA512:
6
- metadata.gz: dcb7675ac86150be1b9c25c631b15d7176ceae25cb07da9dedf06a55fd2684478b728ee5c010179f28df5cdce13fac763373d30d9cca99fed821970b34fe7527
7
- data.tar.gz: 8d50edcae500961cd41a30ce7698cdc1b2772391a928841a379803c32f12148a3729eb281af3cbcbe04ded9b0616c17d49d87866e8fba3dbc30d4cc6768239ed
6
+ metadata.gz: ec567e4861b931da3fc1b494ec5d22425491ab9921c5f02e9d432efda23f52286e411f43323c8b0b87751a5e6d2ae161e5d615ef034637fc7b0136cf1e7925e9
7
+ data.tar.gz: 1999b3932d7badfeb139152edefb334a2f50925598e2b1767edd3dbc30d4b58123473422a53897a9955ea030b44277a842024d532072f82348943db657aadff2
data/lib/gp_webpay.rb CHANGED
@@ -6,4 +6,13 @@ require "gp_webpay/verification"
6
6
  require "gp_webpay/web_services"
7
7
 
8
8
  module GpWebpay
9
+ class << self
10
+ attr_writer :logger
11
+
12
+ def logger
13
+ @logger ||= Logger.new($stdout).tap do |log|
14
+ log.progname = self.name
15
+ end
16
+ end
17
+ end
9
18
  end
@@ -27,9 +27,12 @@ module GpWebpay
27
27
  end
28
28
 
29
29
  def pay_url(options = {})
30
- self.redirect_url = options[:redirect_url]
30
+ self.redirect_url ||= options[:redirect_url]
31
31
 
32
- "#{config.pay_url}?#{pay_verification.payment_attributes_with_digest.to_param}"
32
+ GpWebpay.logger.info "Attributes user for URL generation: #{pay_verification.payment_attributes_with_digest}"
33
+ generated_url = "#{config.pay_url}?#{pay_verification.payment_attributes_with_digest.to_param}"
34
+ GpWebpay.logger.info "Produced URL: #{generated_url}"
35
+ generated_url
33
36
  end
34
37
 
35
38
  def success?(params)
@@ -40,7 +43,7 @@ module GpWebpay
40
43
  private
41
44
 
42
45
  def pay_verification_attrs
43
- %i(operation order_number prcode srcode resulttext)
46
+ %i(OPERATION ORDERNUMBER PRCODE SRCODE RESULTTEXT)
44
47
  end
45
48
 
46
49
  def pay_attributes
@@ -16,6 +16,22 @@ module GpWebpay
16
16
 
17
17
  MASTER_KEYS = %i(user_param)
18
18
 
19
+ TRANSITIONS = {
20
+ :merchant_number => 'MERCHANTNUMBER',
21
+ :order_number => 'ORDERNUMBER',
22
+ :master_order_number => 'MASTERORDERNUMBER',
23
+ :amount_in_cents => 'AMOUNT',
24
+ :deposit_flag => 'DEPOSITFLAG',
25
+ :merchant_order_number => 'MERORDERNUM',
26
+ :redirect_url => 'URL',
27
+ :merchant_description => 'MD',
28
+ :message_id => 'MESSAGEID',
29
+ :bank_id => 'BANKID',
30
+ :currency => 'CURRENCY',
31
+ :operation => 'OPERATION',
32
+ :user_param => 'USERPARAM1',
33
+ }
34
+
19
35
  def initialize(payment, ws_flag = false, type = "")
20
36
  @payment = payment
21
37
  @ws_flag = ws_flag
@@ -54,5 +70,11 @@ module GpWebpay
54
70
  hash
55
71
  end
56
72
  end
73
+
74
+ def self.map_to_keys(hash)
75
+ hash.each_with_object({}) do |(method, value), transformed|
76
+ transformed[TRANSITIONS[method]] = value
77
+ end
78
+ end
57
79
  end
58
80
  end
@@ -4,7 +4,9 @@ module GpWebpay
4
4
  class Verification
5
5
  def initialize(payment_attributes, verification_attrs = nil)
6
6
  @payment_attributes = payment_attributes
7
+ GpWebpay.logger.info "Payment Attrs: #{@payment_attributes}"
7
8
  @verification_attrs = verification_attrs
9
+ GpWebpay.logger.info "Verification Attrs: #{@verification_attrs}"
8
10
  end
9
11
 
10
12
  def verified_response?(params)
@@ -13,7 +15,7 @@ module GpWebpay
13
15
  end
14
16
 
15
17
  def payment_attributes_with_digest
16
- @payment_attributes.merge("DIGEST" => digest)
18
+ PaymentAttributes.map_to_keys(@payment_attributes).merge("DIGEST" => digest)
17
19
  end
18
20
 
19
21
  def digest
@@ -1,3 +1,3 @@
1
1
  module GpWebpay
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gpwebpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrej Antas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport