spree_vpago 2.1.4.pre.beta5 → 2.1.4.pre.beta6

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: a7ca752b7298fee1a74314e6bd75702cc205a01fdcd24fa70e6a94dfca87c9fe
4
- data.tar.gz: 1b96eb27aa112eef3b143eb5d45d0a17d47b79715798239df882e5a620b5db08
3
+ metadata.gz: 5cc9bf61785b98ad108ca7489f282f2ad24f84d33a4b746ecfa25eed3d411f64
4
+ data.tar.gz: 54a8386ee6192dc2b98e96044e6f7ce689b46413f4fa7365b57f74afd8e5f8c5
5
5
  SHA512:
6
- metadata.gz: 6a93d0c06c023cdfbbdb307bb60ac49896f09f48c5a5e877e5becc2b4029f97e56e150882295c2c3b63e88a7b1d277c522dc06fd4755b2fb7b7c0091855bde00
7
- data.tar.gz: b7d2c4e0dc5a9b3d24b2acd30747b0f4955a566d29b0a7e35d0bd03fb2b205e9ba694197f98144b686bc090561c6f310d8098f644389c1fb3c1ef9987d24e6c9
6
+ metadata.gz: bee5ba3f80b99041f9ef0c71e487508eff0b8b4b3cd62e988f6fda583e3d96e979be3fc3c4c9f2eda7b29a17d54c58bfb42b99ec0522dff6ec07a3b29927ef38
7
+ data.tar.gz: c97611f2ddffa60ca142547515f1b04fcf639cc55cb0b6c30a37dd4bfb5bb4d99fcecffc7584cba2c7d66d78e06db0f40affe91e5b3b42aa004a0850c9f72dd9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.1.4.pre.beta5)
4
+ spree_vpago (2.1.4.pre.beta6)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
@@ -24,6 +24,10 @@ module Vpago
24
24
  ]
25
25
  end
26
26
 
27
+ def available_vattanac_payment_options
28
+ %w[khqr deeplink all]
29
+ end
30
+
27
31
  def preference_field_for(form, field, options)
28
32
  case field
29
33
  when 'preferred_acleda_type'
@@ -33,6 +37,8 @@ module Vpago
33
37
  class: 'fullwidth select2')
34
38
  when 'preferred_icon_name'
35
39
  return form.select(:preferred_icon_name, available_payment_icons, {}, class: 'fullwidth select2')
40
+ when 'preferred_vattanac_payment_option'
41
+ return form.select(:preferred_vattanac_payment_option, available_vattanac_payment_options, {}, class: 'fullwidth select2')
36
42
  end
37
43
  super
38
44
  end
@@ -8,6 +8,7 @@ module Spree
8
8
  preference :password, :string
9
9
  preference :merchant_id, :string
10
10
  preference :payment_type, :string, default: 'GOLF_TICKET'
11
+ preference :vattanac_payment_option, :string, default: 'all'
11
12
 
12
13
  def method_type
13
14
  'vattanac'
@@ -1,22 +1,39 @@
1
1
  <%
2
2
  checkout = Vpago::Vattanac::Checkout.new(@payment)
3
+ payment_option = @payment.payment_method.preferred_vattanac_payment_option
4
+
3
5
  result = begin
4
6
  checkout.create
5
7
  rescue => e
6
8
  Rails.logger.error("Vattanac checkout.create failed: #{e.message}")
7
- { mobile_url: nil, web_url: nil }
9
+ { deeplink_url: nil, web_url: nil }
8
10
  end
9
11
  %>
10
12
 
11
13
  <script>
12
14
  const platform = "<%= params[:platform] %>";
13
- const mobileUrl = "<%= raw(result[:mobile_url]) %>";
15
+ const deeplinkUrl = "<%= raw(result[:deeplink_url]) %>";
14
16
  const webUrl = "<%= raw(result[:web_url]) %>";
15
- if (platform === "app" && mobileUrl) {
16
- window.location.href = mobileUrl;
17
- } else if (platform === "web" && webUrl) {
18
- window.location.href = webUrl;
19
- } else {
20
- console.error("Failed to create payment link:", { mobileUrl, webUrl });
17
+ const paymentOption = "<%= payment_option %>";
18
+
19
+ const redirectTo = (url) => { if (url) window.location.href = url; };
20
+
21
+ switch (paymentOption) {
22
+ case "khqr":
23
+ redirectTo(webUrl);
24
+ break;
25
+
26
+ case "deeplink":
27
+ redirectTo(deeplinkUrl);
28
+ break;
29
+
30
+ case "all":
31
+ if (platform === "app") redirectTo(deeplinkUrl);
32
+ else if (platform === "web") redirectTo(webUrl);
33
+ else console.error("Unknown platform:", platform);
34
+ break;
35
+
36
+ default:
37
+ console.error("Invalid payment option:", paymentOption);
21
38
  }
22
39
  </script>
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.1.4-beta5'.freeze
4
+ VERSION = '2.1.4-beta6'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_vpago
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4.pre.beta5
4
+ version: 2.1.4.pre.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-12 00:00:00.000000000 Z
11
+ date: 2025-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday