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 +4 -4
- data/changelog.md +9 -0
- data/lib/gp_webpay/configuration.rb +11 -2
- data/lib/gp_webpay/mock/spec_helper.rb +15 -15
- data/lib/gp_webpay/version.rb +1 -1
- data/lib/gp_webpay/ws/base_signed_request.rb +15 -3
- data/lib/gp_webpay/ws/services/process_capture_reverse.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 557be3e38c554946e0fe2839549b752342205f2bfaa911a4861a3f1ea268c1a3
|
4
|
+
data.tar.gz: e48dd123da0ac8e2180d43917e3b3c2e63e8afe56cb17b08127824f65faf4f24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3c2c5e04ae5cb2230e28a87d732f8769679b48f2ee0f1eb0f0c2b00e553a69cdaecad3201e0cf6368a0e359ca8f99b970939204160c4b98d1d6869af79ed7e
|
7
|
+
data.tar.gz: ce49aa4b92af16bfb9aff3cec47c2baf190c5361045bbf7acb134a61a2f93626c005725bc80cf854bb592ce3e109b35900234c6841bb365f7b2dc46faf8256fc
|
data/changelog.md
CHANGED
@@ -15,7 +15,16 @@ module GpWebpay
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def [](config_name)
|
18
|
-
|
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
|
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
|
-
|
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
|
data/lib/gp_webpay/version.rb
CHANGED
@@ -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(
|
36
|
+
attrs = WsRequest.new(final_attributes).to_gpwebpay
|
36
37
|
|
37
|
-
|
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,
|
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)
|
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.
|
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-
|
11
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|