spree_vpago 2.2.2.pre.pre8 → 2.2.2.pre.pre10

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: 0b0060eaa253e9722aed97f31783691157bf1c673f9cbc0f5f9f7f05450946f8
4
- data.tar.gz: e1e6f2c6a5999d7d9c99e366c765831f1e5d117b37793a3ca48a2338ca192521
3
+ metadata.gz: bd56e9a7ecb7d8d5ca0abaf1232b9d92233bd025043e06b763dbb89d675e0412
4
+ data.tar.gz: 757343200d1e61cbe263a684d24ce2fa1fdd112c87b0d696bf27842132066378
5
5
  SHA512:
6
- metadata.gz: c8ca407d20d38c796db7a8dadcd03207b8df1b0eeb7d76fbcbad6d4f1aebbd4d27c1ccd7c5fe99b19a4a03db02d59a0888c31d6bbe06d54bbbe75bfd2605376f
7
- data.tar.gz: d1eda927ce546aafcd826583e1cc1ca57f2a425c5a4117c7600a3c6ea1741b22c58119644a6df4b3e5f3eda00e59490b148b930748f0f8b22ea98adb3bf854ad
6
+ metadata.gz: 6ef89ccf97395357c1f766648af7fc48891494fc9b2b14d159edfd01c6e7a88f456bb8865bae8a76cde9821122badd3932d6516c6dc78c0c6903c7f25684591e
7
+ data.tar.gz: 97718367ab37d76e0d9898278df202752167c2b4056954e6bb37534a23e6b57d60a5b200c6395e98f3c332e5e5eb94a74e4c771c9887155a448f385716adf316
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.2.2.pre.pre8)
4
+ spree_vpago (2.2.2.pre.pre10)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
@@ -12,43 +12,80 @@
12
12
  <% end %>
13
13
  </form>
14
14
 
15
+ <!-- WebView Container -->
16
+ <div id="webViewContainer" style="display:none;"></div>
17
+
15
18
  <script>
16
- document.addEventListener("DOMContentLoaded", function () {
17
- const form = document.getElementById("aba_merchant_request");
18
- const paymentOption = form.dataset.paymentOption;
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
- // 🔹 Load checkout page in current tab
29
- if (data.checkout_qr_url) {
30
- window.location.href = data.checkout_qr_url;
31
- }
32
-
33
- // 🔹 Attempt ABA deeplink in background
34
- if (data.abapay_deeplink) {
35
- setTimeout(() => {
36
- const iframe = document.createElement("iframe");
37
- iframe.style.display = "none";
38
- iframe.src = data.abapay_deeplink;
39
- document.body.appendChild(iframe);
40
- }, 2000); // wait 1s to allow checkout to start loading
41
- }
42
-
43
- if (!data.checkout_qr_url && !data.abapay_deeplink) {
44
- console.error("checkout_qr_url and abapay_deeplink both missing", data);
45
- }
46
- })
47
- .catch(err => console.error("ABA Deeplink Error:", err));
48
-
49
- // 🔹 CASE 2: Normal ABA KHQR → regular redirect form post
50
- } else {
51
- form.submit();
52
- }
53
- });
19
+ document.addEventListener("DOMContentLoaded", function () {
20
+ const form = document.getElementById("aba_merchant_request");
21
+ const paymentOption = form.dataset.paymentOption;
22
+ const webViewContainer = document.getElementById("webViewContainer");
23
+
24
+ // CASE 1: ABA KHQR Deeplink → fetch JSON then redirect
25
+ if (paymentOption === "abapay_khqr_deeplink") {
26
+
27
+ fetch(form.action, {
28
+ method: "POST",
29
+ body: new FormData(form)
30
+ })
31
+ .then(res => res.json())
32
+ .then(data => {
33
+
34
+ // Load QR page inside webViewContainer
35
+ if (data.checkout_qr_url) {
36
+ webViewContainer.style.display = "block";
37
+ webViewContainer.style.position = "fixed";
38
+ webViewContainer.style.top = "0";
39
+ webViewContainer.style.left = "0";
40
+ webViewContainer.style.width = "100%";
41
+ webViewContainer.style.height = "100%";
42
+ webViewContainer.style.zIndex = "9999";
43
+
44
+ const checkoutIframe = document.createElement("iframe");
45
+ checkoutIframe.src = data.checkout_qr_url;
46
+ checkoutIframe.style.width = "100%";
47
+ checkoutIframe.style.height = "100%";
48
+ checkoutIframe.style.border = "none";
49
+
50
+ webViewContainer.appendChild(checkoutIframe);
51
+ }
52
+
53
+ // Attempt ABA Deeplink (hidden iframe)
54
+ if (data.abapay_deeplink) {
55
+
56
+ const deeplinkFrame = document.createElement("iframe");
57
+ deeplinkFrame.style.display = "none";
58
+ deeplinkFrame.src = data.abapay_deeplink;
59
+ document.body.appendChild(deeplinkFrame);
60
+
61
+ // Detect if app opened
62
+ let appOpened = false;
63
+
64
+ const visibilityHandler = () => {
65
+ appOpened = true;
66
+ };
67
+
68
+ document.addEventListener("visibilitychange", visibilityHandler);
69
+
70
+ setTimeout(() => {
71
+ document.removeEventListener("visibilitychange", visibilityHandler);
72
+
73
+ if (!appOpened) {
74
+ console.log("ABA app not installed, staying inside webViewContainer");
75
+ }
76
+ }, 2000);
77
+ }
78
+
79
+ if (!data.checkout_qr_url && !data.abapay_deeplink) {
80
+ console.error("Missing checkout_qr_url and abapay_deeplink", data);
81
+ }
82
+
83
+ })
84
+ .catch(err => console.error("ABA Deeplink Error:", err));
85
+
86
+ // CASE 2: Normal ABA KHQR → regular redirect form post
87
+ } else {
88
+ form.submit();
89
+ }
90
+ });
54
91
  </script>
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.2.2-pre8'.freeze
4
+ VERSION = '2.2.2-pre10'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_vpago
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2.pre.pre8
4
+ version: 2.2.2.pre.pre10
5
5
  platform: ruby
6
6
  authors:
7
7
  - You