This implementation provides a seamless integration between Google Pay (processed via PayPal) and HubBox's pickup point selection service, enabling customers to choose delivery to collect points directly within the Google Pay interface.

The integration consists of four primary TypeScript modules that work together to manage the payment flow and collect point selection:
main.ts: Application initialization and SDK setupgooglePayButton.ts: Core payment session management, event orchestration, and page reload logicfetchPaypal.ts: API communication layer for payment processing operations (via PayPal)buttonUtils.ts: Utility functions for HubBox widget management, building Google Pay requests, and parsing transaction infoThe system initializes a Google Pay session via the PayPal SDK. Unlike the standard flow, this implementation utilises a page reload strategy to handle the Google Pay Modal's window locking behaviour.
When a customer selects the collection point shipping option, the page reloads to close the Google Pay Modal and immediately opens the HubBox widget.
The HubBox Single Widget Manager is initialized in deferred render mode, pointing to the sandbox environment.
Trigger: Upon the page reload triggered by a user having selected to collect, the widget is injected into a custom modal overlay.
Action: Once a collect point is confirmed, the Google Pay Modal is automatically re-opened with the updated shipping address derived from the selected pickup point.
Backend Communication
The implementation communicates with the following backend endpoints:
State Management
A centralised PageState class works in tandem with browser sessionStorage to maintain the payment state.
Why sessionStorage?
sessionStorage is critical in this implementation to persist transaction data and flags across the page reload required to transition between the Google Pay Modal and the HubBox widget.
Error Handling
The implementation includes comprehensive error handling for authorisation failures and invalid transaction data.
UI Feedback
Errors are mapped to standard Google Pay PaymentAuthorizationResult objects to provide feedback within the native UI.
Debugging
Console logs track internal failures.
The environment is currently set to Sandbox mode for testing.
The HubBox Widget is configured with:
dpd_uk (DPD UK carrier)en-GB (British English)Access our collection of integration examples for leading one-click payment providers. These samples demonstrate how to pass pickup point metadata through express checkout APIs.
View GitHub Repository