spree_vpago 2.1.4.pre.beta5 → 2.1.4.pre.beta7

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: a82a810c320d442c615a12518746acd17590f2f9a4418b73fad7ccd520322f31
4
+ data.tar.gz: bf1f2af6b0fbbfeaa3415fe90d1efa787fa501245b742cd18baa5a365d46c893
5
5
  SHA512:
6
- metadata.gz: 6a93d0c06c023cdfbbdb307bb60ac49896f09f48c5a5e877e5becc2b4029f97e56e150882295c2c3b63e88a7b1d277c522dc06fd4755b2fb7b7c0091855bde00
7
- data.tar.gz: b7d2c4e0dc5a9b3d24b2acd30747b0f4955a566d29b0a7e35d0bd03fb2b205e9ba694197f98144b686bc090561c6f310d8098f644389c1fb3c1ef9987d24e6c9
6
+ metadata.gz: edeba79b6778e35c84e24a7e29486dad3fb05fab64e6d180f290dcee6ccc72c2640a82bda6cd037d023f5f98ed1ec26698ac2660f070dfe14c0f06cc55519af4
7
+ data.tar.gz: c1822b9266811b1e9c713b61ecd872168e6d2a8f8578e8dac195a692b9c324827779af674a49f178abdd31f0a0a527d625fd6f693fac939d23e0b94926067737
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.beta7)
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-beta7'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
@@ -17,7 +17,7 @@ module Vpago
17
17
  response_data = post(generate_payment_url, payload)['data']
18
18
  {
19
19
  web_url: response_data['webPaymentUrl'],
20
- mobile_url: response_data['mobileDeepLink'],
20
+ deeplink_url: response_data['mobileDeepLink'],
21
21
  expires_at: response_data['expiredIn'],
22
22
  generated_at: response_data['generatedAt']
23
23
  }
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.beta7
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