Skip to content

A self-hosted UPI & COD payment gateway with zero per-transaction platform fees, universal JavaScript checkout integration, dynamic QR payments, WhatsApp OTP authentication, and automated payment verification.

JavaScript

fix(security): repair PR #17 merge conflicts without regressing existing hardening

rishabh7c84e07c94e4
diff --git a/packages/merchant-sdk/src/youpi-checkout.js b/packages/merchant-sdk/src/youpi-checkout.js
index 5ad6879..bf5abd9 100644
--- a/packages/merchant-sdk/src/youpi-checkout.js
+++ b/packages/merchant-sdk/src/youpi-checkout.js
@@ -384,7 +384,9 @@ _isSafeRedirect(url) {
*/
_checkoutOrigin() {
try {
- const url = this.options.checkoutUrl || this.options.portalUrl;
+ // Only an explicitly configured checkout URL is authoritative. `portalUrl` defaults
+ // to localhost, so including it would make this check reject legitimate messages.
+ const url = this.options.checkoutUrl;
if (url) return new URL(url, window.location.href).origin;
} catch (e) { }
return null;
diff --git a/packages/merchant-sdk/src/youpi.js b/packages/merchant-sdk/src/youpi.js
index c4077fe..430da5d 100644
--- a/packages/merchant-sdk/src/youpi.js
+++ b/packages/merchant-sdk/src/youpi.js
@@ -392,6 +392,8 @@ _isSafeRedirect(url) {
*/
_checkoutOrigin() {
try {
+ // Only an explicitly configured checkout URL is authoritative. `portalUrl` defaults
+ // to localhost, so including it would make this check reject legitimate messages.
if (this.options.checkoutUrl) return new URL(this.options.checkoutUrl, window.location.href).origin;
} catch (e) { }
return null;