Skip to content

Commit d38977f

Browse files
committed
use a fresh redirect URL so the JS does not rely on
the potentially stale shopThankYouPageUrl from the initial page render
1 parent 7606f29 commit d38977f

8 files changed

Lines changed: 27 additions & 22 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- [0007916](https://bugs.oxid-esales.com/view.php?id=7916): Fix root cause of `sess_challenge` being cleared during active capture. `Payment::removeTemporaryOrder()` unconditionally deleted `sess_challenge` even when the cancel was blocked because PayPal had already approved/captured the payment. Now `sess_challenge` is only deleted when the cancel actually succeeds, keeping the session intact for the concurrent capture flow.
1616
- [0007916](https://bugs.oxid-esales.com/view.php?id=7916): Add database fallback for shop order resolution in `AjaxPaymentController::captureOrder()`. If `sess_challenge` is missing, the shop order is now resolved via the persisted `oscpaypal_order` relationship using the PayPal order ID. Additionally rejects cancelled (storno) orders to prevent tracking against invalidated shop orders.
1717
- [0007916](https://bugs.oxid-esales.com/view.php?id=7916): Fix PayPal capture executed before storno check in `AjaxPaymentController::captureOrder()`. The PayPal capture API call was made before validating whether the shop order had been cancelled, allowing funds to be captured for stornoed orders. Moved order resolution and storno check before the `capturePaymentForOrder()` call so that cancelled orders are rejected without contacting the PayPal API.
18+
- [0007916](https://bugs.oxid-esales.com/view.php?id=7916): Fix redirect to start page instead of thank-you page when the customer retries PayPal payment without reloading the checkout page. The `shopThankYouPageUrl` in the JS config was baked in at initial page render and became stale on retry. `captureOrder()` and `authorizePayment()` now return a fresh `redirectUrl` in the success response. `thankYouPageRedirect()` accepts an optional URL parameter and prefers the server-provided URL over the cached config value. Also consolidated all direct `window.location` assignments in the ACDC controller to use `thankYouPageRedirect()` so that `removeBeforeUnloadListener()` is called consistently before every redirect.
1819
- Fix duplicate order creation for stock-1 articles during PayPal checkout. After the AJAX `captureOrder()` flow completed, `PayPalOrderCompletedSubscriber` cleaned up the PayPal session (`PayPalSession::unsetPayPalSession()`). When the browser then redirected to the order confirmation page, `Order::finalizeOrder()` was called again. Because the PayPal session was already cleared, `isOrderExecutionInProgress()` returned false and the webhook-wait guard did not trigger — causing `parent::finalizeOrder()` to create a second shop order that failed stock validation. Added a guard in `Order::finalizeOrder()` that detects already-paid orders (via `isOrderPaid()` + `oxtransid`) and returns early without creating a duplicate.
1920
- [0007917](https://bugs.oxid-esales.com/view.php?id=7917): Fix tracking carrier country not restored on page reload. When a carrier from the "global" country group was saved, the country dropdown was reset to the order's shipping/billing country instead. Added `getCountryCodeByCarrierKey()` to `PayPalTrackingCarrierList` and `getEffectiveTrackingCountryCode()` to `OrderMain` to resolve the saved carrier's country and pre-select it in the dropdown.
2021

assets/src/js/paypal-frontend.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
'en' => 'Use of the online payment service from PayPal. Documentation: <a href="https://docs.oxid-esales.com/modules/paypal-checkout/en/latest/" target="_blank">PayPal Checkout</a>'
6969
],
7070
'thumbnail' => 'img/paypal.png',
71-
'version' => '3.7.2-rc.4',
71+
'version' => '3.7.2-rc.5',
7272
'author' => 'OXID eSales AG',
7373
'url' => 'https://www.oxid-esales.com',
7474
'email' => 'info@oxid-esales.com',

package-lock.json

Lines changed: 3 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/build/js/paypal-frontend-acdc-payment-controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
return false;
5555
}
5656

57-
window.location = PayPalPayment.getConfigValue('shopThankYouPageUrl');
57+
PayPalPayment.thankYouPageRedirect();
5858
}
5959

6060
if (result.payPalOrder.status === 'PAYER_ACTION_REQUIRED' || result.payPalOrder.status === 'APPROVED' ){
@@ -92,7 +92,7 @@
9292
};
9393

9494
this.afterCaptureOrder = function (details) {
95-
window.location = PayPalPayment.getConfigValue('shopThankYouPageUrl');
95+
PayPalPayment.thankYouPageRedirect();
9696
};
9797

9898
this.isCardFieldInvalid = function (name)

resources/build/js/paypal-frontend-payment-controller-base.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@
139139
});
140140
};
141141

142-
this.thankYouPageRedirect = async function () {
142+
this.thankYouPageRedirect = async function (redirectUrl) {
143143
PayPalPayment.removeBeforeUnloadListener();
144-
window.location = PayPalPayment.getConfigValue('shopThankYouPageUrl');
144+
window.location = redirectUrl || PayPalPayment.getConfigValue('shopThankYouPageUrl');
145145
};
146146

147147
this.handlePaymentAuthorization = async function (details) {
@@ -160,7 +160,7 @@
160160
const result = await PayPalPayment.authorizeOrder(paypalOrderDetails);
161161

162162
if (result.paymentStatus === 'success' ){
163-
window.location = PayPalPayment.getConfigValue('shopThankYouPageUrl');
163+
PayPalPayment.thankYouPageRedirect(result.redirectUrl);
164164
return;
165165
}
166166

resources/build/js/paypal-frontend-standard-payment-controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
});
108108

109109
if (result.paymentStatus === 'success') {
110-
PayPalPayment.thankYouPageRedirect();
110+
PayPalPayment.thankYouPageRedirect(result.redirectUrl);
111111
}
112112
};
113113

src/Controller/AjaxPaymentController.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ public function captureOrder(): void
348348
if ($capturePaymentForOrder) {
349349
$response['paymentStatus'] = $capturePaymentForOrder->getCapturePaymentStatus() ? 'success' : 'error';
350350
}
351+
352+
// Provide a fresh redirect URL so the JS does not rely on
353+
// the potentially stale shopThankYouPageUrl from the initial
354+
// page render (important when the user retries without F5).
355+
$config = Registry::getConfig();
356+
$session = Registry::getSession();
357+
$stoken = $session->getSessionChallengeToken();
358+
$response['redirectUrl'] = $config->getSslShopUrl()
359+
. 'index.php?cl=thankyou&stoken=' . $stoken;
351360
}
352361

353362
if ($response['paymentStatus'] === 'error') {
@@ -775,9 +784,14 @@ public function authorizePayment(): void
775784
$completeOrderResult = $this->completeOrder(false);
776785

777786
if ($completeOrderResult["status"] === 'success') {
787+
$config = Registry::getConfig();
788+
$session = Registry::getSession();
789+
$stoken = $session->getSessionChallengeToken();
778790
$this->outputJson([
779791
'status' => 'success',
780-
'paymentStatus' => $authorizePaymentResult["paymentStatus"]
792+
'paymentStatus' => $authorizePaymentResult["paymentStatus"],
793+
'redirectUrl' => $config->getSslShopUrl()
794+
. 'index.php?cl=thankyou&stoken=' . $stoken,
781795
]);
782796
}
783797
}

0 commit comments

Comments
 (0)