spree_emerchantpay_genesis 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +25 -2
- data/app/helpers/spree_emerchantpay_genesis/mappers/genesis.rb +43 -10
- data/app/helpers/spree_emerchantpay_genesis/mappers/order.rb +9 -6
- data/app/helpers/spree_emerchantpay_genesis/mappers/threeds_attributes.rb +2 -1
- data/app/helpers/spree_emerchantpay_genesis/payment_method_helper.rb +7 -0
- data/app/models/spree/gateway/emerchantpay_checkout.rb +10 -1
- data/app/models/spree_emerchantpay_genesis/base/gateway.rb +6 -1
- data/app/services/spree_emerchantpay_genesis/notifications/service_handler.rb +0 -2
- data/app/services/spree_emerchantpay_genesis/threeds/method_continue.rb +0 -2
- data/app/views/spree/admin/payments/source_views/_emerchantpay_checkout.html.erb +25 -0
- data/config/locales/en.yml +27 -0
- data/lib/spree_emerchantpay_genesis/version.rb +1 -1
- metadata +16 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2dbd23a908a23677fb4ee2bea0a49cc739052aa5d882e57b7c532d57c480602
|
4
|
+
data.tar.gz: d6b2c2fbbe86dcc820946edda7c79d7ff34b83ba702e0b678226ad5c87667306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0487117b7c98132dd864200b76d52c9b9c2b678244726bb6386a3c4c2c3220de2b729dc3c6f8d767abc46bf460c6655e158c301664777b10cf71d6a22f9268a9'
|
7
|
+
data.tar.gz: 861e78025ac386920634ddacb4c130d2d6285067fb693ddad00da2b9fc897a3e0011999d567795cd385931aada42d280e0e105225c07652bd618d786e282cfbf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.1.5
|
2
|
+
-----
|
3
|
+
**Features**:
|
4
|
+
|
5
|
+
* Added `emerchantpay Checkout` Description field handling
|
6
|
+
* Updated Genesis Ruby SDK to version 0.1.6
|
7
|
+
* Updated project dependencies
|
8
|
+
* Added `emerchantpay Checkout` Custom Attributes handling
|
9
|
+
* Added `emerchantpay Checkout` Language support
|
10
|
+
|
1
11
|
0.1.4
|
2
12
|
-----
|
3
13
|
**Features**:
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ This is a Payment Module for Spree eCommerce that gives you the ability to proce
|
|
7
7
|
* Spree FrontEnd - Optional (Tested up to 4.4.0)
|
8
8
|
* Ruby >= 2.7
|
9
9
|
* Ruby on Rails >= 6.1.4
|
10
|
-
* [GenesisRuby v0.1.
|
10
|
+
* [GenesisRuby v0.1.6](https://github.com/GenesisGateway/genesis_ruby/releases/tag/0.1.6)
|
11
11
|
* PCI-certified server in order to use emerchantpay Direct
|
12
12
|
|
13
13
|
## Installation
|
@@ -216,7 +216,30 @@ curl --request 'POST' \
|
|
216
216
|
|
217
217
|
#### Create Checkout Payment
|
218
218
|
|
219
|
-
The Checkout Gateway doesn't require `source_attributes` (see [p.4 Update Order](#payment-point-4)). Upon Order Update or Payment Create the only required parameter is `payment_method_id`.
|
219
|
+
The Checkout Gateway doesn't require `source_attributes` by default (see [p.4 Update Order](#payment-point-4)). Upon Order Update or Payment Create the only required parameter is `payment_method_id`.
|
220
|
+
|
221
|
+
In some cases, the Gateway Web Payment Form may require Custom Attributes. Those attributes can be passed to the gateway via `api/v2/storefront/checkout/create_payment`.
|
222
|
+
public_metadata contains a list with custom attributes where the key is the transaction type chosen on the payment method configuration inside the administration backend.
|
223
|
+
|
224
|
+
```bash
|
225
|
+
curl --request 'POST' \
|
226
|
+
--header 'Accept: application/vnd.api+json' \
|
227
|
+
--header 'X-Spree-Order-Token: EsDjq1oXEgKI6kuujgfvFw1694531383712' \
|
228
|
+
--header 'Content-Type: application/vnd.api+json' \
|
229
|
+
--url 'http://localhost:4000/api/v2/storefront/checkout/create_payment' \
|
230
|
+
--data '{
|
231
|
+
"payment_method_id": "8",
|
232
|
+
"source_attributes": {
|
233
|
+
"consumer_id":"123456",
|
234
|
+
"consumer_email": "travis@example.com",
|
235
|
+
"public_metadata": {
|
236
|
+
"sale3d": { "bin": "401200", "tail": "0085"},
|
237
|
+
"trustly_sale": {"return_success_url_target": "top"}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}'
|
241
|
+
```
|
242
|
+
Full list with the available Custom Attributes for every Transaction Type can be found [here](https://emerchantpay.github.io/gateway-api-docs/#wpf-transaction-types).
|
220
243
|
|
221
244
|
The payment can be finished and a request to the Gateway will be sent with one of the Order Next or Complete endpoints.
|
222
245
|
|
@@ -75,16 +75,15 @@ module SpreeEmerchantpayGenesis
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# Map WPF request
|
78
|
-
def map_wpf(order,
|
78
|
+
def map_wpf(order, source, options)
|
79
79
|
common_attributes order, support_ip: false
|
80
|
+
description_attribute order
|
80
81
|
billing_attributes order
|
81
82
|
shipping_attributes order
|
82
|
-
asyn_attributes options
|
83
|
-
transaction_types_attributes options
|
83
|
+
asyn_attributes options, is_wpf: true
|
84
|
+
transaction_types_attributes options, source
|
84
85
|
threeds_wpf_attributes order, options if ActiveModel::Type::Boolean.new.cast options[:threeds_allowed]
|
85
|
-
|
86
|
-
@context.return_cancel_url = options[:return_cancel_url]
|
87
|
-
@context.return_pending_url = options[:return_pending_url]
|
86
|
+
wpf_locale_attributes options
|
88
87
|
|
89
88
|
self
|
90
89
|
end
|
@@ -181,11 +180,16 @@ module SpreeEmerchantpayGenesis
|
|
181
180
|
end
|
182
181
|
|
183
182
|
# Asynchronous attributes
|
184
|
-
def asyn_attributes(options)
|
183
|
+
def asyn_attributes(options, is_wpf: false)
|
185
184
|
@context.notification_url = "#{options[:hostname]}#{api_v2_storefront_emerchantpay_notification_path}"
|
186
185
|
@context.return_success_url = options[:return_success_url]
|
187
186
|
@context.return_failure_url = options[:return_failure_url]
|
188
187
|
|
188
|
+
if is_wpf
|
189
|
+
@context.return_cancel_url = options[:return_cancel_url]
|
190
|
+
@context.return_pending_url = options[:return_pending_url]
|
191
|
+
end
|
192
|
+
|
189
193
|
nil
|
190
194
|
end
|
191
195
|
|
@@ -209,12 +213,41 @@ module SpreeEmerchantpayGenesis
|
|
209
213
|
end
|
210
214
|
|
211
215
|
# Map WPF Transaction Types
|
212
|
-
def transaction_types_attributes(options)
|
213
|
-
|
214
|
-
|
216
|
+
def transaction_types_attributes(options, source)
|
217
|
+
custom_attributes = source.public_metadata
|
218
|
+
transaction_types = PaymentMethodHelper.select_options_value options, :transaction_types
|
219
|
+
|
220
|
+
transaction_types.each do |type|
|
221
|
+
next if type.empty?
|
222
|
+
|
223
|
+
if custom_attributes.key?(type.to_s) && custom_attributes[type.to_s].is_a?(Hash)
|
224
|
+
@context.add_transaction_type type, custom_attributes[type.to_s].deep_symbolize_keys
|
225
|
+
|
226
|
+
next
|
227
|
+
end
|
228
|
+
|
229
|
+
@context.add_transaction_type type
|
215
230
|
end
|
216
231
|
end
|
217
232
|
|
233
|
+
# Map WPF Description field
|
234
|
+
def description_attribute(order)
|
235
|
+
items_description = order.line_items.map { |item| ["#{item[:product_name]} x #{item[:quantity]}"] }
|
236
|
+
|
237
|
+
@context.description = items_description.join("\n")
|
238
|
+
|
239
|
+
nil
|
240
|
+
end
|
241
|
+
|
242
|
+
# Map WPF language attributes
|
243
|
+
def wpf_locale_attributes(options)
|
244
|
+
locale = PaymentMethodHelper.select_options_value options, :language
|
245
|
+
|
246
|
+
return unless locale.is_a? String
|
247
|
+
|
248
|
+
@context.locale = locale.delete_prefix('\'').delete_suffix('\'')
|
249
|
+
end
|
250
|
+
|
218
251
|
end
|
219
252
|
end
|
220
253
|
end
|
@@ -5,11 +5,10 @@ module SpreeEmerchantpayGenesis
|
|
5
5
|
|
6
6
|
NESTED_NODES = %w(billing_address shipping_address line_items user).freeze
|
7
7
|
ORDER_ALLOWED_ATTRIBUTES = %w(
|
8
|
-
id currency item_total total user_id token item_count email shipment_total
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
created_at updated_at
|
8
|
+
id currency item_total total user_id token item_count email shipment_total bill_address_id ship_address_id
|
9
|
+
last_ip_address adjustment_total additional_tax_total included_tax_total number customer ip order_id shipping
|
10
|
+
tax subtotal discount name address1 address2 city state zip country phone digital created_at updated_at
|
11
|
+
product_name
|
13
12
|
) + NESTED_NODES
|
14
13
|
|
15
14
|
# Prepare Order data used from the Order mapper
|
@@ -17,7 +16,11 @@ module SpreeEmerchantpayGenesis
|
|
17
16
|
order.attributes.symbolize_keys.merge(
|
18
17
|
gateway_options,
|
19
18
|
{ digital: order.digital? },
|
20
|
-
{
|
19
|
+
{
|
20
|
+
line_items: order.line_items.map do |line_item|
|
21
|
+
line_item.attributes.symbolize_keys.merge({ product_name: line_item.product.name })
|
22
|
+
end
|
23
|
+
},
|
21
24
|
{ user: (user ? user.attributes.symbolize_keys : {}) }
|
22
25
|
)
|
23
26
|
end
|
@@ -71,7 +71,8 @@ module SpreeEmerchantpayGenesis
|
|
71
71
|
|
72
72
|
@context.threeds_v2_control_challenge_window_size =
|
73
73
|
fetch_threeds_constant('Control::ChallengeWindowSizes::FULLSCREEN')
|
74
|
-
@context.threeds_v2_control_challenge_indicator =
|
74
|
+
@context.threeds_v2_control_challenge_indicator =
|
75
|
+
PaymentMethodHelper.select_options_value options, :challenge_indicator
|
75
76
|
|
76
77
|
nil
|
77
78
|
end
|
@@ -28,6 +28,13 @@ module SpreeEmerchantpayGenesis
|
|
28
28
|
default_attr
|
29
29
|
end
|
30
30
|
|
31
|
+
# Get default values for select options
|
32
|
+
def select_options_value(options, key)
|
33
|
+
return options[key][:selected] if options[key].is_a? Hash
|
34
|
+
|
35
|
+
options[key]
|
36
|
+
end
|
37
|
+
|
31
38
|
end
|
32
39
|
|
33
40
|
end
|
@@ -3,10 +3,19 @@ module Spree
|
|
3
3
|
class Gateway::EmerchantpayCheckout < SpreeEmerchantpayGenesis::Base::Gateway # rubocop:disable Style/ClassAndModuleChildren
|
4
4
|
|
5
5
|
preference :transaction_types, :multi_select, default: lambda {
|
6
|
-
{
|
6
|
+
{
|
7
|
+
values: GenesisRuby::Utils::Transactions::WpfTypes.all,
|
8
|
+
selected: [GenesisRuby::Api::Constants::Transactions::SALE_3D]
|
9
|
+
}
|
7
10
|
}
|
8
11
|
preference :return_cancel_url, :string, default: 'http://localhost:4000/checkout/payment'
|
9
12
|
preference :return_pending_url, :string, default: 'http://localhost:4000/orders/|:ORDER:|'
|
13
|
+
preference :language, :select, default: lambda {
|
14
|
+
{
|
15
|
+
values: GenesisRuby::Api::Constants::I18n.all,
|
16
|
+
selected: GenesisRuby::Api::Constants::I18n::EN
|
17
|
+
}
|
18
|
+
}
|
10
19
|
|
11
20
|
delegate :load_data, :load_source, :load_payment, to: :provider
|
12
21
|
|
@@ -9,7 +9,12 @@ module SpreeEmerchantpayGenesis
|
|
9
9
|
preference :return_failure_url, :string, default: 'http://localhost:4000/checkout/payment?order_number=|:ORDER:|'
|
10
10
|
preference :threeds_allowed, :boolean_select, default: true
|
11
11
|
preference :challenge_indicator, :select, default: lambda {
|
12
|
-
{
|
12
|
+
{
|
13
|
+
values: GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Control::
|
14
|
+
ChallengeIndicators.all,
|
15
|
+
selected: GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Control::
|
16
|
+
ChallengeIndicators::NO_PREFERENCE
|
17
|
+
}
|
13
18
|
}
|
14
19
|
preference :hostname, :string, default: 'http://127.0.0.1:4000'
|
15
20
|
preference :test_mode, :boolean_select, default: true
|
@@ -14,6 +14,31 @@
|
|
14
14
|
<th><%= I18n.t('emerchantpay.payments_table.source_consumer_email') %>:</th>
|
15
15
|
<td><%= payment.source.consumer_email %></td>
|
16
16
|
</tr>
|
17
|
+
<% unless payment.source.public_metadata.empty? %>
|
18
|
+
<tr>
|
19
|
+
<td colspan="2" class="text-center">
|
20
|
+
<h3><%= I18n.t('emerchantpay.payments_table.source_custom_attributes') %></h3>
|
21
|
+
<table class="table border-top-0">
|
22
|
+
<% payment.source.public_metadata.each do |transaction_type, custom_attributes| %>
|
23
|
+
<% next unless custom_attributes.is_a? Hash %>
|
24
|
+
<tr>
|
25
|
+
<th class="col-2"><%= transaction_type %></th>
|
26
|
+
<td class="text-left col-10">
|
27
|
+
<table class="table">
|
28
|
+
<% custom_attributes .each do |attribute, value| %>
|
29
|
+
<tr>
|
30
|
+
<td class="col-5"><%= attribute %></td>
|
31
|
+
<td class="col-7"><%= value %></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
</table>
|
35
|
+
</td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
</table>
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
17
42
|
</table>
|
18
43
|
</div>
|
19
44
|
</fieldset>
|
data/config/locales/en.yml
CHANGED
@@ -75,6 +75,32 @@ en:
|
|
75
75
|
webmoney: Webmoney
|
76
76
|
webpay: Webpay
|
77
77
|
wechat: Wechat
|
78
|
+
ar: Arabic
|
79
|
+
bg: Bulgarian
|
80
|
+
de: German
|
81
|
+
en: English
|
82
|
+
es: Spanish
|
83
|
+
fr: French
|
84
|
+
hi: Hindu
|
85
|
+
ja: Japanese
|
86
|
+
is: Icelandic
|
87
|
+
it: Italian
|
88
|
+
nl: Dutch
|
89
|
+
pt: Portuguese
|
90
|
+
pl: Polish
|
91
|
+
ru: Russian
|
92
|
+
tr: Turkish
|
93
|
+
zh: Mandarin Chinese
|
94
|
+
id: Indonesian
|
95
|
+
ms: Malay
|
96
|
+
th: Thai
|
97
|
+
cs: Czech
|
98
|
+
hr: Croatian
|
99
|
+
sl: Slovenian
|
100
|
+
fi: Finnish
|
101
|
+
"no": Norwegian
|
102
|
+
da: Danish
|
103
|
+
sv: Swedish
|
78
104
|
payment:
|
79
105
|
usage: Electronic transaction via Spree eCommerce platform
|
80
106
|
reference: Reference transaction via Spree eCommerce platform
|
@@ -96,6 +122,7 @@ en:
|
|
96
122
|
source_name: Name
|
97
123
|
source_consumer_id: Consumer ID
|
98
124
|
source_consumer_email: Consumer Email
|
125
|
+
source_custom_attributes: Custom Attributes
|
99
126
|
spree:
|
100
127
|
token: Token
|
101
128
|
username: Username
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_emerchantpay_genesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- emerchantpay ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: genesis_ruby
|
@@ -16,49 +16,32 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '6.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '6.0'
|
26
|
+
version: 0.1.6
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: securerandom
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - "
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
33
|
+
version: '0'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
40
|
+
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: spree_backend
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '4.4'
|
62
45
|
- - ">="
|
63
46
|
- !ruby/object:Gem::Version
|
64
47
|
version: 4.4.0
|
@@ -66,9 +49,6 @@ dependencies:
|
|
66
49
|
prerelease: false
|
67
50
|
version_requirements: !ruby/object:Gem::Requirement
|
68
51
|
requirements:
|
69
|
-
- - "~>"
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '4.4'
|
72
52
|
- - ">="
|
73
53
|
- !ruby/object:Gem::Version
|
74
54
|
version: 4.4.0
|
@@ -76,9 +56,6 @@ dependencies:
|
|
76
56
|
name: spree_core
|
77
57
|
requirement: !ruby/object:Gem::Requirement
|
78
58
|
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '4.4'
|
82
59
|
- - ">="
|
83
60
|
- !ruby/object:Gem::Version
|
84
61
|
version: 4.4.0
|
@@ -86,9 +63,6 @@ dependencies:
|
|
86
63
|
prerelease: false
|
87
64
|
version_requirements: !ruby/object:Gem::Requirement
|
88
65
|
requirements:
|
89
|
-
- - "~>"
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '4.4'
|
92
66
|
- - ">="
|
93
67
|
- !ruby/object:Gem::Version
|
94
68
|
version: 4.4.0
|
@@ -96,16 +70,16 @@ dependencies:
|
|
96
70
|
name: spree_extension
|
97
71
|
requirement: !ruby/object:Gem::Requirement
|
98
72
|
requirements:
|
99
|
-
- -
|
73
|
+
- - ">="
|
100
74
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0
|
75
|
+
version: '0'
|
102
76
|
type: :runtime
|
103
77
|
prerelease: false
|
104
78
|
version_requirements: !ruby/object:Gem::Requirement
|
105
79
|
requirements:
|
106
|
-
- -
|
80
|
+
- - ">="
|
107
81
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0
|
82
|
+
version: '0'
|
109
83
|
- !ruby/object:Gem::Dependency
|
110
84
|
name: appraisal
|
111
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,16 +238,16 @@ dependencies:
|
|
264
238
|
name: rspec-rails
|
265
239
|
requirement: !ruby/object:Gem::Requirement
|
266
240
|
requirements:
|
267
|
-
- - "
|
241
|
+
- - ">="
|
268
242
|
- !ruby/object:Gem::Version
|
269
|
-
version: '
|
243
|
+
version: '0'
|
270
244
|
type: :development
|
271
245
|
prerelease: false
|
272
246
|
version_requirements: !ruby/object:Gem::Requirement
|
273
247
|
requirements:
|
274
|
-
- - "
|
248
|
+
- - ">="
|
275
249
|
- !ruby/object:Gem::Version
|
276
|
-
version: '
|
250
|
+
version: '0'
|
277
251
|
- !ruby/object:Gem::Dependency
|
278
252
|
name: rubocop
|
279
253
|
requirement: !ruby/object:Gem::Requirement
|