Add the bank selection iframe alongside Stripe and wire up mutual exclusion
After creating a payment request, embed the Quidkey bank selection iframe on your checkout page alongside your existing Stripe Payment Element. Customers choose between Stripe or Quidkey, and you route the payment based on their selection.
Add the iframe using the payment_token from the create step. Place it near your Stripe Payment Element so customers see both options. If the Quidkey API call fails, keep your page in its default Stripe-only state.
Your existing PaymentIntent creation stays exactly as it is. As long as you already render a single Stripe Payment Element, no backend changes are required.
The key behavior is ensuring only one payment method (Stripe or Quidkey) is active at a time. Listen for postMessage events from the iframe to track the customer’s bank selection, and collapse the Stripe Payment Element when Quidkey is active.
// Track which payment method is currently selectedlet currentSelection = { source: null, method: null };let currentPaymentScheme = null;window.addEventListener('message', (event) => { if (event.data.type !== 'quidkey-state-update') return; // Update dynamic height if (event.data.dynamicHeight) { document.documentElement.style.setProperty( '--quidkey-dynamic-height', event.data.dynamicHeight ); } // Track payment scheme currentPaymentScheme = event.data.paymentScheme || null; // Handle bank selection const selectedBankId = event.data.selectedBankId; if (selectedBankId) { currentSelection = { source: 'quidkey', method: selectedBankId }; purchaseButton.disabled = false; } // Collapse Stripe when Quidkey is active if (event.data.isListOpen || event.data.isPredictedBankSelected) { if (paymentElement) { paymentElement.collapse(); } }});
When the customer interacts with the Stripe Payment Element again, update currentSelection to { source: 'stripe', method: null } using Stripe’s change event listener.
Load the page in your browser. You should see both the Stripe Payment Element and the Quidkey bank picker. Quidkey will predict and pre-select a demo bank in test mode.
2
Test Quidkey path
Click the Quidkey bank option. The Stripe Payment Element should collapse. Your purchase button should be enabled. Click Purchase, authenticate with any credentials (demo mode), and verify you’re redirected to your success URL.
3
Test Stripe path
Reload and interact with the Stripe Payment Element instead. The Quidkey selection should clear. Confirm the Stripe payment flow works as before.
4
Verify with webhook
Check your webhook endpoint (if configured) for the Quidkey payment confirmation.