/** * Wrapper around the Airwallex redirect-page query string. * * The mapping between business concepts (order key, order id, intent id) * and query parameter names lives in this one place, so a rename or a * compat fallback touches this class instead of every call site. * * Usage: * const redirectUrl = RedirectUrl.from(window.location.search); * const orderKey = redirectUrl.orderKey(); */ export class RedirectUrl { private constructor(private readonly params: URLSearchParams) {} static from(search: string): RedirectUrl { return new RedirectUrl(new URLSearchParams(search)); } /** * WooCommerce order key, sent as `order_ref` on redirect-page and * confirmation URLs. Falls back to the legacy `key` parameter so * return URLs generated before the rename keep working. */ orderKey(): string { return this.params.get('order_ref') || this.params.get('key') || ''; } orderId(): string { return this.params.get('order_id') || ''; } intentId(): string { return this.params.get('intent_id') || ''; } }