rails-gp-webpay 0.2.5 → 0.2.6

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: 9c597464425c2927b468ae8c969fd4d2046060668df8f4c9793f7e74ab18712d
4
- data.tar.gz: 7e67ac949546fb2ddc85a4ae551ac8d06b5e62e71811d0ded3ccfe197bc85a4f
3
+ metadata.gz: 557be3e38c554946e0fe2839549b752342205f2bfaa911a4861a3f1ea268c1a3
4
+ data.tar.gz: e48dd123da0ac8e2180d43917e3b3c2e63e8afe56cb17b08127824f65faf4f24
5
5
  SHA512:
6
- metadata.gz: 36c914a4554ec7de7bce64c8da8e5eced4c4da6009f63b481aa4cf9cf562878f84e81dec3f6178d8a0dc2b1295172128a630b145b5826a6019e0db066a9d1fb4
7
- data.tar.gz: '008e96b29024a860c39bd4d168492525d5e8abc481e97978a17b1705e5557853e21ef566498740567fd95fbdc8a7e3514758f4e242d62e895bd5eda8ce150b2d'
6
+ metadata.gz: ae3c2c5e04ae5cb2230e28a87d732f8769679b48f2ee0f1eb0f0c2b00e553a69cdaecad3201e0cf6368a0e359ca8f99b970939204160c4b98d1d6869af79ed7e
7
+ data.tar.gz: ce49aa4b92af16bfb9aff3cec47c2baf190c5361045bbf7acb134a61a2f93626c005725bc80cf854bb592ce3e109b35900234c6841bb365f7b2dc46faf8256fc
data/changelog.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.6
4
+ Add merchant number to tests, add default attributes to requests
5
+
3
6
  ## 0.2.4
4
7
  Increase savon timeout to 5 minutes
5
8
 
@@ -21,8 +21,7 @@ module GpWebpay
21
21
  end
22
22
 
23
23
  def find_configuration_by_merchant_number(merchant_number)
24
-
25
- config = @configurations.find { |_key, value| puts _key;value.merchant_number.to_s == merchant_number.to_s }
24
+ config = @configurations.find { |_key, value| value.merchant_number.to_s == merchant_number.to_s }
26
25
  return nil if config.blank?
27
26
 
28
27
  config[-1]
@@ -1,5 +1,5 @@
1
1
  require 'savon/mock/spec_helper'
2
-
2
+ # rubocop:disable Metrics/ParameterLists
3
3
  module GpWebpay
4
4
  module SpecHelper
5
5
  class Interface
@@ -45,15 +45,13 @@ module GpWebpay
45
45
  allow(GpWebpay::Ws::Services::ProcessUsageBasedPayment)
46
46
  .to receive(:call).with(
47
47
  hash_including(
48
- {
49
- message_id: anything,
48
+ { message_id: anything,
50
49
  payment_number: anything,
51
50
  order_number: anything,
52
51
  currency_code: anything,
53
- capture_flag: '1'
54
- }.merge(attributes)
52
+ capture_flag: '1' }.merge(attributes)
55
53
  ),
56
- merchant_number: merchant_number,
54
+ merchant_number: merchant_number
57
55
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
58
56
  valid?: valid, success?: success, status: status, result_text: result_text,
59
57
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
@@ -69,28 +67,28 @@ module GpWebpay
69
67
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
70
68
  end
71
69
 
72
- def stub_refund_payment(attributes, valid: true, success: true, status: '', result_text: 'OK')
70
+ def stub_refund_payment(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK')
73
71
  allow(GpWebpay::Ws::Services::ProcessRefundPayment)
74
72
  .to receive(:call).with(
75
- hash_including({ message_id: anything }.merge(attributes))
73
+ hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
76
74
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
77
75
  valid?: valid, success?: success, status: status, result_text: result_text,
78
76
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
79
77
  end
80
78
 
81
- def stub_capture_reverse(attributes, valid: true, success: true, status: '', result_text: 'OK')
79
+ def stub_capture_reverse(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK')
82
80
  allow(GpWebpay::Ws::Services::ProcessCaptureReverse)
83
81
  .to receive(:call).with(
84
- hash_including({ message_id: anything }.merge(attributes))
82
+ hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
85
83
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
86
84
  valid?: valid, success?: success, status: status, result_text: result_text,
87
85
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
88
86
  end
89
87
 
90
- def stub_cancel_capture(attributes, valid: true, success: true, status: '', result_text: 'OK')
88
+ def stub_cancel_capture(attributes, merchant_number: nil, valid: true, success: true, status: '', result_text: 'OK')
91
89
  allow(GpWebpay::Ws::Services::ProcessCancelCapture)
92
90
  .to receive(:call).with(
93
- hash_including({ message_id: anything }.merge(attributes))
91
+ hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
94
92
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
95
93
  valid?: valid, success?: success, status: status, result_text: result_text,
96
94
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
@@ -102,3 +100,4 @@ module GpWebpay
102
100
  end
103
101
  end
104
102
  end
103
+ # rubocop:enable Metrics/ParameterLists
@@ -1,3 +1,3 @@
1
1
  module GpWebpay
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
@@ -23,6 +23,7 @@ module GpWebpay
23
23
  RESPONSE_NAME = 'override_me'.freeze
24
24
  RESPONSE_ENTITY_NAME = 'override_me'.freeze
25
25
  SERVICE_EXCEPTION = :service_exception
26
+ DEFAULT_ATTRIBUTES = {}.freeze
26
27
 
27
28
  def initialize(attributes, merchant_number: :default)
28
29
  @attributes = attributes
@@ -32,9 +33,10 @@ module GpWebpay
32
33
  end
33
34
 
34
35
  def call
35
- attrs = WsRequest.new(attributes.merge(provider: config.provider, merchant_number: config.merchant_number)).to_gpwebpay
36
+ attrs = WsRequest.new(final_attributes).to_gpwebpay
36
37
 
37
- res = client.call(self.class::OPERATION_NAME, message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) })
38
+ Rails.logger.debug([self.class::OPERATION_NAME, { message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) } }])
39
+ res = client.call(self.class::OPERATION_NAME, { message: { self.class::REQUEST_NAME => attributes_with_signature(attrs) } })
38
40
  WsResponse.from_success(res.body, self.class::RESPONSE_NAME, self.class::RESPONSE_ENTITY_NAME, config.merchant_number)
39
41
  rescue Savon::HTTPError => e
40
42
  rescue_from_http(e)
@@ -44,6 +46,12 @@ module GpWebpay
44
46
 
45
47
  protected
46
48
 
49
+ def final_attributes
50
+ {}.merge(self.class::DEFAULT_ATTRIBUTES,
51
+ attributes,
52
+ { provider: config.provider, merchant_number: config.merchant_number })
53
+ end
54
+
47
55
  def digest_text(attrs)
48
56
  attrs.values.join('|')
49
57
  end
@@ -14,6 +14,7 @@ module GpWebpay
14
14
  REQUEST_NAME = :capture_reverse_request
15
15
  RESPONSE_NAME = :process_capture_reverse_response
16
16
  RESPONSE_ENTITY_NAME = :capture_reverse_response
17
+ DEFAULT_ATTRIBUTES = { capture_number: 1 }.freeze # 1 is recommended
17
18
  end
18
19
  end
19
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-gp-webpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lubomir Vnenk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport