spree_vpago 2.2.2.pre.pre10 → 2.2.2.pre.pre12
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 +4 -4
- data/Gemfile.lock +2 -2
- data/app/controllers/spree/vpago_payments_controller.rb +0 -17
- data/app/helpers/vpago/vpago_payments_helper.rb +0 -4
- data/app/services/vpago/payment_url_constructor.rb +1 -9
- data/app/views/spree/vpago_payments/forms/spree/gateway/_payway_v2.html.erb +57 -36
- data/app/views/spree/vpago_payments/forms/spree/gateway/_vattanac.html.erb +25 -43
- data/lib/spree_vpago/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d5ee57baf6e2451847466adba567cf8922799e54575e0aa690758416ad14ed1
|
|
4
|
+
data.tar.gz: 2998d1e7883e8c1bd041bc2eb9abc4c8f3dcb45ee21a3c8d6958c838ffa57bfa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4fac23a6529811d3fc71c6ac9128a2c2c93fad05cc3bab1e09878d7d9ccc67ecb4482075893162ce1568524ab364dc6c7bc763c2c56615122083c74dc4d21d3
|
|
7
|
+
data.tar.gz: 75f328a206a6a6deeb0a62d3bc41286188ebc931c36299ac35b07bc9e0a087d6631fb1c6615d9ef8f5b50fda2c187c4fdcae63fd6a30c0358b9bc7d20f3d292e
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
spree_vpago (2.2.2.pre.
|
|
4
|
+
spree_vpago (2.2.2.pre.pre12)
|
|
5
5
|
faraday
|
|
6
6
|
google-cloud-firestore
|
|
7
7
|
spree_api (>= 4.5)
|
|
@@ -259,7 +259,7 @@ GEM
|
|
|
259
259
|
multi_json (~> 1.11)
|
|
260
260
|
os (>= 0.9, < 2.0)
|
|
261
261
|
signet (>= 0.16, < 2.a)
|
|
262
|
-
grpc (1.78.
|
|
262
|
+
grpc (1.78.1)
|
|
263
263
|
google-protobuf (>= 3.25, < 5.0)
|
|
264
264
|
googleapis-common-protos-types (~> 1.0)
|
|
265
265
|
hashdiff (1.1.0)
|
|
@@ -16,12 +16,6 @@ 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?)
|
|
25
19
|
end
|
|
26
20
|
|
|
27
21
|
# GET
|
|
@@ -85,17 +79,6 @@ module Spree
|
|
|
85
79
|
sanitized_params
|
|
86
80
|
end
|
|
87
81
|
|
|
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
|
-
|
|
99
82
|
def render_not_found
|
|
100
83
|
respond_to do |format|
|
|
101
84
|
format.html { render file: Rails.public_path.join('404.html'), status: :not_found, layout: false }
|
|
@@ -24,8 +24,7 @@ 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
|
|
28
|
-
check_in_app_browser: aba_khqr_payment? ? true : nil
|
|
27
|
+
offsite_payment: offsite_payment? ? true : nil
|
|
29
28
|
}.compact.to_query
|
|
30
29
|
end
|
|
31
30
|
|
|
@@ -34,13 +33,6 @@ module Vpago
|
|
|
34
33
|
payment.payment_method.type_true_money?
|
|
35
34
|
end
|
|
36
35
|
|
|
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
|
-
|
|
44
36
|
private
|
|
45
37
|
|
|
46
38
|
def app_scheme
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<% @checkout = ::Vpago::PaywayV2::Checkout.new(@payment) %>
|
|
2
|
-
<% payment_option = @payment.payment_method.preferences[:payment_option] %>
|
|
2
|
+
<% @payment_option = @payment.payment_method.preferences[:payment_option] %>
|
|
3
3
|
|
|
4
4
|
<form method="POST"
|
|
5
5
|
action="<%= @checkout.checkout_url %>"
|
|
6
6
|
id="aba_merchant_request"
|
|
7
|
-
data-payment-option="<%= payment_option %>"
|
|
8
|
-
style="<%= 'display:none;' if payment_option == 'abapay_khqr_deeplink' %>">
|
|
7
|
+
data-payment-option="<%= @payment_option %>"
|
|
8
|
+
style="<%= 'display:none;' if @payment_option == 'abapay_khqr_deeplink' %>">
|
|
9
9
|
|
|
10
10
|
<% @checkout.gateway_params.each do |key, value| %>
|
|
11
11
|
<input type="hidden" name="<%= key %>" value="<%= value %>">
|
|
@@ -21,18 +21,37 @@
|
|
|
21
21
|
const paymentOption = form.dataset.paymentOption;
|
|
22
22
|
const webViewContainer = document.getElementById("webViewContainer");
|
|
23
23
|
|
|
24
|
-
// CASE 1: ABA KHQR Deeplink → fetch JSON then
|
|
25
|
-
if
|
|
24
|
+
// CASE 1: ABA KHQR Deeplink → fetch JSON then render checkout + optional deeplink
|
|
25
|
+
// 1. Check if response is OK and has JSON content
|
|
26
|
+
// 2. Validate required fields
|
|
27
|
+
// 3. WAIT until checkout fully loads before attempting deeplink
|
|
28
|
+
// 4. Detect if user leaves browser (app opened)
|
|
29
|
+
// 5. Fallback: show form and submit normally
|
|
26
30
|
|
|
31
|
+
if (paymentOption === "abapay_khqr_deeplink") {
|
|
27
32
|
fetch(form.action, {
|
|
28
33
|
method: "POST",
|
|
29
34
|
body: new FormData(form)
|
|
30
35
|
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
.then(res => {
|
|
37
|
+
if (!res.ok) {
|
|
38
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const contentType = res.headers.get("content-type");
|
|
42
|
+
if (!contentType || !contentType.includes("application/json")) {
|
|
43
|
+
throw new Error("Response is not JSON");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return res.json();
|
|
47
|
+
})
|
|
48
|
+
.then(data => {
|
|
49
|
+
// Validate required fields
|
|
50
|
+
if (!data.checkout_qr_url && !data.abapay_deeplink) {
|
|
51
|
+
throw new Error("Missing checkout_qr_url and abapay_deeplink");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Setup container as full-screen overlay
|
|
36
55
|
webViewContainer.style.display = "block";
|
|
37
56
|
webViewContainer.style.position = "fixed";
|
|
38
57
|
webViewContainer.style.top = "0";
|
|
@@ -40,6 +59,7 @@
|
|
|
40
59
|
webViewContainer.style.width = "100%";
|
|
41
60
|
webViewContainer.style.height = "100%";
|
|
42
61
|
webViewContainer.style.zIndex = "9999";
|
|
62
|
+
webViewContainer.style.backgroundColor = "#fff";
|
|
43
63
|
|
|
44
64
|
const checkoutIframe = document.createElement("iframe");
|
|
45
65
|
checkoutIframe.src = data.checkout_qr_url;
|
|
@@ -48,40 +68,41 @@
|
|
|
48
68
|
checkoutIframe.style.border = "none";
|
|
49
69
|
|
|
50
70
|
webViewContainer.appendChild(checkoutIframe);
|
|
51
|
-
}
|
|
52
71
|
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
checkoutIframe.onload = function () {
|
|
73
|
+
if (!data.abapay_deeplink) return;
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
deeplinkFrame.style.display = "none";
|
|
58
|
-
deeplinkFrame.src = data.abapay_deeplink;
|
|
59
|
-
document.body.appendChild(deeplinkFrame);
|
|
75
|
+
console.log("Checkout loaded, attempting ABA deeplink...");
|
|
60
76
|
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
const deeplinkFrame = document.createElement("iframe");
|
|
78
|
+
deeplinkFrame.style.display = "none";
|
|
79
|
+
deeplinkFrame.src = data.abapay_deeplink;
|
|
80
|
+
document.body.appendChild(deeplinkFrame);
|
|
63
81
|
|
|
64
|
-
|
|
65
|
-
appOpened = true;
|
|
66
|
-
};
|
|
82
|
+
let appOpened = false;
|
|
67
83
|
|
|
68
|
-
|
|
84
|
+
const visibilityHandler = () => {
|
|
85
|
+
appOpened = true;
|
|
86
|
+
};
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
document.removeEventListener("visibilitychange", visibilityHandler);
|
|
88
|
+
document.addEventListener("visibilitychange", visibilityHandler);
|
|
72
89
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
}, 2000);
|
|
77
|
-
}
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
document.removeEventListener("visibilitychange", visibilityHandler);
|
|
78
92
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
if (!appOpened) {
|
|
94
|
+
console.log("ABA app not installed, staying on checkout page.");
|
|
95
|
+
}
|
|
96
|
+
}, 2000);
|
|
97
|
+
};
|
|
98
|
+
})
|
|
99
|
+
.catch(err => {
|
|
100
|
+
console.error("ABA Deeplink Error:", err);
|
|
101
|
+
console.log("Falling back to regular form submission...");
|
|
102
|
+
|
|
103
|
+
form.style.display = "block";
|
|
104
|
+
form.submit();
|
|
105
|
+
});
|
|
85
106
|
|
|
86
107
|
// CASE 2: Normal ABA KHQR → regular redirect form post
|
|
87
108
|
} else {
|
|
@@ -8,50 +8,32 @@ 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)
|
|
13
11
|
%>
|
|
14
12
|
|
|
15
13
|
<script>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
});
|
|
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
|
+
}
|
|
57
39
|
</script>
|
data/lib/spree_vpago/version.rb
CHANGED
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.
|
|
4
|
+
version: 2.2.2.pre.pre12
|
|
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-
|
|
11
|
+
date: 2026-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|