rails-gp-webpay 0.2.1 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52882ed499ad728c9d62bac6f924422d0b15518c85bc965944b9e0d0332e13cf
4
- data.tar.gz: 3218bcd7f60ff9ba26778cdaa7ad9b33ade27e7f3b627eda6001d4a2b981ee99
3
+ metadata.gz: 557be3e38c554946e0fe2839549b752342205f2bfaa911a4861a3f1ea268c1a3
4
+ data.tar.gz: e48dd123da0ac8e2180d43917e3b3c2e63e8afe56cb17b08127824f65faf4f24
5
5
  SHA512:
6
- metadata.gz: db6879b751fddb1af35073ea7cf40ccda2200379a9547be32b9de979e6a755dc81290d83565dadbc4411e5b3af6cbec4958372b7b55b93eea30206e665d41345
7
- data.tar.gz: 3c432d0befc7f32b069d57d65dfdb2eaf63f1f824cb90b4eab40c80795cf0f0cd22b97274b06436aa9731c5aa5c5a1e5d43019129c31046ea10767a4d7f45481
6
+ metadata.gz: ae3c2c5e04ae5cb2230e28a87d732f8769679b48f2ee0f1eb0f0c2b00e553a69cdaecad3201e0cf6368a0e359ca8f99b970939204160c4b98d1d6869af79ed7e
7
+ data.tar.gz: ce49aa4b92af16bfb9aff3cec47c2baf190c5361045bbf7acb134a61a2f93626c005725bc80cf854bb592ce3e109b35900234c6841bb365f7b2dc46faf8256fc
data/changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.6
4
+ Add merchant number to tests, add default attributes to requests
5
+
6
+ ## 0.2.4
7
+ Increase savon timeout to 5 minutes
8
+
9
+ ## 0.2.2
10
+ Add merchant number to stubs
11
+
3
12
  ## 0.2
4
13
  Add spec helpers
5
14
 
@@ -15,7 +15,16 @@ module GpWebpay
15
15
  end
16
16
 
17
17
  def [](config_name)
18
- @configurations[config_name]
18
+ return if config_name.blank?
19
+
20
+ @configurations[config_name] || find_configuration_by_merchant_number(config_name)
21
+ end
22
+
23
+ def find_configuration_by_merchant_number(merchant_number)
24
+ config = @configurations.find { |_key, value| value.merchant_number.to_s == merchant_number.to_s }
25
+ return nil if config.blank?
26
+
27
+ config[-1]
19
28
  end
20
29
 
21
30
  def add_configuration(merchant_number:, default: false)
@@ -25,7 +34,7 @@ module GpWebpay
25
34
  end
26
35
 
27
36
  def remove_configuration(merchant_number:)
28
- @configurations[merchant_number] = nil
37
+ @configurations.delete(merchant_number)
29
38
  @configurations[:default] = @configurations[@configurations.keys[0]]
30
39
  end
31
40
 
@@ -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
@@ -33,26 +33,25 @@ module GpWebpay
33
33
  .and_return(instance_double(GpWebpay::Ws::WsResponse, valid?: valid, success?: success, status: status))
34
34
  end
35
35
 
36
- def stub_payment_status(payment_number, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true)
36
+ def stub_payment_status(payment_number, merchant_number: nil, status: 'VERIFIED', sub_status: 'SETTLED', success: true, valid: true)
37
37
  allow(GpWebpay::Ws::Services::GetPaymentStatus)
38
- .to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything))
38
+ .to receive(:call).with(hash_including(payment_number: payment_number, message_id: anything), merchant_number: merchant_number)
39
39
  .and_return(instance_double(GpWebpay::Ws::WsResponse,
40
40
  valid?: valid, success?: success, status: status,
41
41
  params: { sub_status: sub_status }))
42
42
  end
43
43
 
44
- def stub_usage_based_payment(attributes, valid: true, success: true, status: '', result_text: 'OK', response_token_data: nil)
44
+ def stub_usage_based_payment(attributes, merchant_number:, valid: true, success: true, status: '', result_text: 'OK', response_token_data: nil)
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)
55
- )
52
+ capture_flag: '1' }.merge(attributes)
53
+ ),
54
+ merchant_number: merchant_number
56
55
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
57
56
  valid?: valid, success?: success, status: status, result_text: result_text,
58
57
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4',
@@ -68,28 +67,28 @@ module GpWebpay
68
67
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
69
68
  end
70
69
 
71
- 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')
72
71
  allow(GpWebpay::Ws::Services::ProcessRefundPayment)
73
72
  .to receive(:call).with(
74
- hash_including({ message_id: anything }.merge(attributes))
73
+ hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
75
74
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
76
75
  valid?: valid, success?: success, status: status, result_text: result_text,
77
76
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
78
77
  end
79
78
 
80
- 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')
81
80
  allow(GpWebpay::Ws::Services::ProcessCaptureReverse)
82
81
  .to receive(:call).with(
83
- hash_including({ message_id: anything }.merge(attributes))
82
+ hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
84
83
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
85
84
  valid?: valid, success?: success, status: status, result_text: result_text,
86
85
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
87
86
  end
88
87
 
89
- 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')
90
89
  allow(GpWebpay::Ws::Services::ProcessCancelCapture)
91
90
  .to receive(:call).with(
92
- hash_including({ message_id: anything }.merge(attributes))
91
+ hash_including({ message_id: anything }.merge(attributes)), merchant_number: merchant_number
93
92
  ).and_return(instance_double(GpWebpay::Ws::WsResponse,
94
93
  valid?: valid, success?: success, status: status, result_text: result_text,
95
94
  pr_code: success ? '0' : '123', sr_code: success ? '0' : '4'))
@@ -101,3 +100,4 @@ module GpWebpay
101
100
  end
102
101
  end
103
102
  end
103
+ # rubocop:enable Metrics/ParameterLists
@@ -1,3 +1,3 @@
1
1
  module GpWebpay
2
- VERSION = '0.2.1'.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
@@ -54,7 +62,11 @@ module GpWebpay
54
62
  end
55
63
 
56
64
  def client
57
- @client ||= Savon.client(wsdl: config.wsdl_file, endpoint: config.ws_url, pretty_print_xml: true)
65
+ @client ||= Savon.client(wsdl: config.wsdl_file,
66
+ endpoint: config.ws_url,
67
+ pretty_print_xml: true,
68
+ open_timeout: 300,
69
+ read_timeout: 300)
58
70
  end
59
71
 
60
72
  def rescue_from_http(error)
@@ -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.1
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-04-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