spree_vpago 2.2.2.pre.pre11 → 2.2.2.pre.pre13
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 -15
- 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 +39 -81
- data/lib/spree_vpago/version.rb +1 -1
- data/lib/vpago/payway_v2/base.rb +2 -25
- 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: 8e1146678e861bc1d84d97e922fb268148a45bb605d9d14414d121428e5c2dc6
|
|
4
|
+
data.tar.gz: fa89bb5e2bfec29f04d4fa31477b6f48d4f8ed0b970faa2bd51d1e828640b87d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc6d965090f34c46547385cae293652dbc453d2f50524e58d9320aa16bd85b3d8d9cb2e5a8ec8c496867377e133d9dbbbc99b1fa15a988dc6ead8da0a82e08e3
|
|
7
|
+
data.tar.gz: e1c7d30ac4be2adb539b1476c1f1d3aa9fdcd1e3650e09c333f617d463909c3986e2db43f48843e9db5eee17eb464b5a58d2fa68c81d5e0d664bb5ad55cf83e3
|
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.pre13)
|
|
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,15 +79,6 @@ module Spree
|
|
|
85
79
|
sanitized_params
|
|
86
80
|
end
|
|
87
81
|
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
def in_app_browser?
|
|
91
|
-
in_app_browsers = %w[FBAN FBAV Telegram FB_Messenger Messenger]
|
|
92
|
-
user_agent = request.user_agent.to_s
|
|
93
|
-
|
|
94
|
-
in_app_browsers.any? { |browser| user_agent.include?(browser) }
|
|
95
|
-
end
|
|
96
|
-
|
|
97
82
|
def render_not_found
|
|
98
83
|
respond_to do |format|
|
|
99
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,93 +1,51 @@
|
|
|
1
|
-
<% @checkout = ::Vpago::PaywayV2::Checkout.new(@payment
|
|
2
|
-
<% payment_option = @payment.payment_method.preferences[:payment_option] %>
|
|
1
|
+
<% @checkout = ::Vpago::PaywayV2::Checkout.new(@payment) %>
|
|
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 %>">
|
|
12
12
|
<% end %>
|
|
13
13
|
</form>
|
|
14
14
|
|
|
15
|
-
<!-- WebView Container -->
|
|
16
|
-
<div id="webViewContainer" style="display:none;"></div>
|
|
17
|
-
|
|
18
15
|
<script>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const checkoutIframe = document.createElement("iframe");
|
|
49
|
-
checkoutIframe.src = data.checkout_qr_url;
|
|
50
|
-
checkoutIframe.style.width = "100%";
|
|
51
|
-
checkoutIframe.style.height = "100%";
|
|
52
|
-
checkoutIframe.style.border = "none";
|
|
53
|
-
|
|
54
|
-
webViewContainer.appendChild(checkoutIframe);
|
|
55
|
-
|
|
56
|
-
// WAIT until checkout fully loads
|
|
57
|
-
checkoutIframe.onload = function () {
|
|
58
|
-
|
|
59
|
-
if (!data.abapay_deeplink) return;
|
|
60
|
-
|
|
61
|
-
console.log("Checkout loaded, attempting ABA deeplink...");
|
|
62
|
-
|
|
63
|
-
const deeplinkFrame = document.createElement("iframe");
|
|
64
|
-
deeplinkFrame.style.display = "none";
|
|
65
|
-
deeplinkFrame.src = data.abapay_deeplink;
|
|
66
|
-
document.body.appendChild(deeplinkFrame);
|
|
67
|
-
|
|
68
|
-
// Detect if user leaves browser (app opened)
|
|
69
|
-
let appOpened = false;
|
|
70
|
-
|
|
71
|
-
const visibilityHandler = () => {
|
|
72
|
-
appOpened = true;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
document.addEventListener("visibilitychange", visibilityHandler);
|
|
76
|
-
|
|
77
|
-
setTimeout(() => {
|
|
78
|
-
document.removeEventListener("visibilitychange", visibilityHandler);
|
|
79
|
-
|
|
80
|
-
if (!appOpened) {
|
|
81
|
-
console.log("ABA app not installed, staying on checkout page.");
|
|
82
|
-
}
|
|
83
|
-
}, 2000);
|
|
84
|
-
};
|
|
85
|
-
})
|
|
86
|
-
.catch(err => console.error("ABA Deeplink Error:", err));
|
|
87
|
-
|
|
88
|
-
// CASE 2: Normal ABA KHQR → regular redirect form post
|
|
89
|
-
} else {
|
|
16
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
17
|
+
const form = document.getElementById("aba_merchant_request");
|
|
18
|
+
const paymentOption = form.dataset.paymentOption;
|
|
19
|
+
|
|
20
|
+
if (paymentOption === "abapay_khqr_deeplink") {
|
|
21
|
+
|
|
22
|
+
fetch(form.action, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
body: new FormData(form)
|
|
25
|
+
})
|
|
26
|
+
.then(res => res.json())
|
|
27
|
+
.then(data => {
|
|
28
|
+
|
|
29
|
+
if (!data.checkout_qr_url && !data.abapay_deeplink) {
|
|
30
|
+
throw new Error("Missing payment URLs");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (data.checkout_qr_url) {
|
|
34
|
+
window.open(data.checkout_qr_url, "_blank");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (data.abapay_deeplink) {
|
|
38
|
+
window.location.href = data.abapay_deeplink;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
})
|
|
42
|
+
.catch(err => {
|
|
43
|
+
console.error("Error:", err);
|
|
90
44
|
form.submit();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
} else {
|
|
48
|
+
form.submit();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
</script>
|
data/lib/spree_vpago/version.rb
CHANGED
data/lib/vpago/payway_v2/base.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
module Vpago
|
|
2
2
|
module PaywayV2
|
|
3
3
|
class Base
|
|
4
|
-
def initialize(payment,
|
|
4
|
+
def initialize(payment, options = {})
|
|
5
5
|
@options = options
|
|
6
6
|
@payment = payment
|
|
7
|
-
@user_agent = user_agent
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def req_time
|
|
@@ -113,32 +112,10 @@ module Vpago
|
|
|
113
112
|
uri.scheme = app_scheme
|
|
114
113
|
uri.to_s
|
|
115
114
|
else
|
|
116
|
-
|
|
117
|
-
if in_app_browser_payment?
|
|
118
|
-
case @user_agent
|
|
119
|
-
when /FBAN|FBAV/
|
|
120
|
-
'fb://'
|
|
121
|
-
when /Telegram/
|
|
122
|
-
'tg://'
|
|
123
|
-
when /FB_Messenger|Messenger/
|
|
124
|
-
'fb-messenger://'
|
|
125
|
-
else
|
|
126
|
-
continue_success_url
|
|
127
|
-
end
|
|
128
|
-
else
|
|
129
|
-
continue_success_url
|
|
130
|
-
end
|
|
115
|
+
continue_success_url
|
|
131
116
|
end
|
|
132
117
|
end
|
|
133
118
|
|
|
134
|
-
# Check if payment is from in-app browser
|
|
135
|
-
def in_app_browser_payment?
|
|
136
|
-
return false unless @user_agent.present?
|
|
137
|
-
|
|
138
|
-
in_app_browsers = %w[FBAN FBAV Telegram FB_Messenger Messenger]
|
|
139
|
-
in_app_browsers.any? { |browser| @user_agent.include?(browser) }
|
|
140
|
-
end
|
|
141
|
-
|
|
142
119
|
def return_deeplink
|
|
143
120
|
return nil unless return_deeplink_url.present?
|
|
144
121
|
|
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.pre13
|
|
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-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|