spree_vpago 2.2.2.pre.pre6 → 2.2.2.pre.pre7

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: bfb2ee6211441d6c66a5043ed3f5bf7fdb18eb4d68a70ee177ed633cfe6dc49e
4
- data.tar.gz: eb8ddb4d7a0f46363a991dee8d2081ab7c01f7decec63e2305f42c7c260105a7
3
+ metadata.gz: d7793c0aec41fce672ee0633228351ac3aac2f42b2ddd130298796a67d1ad3f0
4
+ data.tar.gz: a50c7029f6a8420f60db25dccb15674f1bac7e4dad979874fbb968427f929ae1
5
5
  SHA512:
6
- metadata.gz: afa0f05102aa05054c503842ba75ba96e414602df5c74595834560340a92801082053529cee425da3eb4ff32fbb387d68825161d22101d234d48605b21a20129
7
- data.tar.gz: 3543272b442de44acbe4c4b82ac82a8212fd6b444998d699f3dcfb35213c22b5f271b6d98fdaf2165d9fa8a767e072c1f6ae0104fe635d3d7673822a8f5d07ab
6
+ metadata.gz: 6116d80f3f46d00c573e39fa1d57bf2c8edd5eb6e1b253244a1b40f561665b47d50b71480e063ce60fbf7f21d62e09ca0f2ce46c2962c3b330c4d8a760ad2970
7
+ data.tar.gz: 06d4f719cda898e6140ca8f0e449b32550540f96c4f1db3932e28924fb3e42afff25c972693f01eca0c76e841fd4462231df5d64716c34a8b530cc9959ca2e1d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.2.2.pre.pre6)
4
+ spree_vpago (2.2.2.pre.pre7)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
@@ -16,6 +16,12 @@ module Spree
16
16
  return redirect_to @payment.processing_url, allow_other_host: true unless @payment.checkout?
17
17
 
18
18
  @order = @payment.order
19
+
20
+ # Set offsite_payment flag based on payment method and browser
21
+ # True Money: always true (from params)
22
+ # ABA KHQR: only true when in in-app browsers
23
+ @offsite_payment = params[:offsite_payment] == 'true' ||
24
+ (params[:check_in_app_browser] == 'true' && in_app_browser?)
19
25
  end
20
26
 
21
27
  # GET
@@ -79,6 +85,17 @@ module Spree
79
85
  sanitized_params
80
86
  end
81
87
 
88
+ private
89
+
90
+ def in_app_browser?
91
+ user_agent = request.user_agent.to_s
92
+ user_agent.include?('FBAN') || user_agent.include?('FBAV') || # Facebook
93
+ user_agent.include?('Telegram') || # Telegram
94
+ user_agent.include?('MicroMessenger') || # WeChat
95
+ user_agent.include?('Line') || # Line
96
+ user_agent.include?('WhatsApp') # WhatsApp
97
+ end
98
+
82
99
  def render_not_found
83
100
  respond_to do |format|
84
101
  format.html { render file: Rails.public_path.join('404.html'), status: :not_found, layout: false }
@@ -8,5 +8,9 @@ module Vpago
8
8
  def render_form
9
9
  render partial: "spree/vpago_payments/forms/#{@payment.payment_method.class.to_s.underscore}"
10
10
  end
11
+
12
+ def offsite_payment?
13
+ @offsite_payment || false
14
+ end
11
15
  end
12
16
  end
@@ -24,7 +24,8 @@ module Vpago
24
24
  payment_number: payment.number,
25
25
  order_number: order.number,
26
26
  order_jwt_token: order_jwt_token,
27
- offsite_payment: offsite_payment? ? true : nil
27
+ offsite_payment: offsite_payment? ? true : nil,
28
+ check_in_app_browser: aba_khqr_payment? ? true : nil
28
29
  }.compact.to_query
29
30
  end
30
31
 
@@ -33,6 +34,13 @@ module Vpago
33
34
  payment.payment_method.type_true_money?
34
35
  end
35
36
 
37
+ def aba_khqr_payment?
38
+ return false unless payment.payment_method.is_a?(Spree::Gateway::PaywayV2)
39
+
40
+ payment_option = payment.payment_method.preferred_payment_option
41
+ payment_option.in?(%w[abapay_khqr abapay_khqr_deeplink])
42
+ end
43
+
36
44
  private
37
45
 
38
46
  def app_scheme
@@ -13,32 +13,37 @@
13
13
  </form>
14
14
 
15
15
  <script>
16
- document.addEventListener("DOMContentLoaded", function () {
17
- const form = document.getElementById("aba_merchant_request");
18
- const paymentOption = form.dataset.paymentOption;
16
+ document.addEventListener("DOMContentLoaded", function () {
17
+ const form = document.getElementById("aba_merchant_request");
18
+ const paymentOption = form.dataset.paymentOption;
19
19
 
20
- // 🔹 CASE 1: ABA KHQR Deeplink → fetch JSON then redirect
21
- if (paymentOption === "abapay_khqr_deeplink") {
22
- fetch(form.action, {
23
- method: "POST",
24
- body: new FormData(form)
25
- })
26
- .then(res => res.json())
27
- .then(data => {
28
- if (data.abapay_deeplink) {
20
+ // 🔹 CASE 1: ABA KHQR Deeplink → fetch JSON then redirect
21
+ if (paymentOption === "abapay_khqr_deeplink") {
22
+ fetch(form.action, {
23
+ method: "POST",
24
+ body: new FormData(form)
25
+ })
26
+ .then(res => res.json())
27
+ .then(data => {
28
+ if (data.checkout_qr_url) {
29
+ window.open(data.checkout_qr_url, "_blank");
30
+ }
31
+
32
+ if (data.abapay_deeplink) {
33
+ setTimeout(() => {
29
34
  window.location.href = data.abapay_deeplink;
30
- } else if (data.checkout_qr_url) {
31
- window.location.href = data.checkout_qr_url;
32
- }
33
- if (!data.checkout_qr_url && !data.abapay_deeplink) {
34
- console.error("checkout_qr_url and abapay_deeplink both missing", data);
35
- }
36
- })
37
- .catch(err => console.error("ABA Deeplink Error:", err));
35
+ }, 1500);
36
+ }
37
+
38
+ if (!data.checkout_qr_url && !data.abapay_deeplink) {
39
+ console.error("checkout_qr_url and abapay_deeplink both missing", data);
40
+ }
41
+ })
42
+ .catch(err => console.error("ABA Deeplink Error:", err));
38
43
 
39
- // 🔹 CASE 2: Normal ABA KHQR → regular redirect form post
40
- } else {
41
- form.submit();
42
- }
43
- });
44
+ // 🔹 CASE 2: Normal ABA KHQR → regular redirect form post
45
+ } else {
46
+ form.submit();
47
+ }
48
+ });
44
49
  </script>
@@ -8,32 +8,50 @@ rescue => e
8
8
  Rails.logger.error("Vattanac checkout.create failed: #{e.message}")
9
9
  { deeplink_url: nil, web_url: nil }
10
10
  end
11
+
12
+ @payment.user_informer.payment_is_processing(processing: true)
11
13
  %>
12
14
 
13
15
  <script>
14
- const platform = "<%= params[:platform] %>";
15
- const deeplinkUrl = "<%= raw(result[:deeplink_url]) %>";
16
- const webUrl = "<%= raw(result[:web_url]) %>";
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);
38
- }
16
+ document.addEventListener("DOMContentLoaded", () => {
17
+ const platform = "<%= params[:platform] %>";
18
+ const deeplinkUrl = "<%= raw(result[:deeplink_url]) %>";
19
+ const webUrl = "<%= raw(result[:web_url]) %>";
20
+ const paymentOption = "<%= payment_option %>";
21
+
22
+ const redirectTo = (url) => { if (url) window.location.href = url; };
23
+
24
+ const setupPaymentProcessingListener = () => {
25
+ const firebaseConfigs = <%= Rails.application.credentials.firebase_web_config.to_json.html_safe %>;
26
+ const documentReferencePath = "<%= @payment.user_informer.document_reference_path %>";
27
+ const successUrl = "<%= @payment.success_url %>";
28
+
29
+ if (window.initPaymentProcessingListener) {
30
+ window.initPaymentProcessingListener(firebaseConfigs, documentReferencePath, successUrl);
31
+ } else {
32
+ console.log("initPaymentProcessingListener is not defined");
33
+ }
34
+ };
35
+
36
+ switch (paymentOption) {
37
+ case "khqr":
38
+ redirectTo(webUrl);
39
+ break;
40
+
41
+ case "deeplink":
42
+ redirectTo(deeplinkUrl);
43
+ break;
44
+
45
+ case "all":
46
+ if (platform === "app") redirectTo(deeplinkUrl);
47
+ else if (platform === "web") redirectTo(webUrl);
48
+ else console.error("Unknown platform:", platform);
49
+ break;
50
+
51
+ default:
52
+ console.error("Invalid payment option:", paymentOption);
53
+ }
54
+
55
+ setupPaymentProcessingListener();
56
+ });
39
57
  </script>
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.2.2-pre6'.freeze
4
+ VERSION = '2.2.2-pre7'.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.2.2.pre.pre6
4
+ version: 2.2.2.pre.pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-17 00:00:00.000000000 Z
11
+ date: 2026-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday