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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/spree/vpago_payments_controller.rb +17 -0
- data/app/helpers/vpago/vpago_payments_helper.rb +4 -0
- data/app/services/vpago/payment_url_constructor.rb +9 -1
- data/app/views/spree/vpago_payments/forms/spree/gateway/_payway_v2.html.erb +30 -25
- data/app/views/spree/vpago_payments/forms/spree/gateway/_vattanac.html.erb +43 -25
- 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: d7793c0aec41fce672ee0633228351ac3aac2f42b2ddd130298796a67d1ad3f0
|
|
4
|
+
data.tar.gz: a50c7029f6a8420f60db25dccb15674f1bac7e4dad979874fbb968427f929ae1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6116d80f3f46d00c573e39fa1d57bf2c8edd5eb6e1b253244a1b40f561665b47d50b71480e063ce60fbf7f21d62e09ca0f2ce46c2962c3b330c4d8a760ad2970
|
|
7
|
+
data.tar.gz: 06d4f719cda898e6140ca8f0e449b32550540f96c4f1db3932e28924fb3e42afff25c972693f01eca0c76e841fd4462231df5d64716c34a8b530cc9959ca2e1d
|
data/Gemfile.lock
CHANGED
|
@@ -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 }
|
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
17
|
+
const form = document.getElementById("aba_merchant_request");
|
|
18
|
+
const paymentOption = form.dataset.paymentOption;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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>
|
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.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-
|
|
11
|
+
date: 2026-02-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|