spree_vpago 2.2.2.pre.pre20 → 2.2.2.pre.pre21

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: 821936697cd70f073c9e150a8ad0158f9f14c61ced8298678f29e34705def9b6
4
- data.tar.gz: 959d5f7ab9e0cb76af94dd105678cc6ac78309fb91e19158208e67b2dd8a195b
3
+ metadata.gz: '05536639cc3731496d0e01bd7ecccb56062d2b412ca795b7a924deac49c9c9a5'
4
+ data.tar.gz: f2dbe115e30add8edc1188b3c8a8ae855235d88197d45683615cb5dbe4b17445
5
5
  SHA512:
6
- metadata.gz: d6b7fecf9f5c79916b72d08847e00d304945f4f9d551cf721128c7f898ba261f8961810d14ee0a6e586c3b0515073d6d17d41cfa3fbad75d4add051f16e75875
7
- data.tar.gz: 918543e674ec44b62aa0e7a86df7c94393f472967c166f4d3e6c88a78c71969dbc64a0dd49a6ff6f5ffea430467f76354a1dfec767c535aee48a40b42b3179a8
6
+ metadata.gz: 43688b89eab0f758808875722761c47b35d460c2c76501b3ff0218ea25b60d2b7859183cf4733a66704ae0f10b72b4f7bc9a75a6b1e97a1139f893c08b5cf008
7
+ data.tar.gz: 5642262ac80774489724678f53fb027e09c2257dbed79ae9fa32c3cf9f806baee60315120053f97feb272779d8fda1b3497c4cdf7e0941e1c9c9dbffbd838012
data/.env.example CHANGED
@@ -1,7 +1,3 @@
1
- #pre-auth
2
- PAYWAY_V2_PRE_AUTH_COMPLETE_PATH=""
3
- PAYWAY_V2_PRE_AUTH_CANCEL_PATH=""
4
-
5
1
  #vattanac-mini-app
6
2
  VATTANAC_PUBLIC_KEY=""
7
3
  VATTANAC_AES_SECRET_KEY=""
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.2.2.pre.pre20)
4
+ spree_vpago (2.2.2.pre.pre21)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
data/README.md CHANGED
@@ -95,14 +95,6 @@ ENV configuration:
95
95
 
96
96
  ```ruby
97
97
  ENV['PAYWAY_MERCHANT_PROFILE_CONTENT_TYPE'] # html, json
98
- ENV['PAYWAY_CHECKOUT_PATH']
99
- ENV['PAYWAY_CHECK_TRANSACTION_PATH']
100
- ENV['PAYWAY_RETURN_CALLBACK_URL']
101
- ENV['PAYWAY_CONTINUE_SUCCESS_CALLBACK_URL']
102
-
103
- #pre-auth
104
- ENV['PAYWAY_V2_PRE_AUTH_COMPLETE_PATH']
105
- ENV['PAYWAY_V2_PRE_AUTH_CANCEL_PATH']
106
98
  ```
107
99
 
108
100
  Payment method configuration:
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Polls the transaction status endpoint until the payment succeeds, fails, or
3
+ * the maximum polling duration is reached.
4
+ *
5
+ * @param {Object} options
6
+ * @param {string} options.checkTransactionUrl
7
+ * @param {Function} options.onSuccess
8
+ * @param {Function} options.onFailure
9
+ */
10
+ async function checkTransactionPeriodically({
11
+ checkTransactionUrl,
12
+ onSuccess,
13
+ onFailure,
14
+ }) {
15
+ var pollIntervalMs = 5000;
16
+ var maxDurationMs = 10 * 60 * 1000;
17
+ var shouldPoll = true;
18
+ var intervalId;
19
+ var startTime = Date.now();
20
+
21
+ var pollStatus = function () {
22
+ if (shouldPoll) return;
23
+
24
+ if (Date.now() - startTime >= maxDurationMs) {
25
+ if (intervalId) clearInterval(intervalId);
26
+ return;
27
+ }
28
+
29
+ fetch(checkTransactionUrl, {
30
+ method: "GET",
31
+ headers: { Accept: "application/json" },
32
+ credentials: "same-origin",
33
+ })
34
+ .then(function (response) {
35
+ return response.json().then(function (body) {
36
+ return { ok: response.ok, body: body };
37
+ });
38
+ })
39
+ .then(function (result) {
40
+ var status =
41
+ result.body && result.body.status
42
+ ? String(result.body.status)
43
+ : "pending";
44
+
45
+ if (status === "success" || status === "failed") {
46
+ shouldPoll = false;
47
+ if (intervalId) clearInterval(intervalId);
48
+
49
+ if (status === "success") onSuccess(status);
50
+ if (status === "failed") onFailure(status);
51
+ }
52
+ })
53
+ .catch(function () {});
54
+ };
55
+
56
+ intervalId = window.setInterval(pollStatus, pollIntervalMs);
57
+ }
58
+
59
+ window.checkTransactionPeriodically = checkTransactionPeriodically;
@@ -8,7 +8,7 @@
8
8
  <%= csrf_meta_tags %>
9
9
  <%= csp_meta_tag %>
10
10
 
11
- <%= javascript_include_tag "vpago/vpago_payments/payment_processing_listener", 'data-turbo-track': 'reload' %>
11
+ <%= javascript_include_tag "vpago/vpago_payments/check_transaction_periodically", 'data-turbo-track': 'reload' %>
12
12
  <%= javascript_include_tag "vpago/vpago_payments/request_process_payment", 'data-turbo-track': 'reload' %>
13
13
  <%= javascript_include_tag "vpago/vpago_payments/user_informers/#{user_informer}", 'data-turbo-track': 'reload' %>
14
14
  </head>
@@ -1,40 +1,10 @@
1
- <%# This partial listens to payment status changes from bank and does not process the payment. %>
2
- <%# When it detects a status change, it automatically redirects to the processing URL for actual processing. %>
3
- <%# Designed to be used in checkout.html.erb %>
4
-
5
1
  <script>
6
2
  document.addEventListener("DOMContentLoaded", function() {
7
- var checkTransactionUrl = "<%= j @payment.check_transaction_url %>";
8
- var processingUrl = "<%= j @payment.processing_url %>";
9
- var pollIntervalMs = 5000;
10
- var hasRedirected = false;
11
- var intervalId;
12
-
13
- var pollStatus = function() {
14
- if (hasRedirected) return;
15
-
16
- fetch(checkTransactionUrl, {
17
- method: "GET",
18
- headers: { "Accept": "application/json" },
19
- credentials: "same-origin"
20
- })
21
- .then(function(response) {
22
- return response.json().then(function(body) {
23
- return { ok: response.ok, body: body };
24
- });
25
- })
26
- .then(function(result) {
27
- var status = result.body && result.body.status ? String(result.body.status) : "pending";
28
-
29
- if (status === "success" || status === "failed") {
30
- hasRedirected = true;
31
- if (intervalId) clearInterval(intervalId);
32
- window.location.replace(processingUrl);
33
- }
34
- })
35
- .catch(function() {});
36
- };
37
-
38
- intervalId = window.setInterval(pollStatus, pollIntervalMs);
3
+ var processingUrl = "<%= raw @payment.processing_url %>";
4
+ window.checkTransactionPeriodically({
5
+ checkTransactionUrl: "<%= raw @payment.check_transaction_url %>",
6
+ onFailure: () => window.location.replace(processingUrl),
7
+ onSuccess: () => window.location.replace(processingUrl),
8
+ });
39
9
  });
40
- </script>
10
+ </script>
@@ -14,6 +14,26 @@
14
14
  retryDelayMs: 1000,
15
15
  })
16
16
 
17
+ // This block in /processing is purely JUST for review/audit purposes (ABA requirement).
18
+ // It checks the bank transaction status periodically without actually
19
+ // triggering payment processing again. By the time the user lands
20
+ // on this page, the transaction is normally complete or failed.
21
+ //
22
+ // What it does:
23
+ // 1. Logs or updates the UI with transaction status for review.
24
+ // 2. Provides reassurance that the bank transaction was confirmed.
25
+ // 3. Optionally, could allow a manual retry button if needed.
26
+ //
27
+ // What it does NOT do:
28
+ // - It does NOT call requestProcessPayment again (payment job is
29
+ // already unique and idempotent elsewhere).
30
+ // - It does NOT retry processing unnecessarily.
31
+ window.checkTransactionPeriodically({
32
+ checkTransactionUrl: "<%= raw @payment.check_transaction_url %>",
33
+ onFailure: () => console.log("Bank transaction failed"),
34
+ onSuccess: () => console.log("Bank transaction confirmed"),
35
+ })
36
+
17
37
  window.listenToProcessingState({
18
38
  firebaseConfigs: firebaseConfigs,
19
39
  documentReferencePath: "<%= payment.user_informer.document_reference_path %>",
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.2.2-pre20'.freeze
4
+ VERSION = '2.2.2-pre21'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
@@ -27,7 +27,7 @@ module Vpago
27
27
  end
28
28
 
29
29
  def checkout_url
30
- "#{host}#{ENV.fetch('PAYWAY_CHECKOUT_PATH', nil)}"
30
+ "#{host}/api/payment-gateway/v1/payments/purchase"
31
31
  end
32
32
 
33
33
  alias action_url checkout_url
@@ -36,7 +36,7 @@ module Vpago
36
36
  end
37
37
 
38
38
  def cancel_url
39
- "#{host}#{ENV.fetch('PAYWAY_V2_PRE_AUTH_CANCEL_PATH')}"
39
+ "#{host}/api/merchant-portal/merchant-access/online-transaction/pre-auth-cancellation"
40
40
  end
41
41
  end
42
42
  end
@@ -58,7 +58,7 @@ module Vpago
58
58
  end
59
59
 
60
60
  def complete_url
61
- "#{host}#{ENV.fetch('PAYWAY_V2_PRE_AUTH_COMPLETE_PATH')}"
61
+ "#{host}/api/merchant-portal/merchant-access/online-transaction/pre-auth-completion"
62
62
  end
63
63
 
64
64
  def success?
@@ -76,9 +76,9 @@ module Vpago
76
76
  # somehow php counter part are not able to decode if the \n present.
77
77
  hash.delete("\n")
78
78
  end
79
-
79
+
80
80
  def check_transaction_url
81
- "#{host}#{ENV.fetch('PAYWAY_CHECK_TRANSACTION_PATH', nil)}"
81
+ "#{host}/api/payment-gateway/v1/payments/check-transaction-2"
82
82
  end
83
83
  end
84
84
  end
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.pre20
4
+ version: 2.2.2.pre.pre21
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
@@ -146,7 +146,7 @@ files:
146
146
  - app/assets/images/payment_logos/wingpay.png
147
147
  - app/assets/images/vpago/payway/abapay.png
148
148
  - app/assets/images/vpago/payway/cards.png
149
- - app/assets/javascripts/vpago/vpago_payments/payment_processing_listener.js
149
+ - app/assets/javascripts/vpago/vpago_payments/check_transaction_periodically.js
150
150
  - app/assets/javascripts/vpago/vpago_payments/request_process_payment.js
151
151
  - app/assets/javascripts/vpago/vpago_payments/user_informers/firebase.js
152
152
  - app/controllers/.gitkeep
@@ -1,95 +0,0 @@
1
- window.initPaymentProcessingListener = async function (
2
- firebaseConfigs,
3
- documentReferencePath,
4
- successUrl
5
- ) {
6
- function log(status, processing, reasonCode, reasonMessage) {
7
- console.log(`Status: ${status}`);
8
- console.log(`Reason Code: ${reasonCode}`);
9
- console.log(
10
- `Processing: ${processing ? "Processing..." : "No more process."}`
11
- );
12
- console.log(`Reason Message: ${reasonMessage}`);
13
- }
14
-
15
- window.listenToProcessingState({
16
- firebaseConfigs,
17
- documentReferencePath,
18
-
19
- onPaymentIsProcessing(
20
- orderState,
21
- paymentState,
22
- processing,
23
- reasonCode,
24
- reasonMessage
25
- ) {
26
- log("Payment is processing", processing, reasonCode, reasonMessage);
27
- },
28
-
29
- onPaymentIsRetrying(
30
- orderState,
31
- paymentState,
32
- processing,
33
- reasonCode,
34
- reasonMessage
35
- ) {
36
- log("Payment is retrying", processing, reasonCode, reasonMessage);
37
- },
38
-
39
- onOrderIsProcessing(
40
- orderState,
41
- paymentState,
42
- processing,
43
- reasonCode,
44
- reasonMessage
45
- ) {
46
- log("Order is processing", processing, reasonCode, reasonMessage);
47
- },
48
-
49
- onOrderIsCompleted(
50
- orderState,
51
- paymentState,
52
- processing,
53
- reasonCode,
54
- reasonMessage
55
- ) {
56
- log("Order is completed", processing, reasonCode, reasonMessage);
57
- },
58
-
59
- onOrderProcessFailed(
60
- orderState,
61
- paymentState,
62
- processing,
63
- reasonCode,
64
- reasonMessage
65
- ) {
66
- log("Order process failed", processing, reasonCode, reasonMessage);
67
- },
68
-
69
- onPaymentProcessFailed(
70
- orderState,
71
- paymentState,
72
- processing,
73
- reasonCode,
74
- reasonMessage
75
- ) {
76
- log("Payment process failed", processing, reasonCode, reasonMessage);
77
- },
78
-
79
- onCompleted(
80
- orderState,
81
- paymentState,
82
- processing,
83
- reasonCode,
84
- reasonMessage
85
- ) {
86
- log(
87
- "Completed — redirecting to success URL",
88
- processing,
89
- reasonCode,
90
- reasonMessage
91
- );
92
- window.location.href = successUrl;
93
- },
94
- });
95
- };