GoCardless Components is a JavaScript component library aimed at providing GoCardless integrators with customisable functionality for creating checkout flows without the need to build their own from scratch using the API.
This document explains how Remember Me works with GoCardless Components, and how to integrate the standalone Remember Me components into your own checkout flow.
Remember Me lets returning customers skip re-entering their details. When a customer enters an email address GoCardless has seen before, they verify their identity and their saved details are pre-filled. New customers can opt in to have their details saved for next time.
Using the Billing Request component?
If you're using the Billing Request
component, Remember Me is already
included and appears automatically — you don't need anything from this page. This page is for
custom checkouts that need standalone Remember Me components.
This page covers the standalone ReturnFlow and Signup components for custom checkouts that don't use the Billing Request component. You'll mount and configure these components yourself to integrate Remember Me into your existing checkout flow.
Remember Me currently supports the Bacs scheme only.
The standalone Remember Me components require a valid Billing Request ID to function. The Billing Request component creates its own, so you can skip this section if you use it. Ensure you can:
The rest of this page is only needed if you are using the standalone components. If you use the Billing Request component, you don't need anything else from this page.
Loading this script attaches GcComponents to the global window object. You don't need to load React or a separate stylesheet.
Load the library with a regular <script src="..."> tag. The Remember Me components are loaded on
demand from the same location as this script, so it can't be copied into your own bundle or
inlined.
Using the latest version of the GoCardless Components library is advised during the development and testing phases of the integration.
However, for go-live, it is recommended to use a specific version of the GoCardless Components library, by replacing latest with the full version number. Remember Me requires version 2.25.0 or later:
This provides type safety for the window.GcComponents global object and makes all the callback interfaces (such as VerificationResult and GoCardlessError) available throughout your project without importing them.
The file has no import or export, so TypeScript treats it as a global declaration file. Don't add one, or the types stop being global.
The environment in which you want to use the components (sandbox or live)
Yes
sessionToken
A callback returning a fresh session token (see Prerequisites)
Yes
The library also accepts optional appearance, enableAnalytics, onEvent, onError and locale settings. These work the same as for the Billing Request component, see Configure the Library for the full list.
The publicToken and scheme options and the loadConfig method from earlier versions of this
page are no longer used. Authentication is handled by the session token, and Remember Me is
currently available for the Bacs scheme only.
When creating a GC Component, you need to specify where on your webpage it will be mounted. Create a <div> in your app in the place you want the GC Component to be displayed and give it an intuitive identifier (i.e. gc-billing-return-flow), to select when creating a component.
const billingRequestId = "BR123456"; // From your backendconst returnFlow = gc.createComponent("remember-me-return-flow", { billingRequestId, defaultEmail: "", // Optional: pre-fill email if available onCustomerRecognitionCheck: (result) => { if (result.recognised) { console.log("Customer recognised", result.customerData); // Customer found - they will be prompted for verification } else { console.log("Customer not recognised - show standard checkout"); // Show your normal checkout form } }, onVerificationAttempt: (result) => { if (result.success) { console.log("Verification complete"); // Pre-fill customer details from result.billingRequest // Navigate to confirmation page } }, onVerificationExit: (exitPoint) => { if (exitPoint === "user_closed") { // User cancelled - show manual entry option console.log("User cancelled verification"); } else if (exitPoint === "verification_failed") { // Verification failed - offer retry or manual entry console.log("Verification failed"); } }, onError: (error) => { console.error("Remember Me error:", error); // Fallback to standard checkout },});await returnFlow.mount("#gc-billing-return-flow");
gc is the instance returned by GcComponents.init(...) in Configure Components, and #gc-billing-return-flow is the <div> described in Select where to mount GoCardless Components. mount is asynchronous: it resolves once the component has loaded and been added to the page.
To remove the component, for example when the customer navigates away, call returnFlow.unmount().
After a successful verification, onVerificationExit can be called before
onVerificationAttempt, because the component confirms the payer details before it calls
onVerificationAttempt. Don't rely on the order of the two callbacks. Use onVerificationAttempt
to read the customer's details.
The ReturnFlow component can be embedded directly inside your checkout form to provide a seamless experience. The component replaces the email input field and handles customer recognition and verification.
The ReturnFlow component replaces the email input field in your form
Use the onChange callback to sync the email value to your form state
Mount the component in a dedicated <div> with a unique ID
The component handles email recognition and verification automatically
After verification, the customer's saved details are available on result.billingRequest in the onVerificationAttempt callback (see the next section)
The example calls GcComponents.init inside the effect to keep it self-contained. In your app, initialise the library once and reuse the instance for every component
When a returning customer successfully verifies their identity, you should auto-fill the form fields with their saved information from the billing request.
The onVerificationAttempt callback receives a VerificationResult object containing the billing request with customer data. The customer's details are only available here, after verification succeeds. Before that, the billing request does not contain them (the email, for example, is only available as customerData.email in onCustomerRecognitionCheck):
const handleVerificationSuccess = (result: VerificationResult) => { if (result.success && result.billingRequest) { const { resources } = result.billingRequest; const customer = resources?.customer; const billingDetail = resources?.customer_billing_detail; const bankAccount = resources?.customer_bank_account; // Extract and parse customer data if (customer && billingDetail) { // Parse address line 1 to extract house number and street const addressLine1 = billingDetail.address_line1 || ""; const addressParts = addressLine1.match(/^(\S+)\s+(.+)$/); // Any of these can be null, so fall back to an empty string const customerData = { email: customer.email || "", // For a business payer, GoCardless returns company_name instead of the // names. If your form has a business option, use it to fill that field firstName: customer.given_name || "", lastName: customer.family_name || "", companyName: customer.company_name || "", houseNumber: addressParts?.[1] || "", flatNumber: billingDetail.address_line2 || "", streetName: addressParts?.[2] || addressLine1, townCity: billingDetail.city || "", postcode: billingDetail.postal_code || "", // Often empty for UK addresses county: billingDetail.region || "", }; // Update form state with customer data setFormData(customerData); } // Store masked bank account for display if (bankAccount) { setMaskedBankAccount(bankAccount); } // Mark customer as verified setIsVerified(true); }};
Make sure your form inputs are controlled components that respond to state changes:
// Use useEffect to update form data when verification completesuseEffect(() => { if (verifiedCustomerData) { setFormData((prev) => ({ ...prev, ...verifiedCustomerData, })); }}, [verifiedCustomerData]);// Form inputs automatically reflect the updated state<input type="text" name="firstName" value={formData.firstName} // This updates automatically onChange={handleChange}/>
<h1>Payment Successful!</h1><p>Thank you for your payment.</p><div id="gc-billing-signup"></div><p id="signup-confirmation" hidden>Your details have been saved for faster checkout next time</p>
const billingRequestId = "BR123456"; // From your backendconst customerEmail = "[email protected]";const signup = gc.createComponent("remember-me-signup", { billingRequestId, email: customerEmail, onSuccess: (result) => { console.log("Customer enrolled in Remember Me:", result); signup.unmount(); document.getElementById("signup-confirmation").hidden = false; }, onError: (error) => { console.error("Signup failed:", error); // Optional: Show user-friendly message // Don't block user from proceeding if signup fails },});await signup.mount("#gc-billing-signup");
Both components use the GoCardless theme by default. The theme automatically adapts to create a cohesive experience.
The Remember Me components can be customised to fit the UI of your page. This is done through the optional appearance object, which you can pass to GcComponents.init to style every component on the page, or to createComponent to style a single component. When both are set, the component's appearance takes priority.
Example:
const gc = GcComponents.init({ environment: "sandbox", sessionToken: () => fetch("/your-backend/session-token").then((r) => r.text()), appearance: { backgroundColor: "#bfe6f2", inputBorderRadius: "0px", wrapperBorderRadius: "0", textFontFamily: "Georgia, serif", buttonPrimaryColor: "#004d40", },});gc.createComponent("remember-me-return-flow", { billingRequestId,}).mount("#gc-billing-return-flow");gc.createComponent("remember-me-signup", { billingRequestId, email: customerEmail, // Optional: overrides the global appearance for this component only appearance: { buttonPrimaryColor: "#00a000" },}).mount("#gc-billing-signup");
You can modify colours, fonts, borders, padding etc. for a variety of different on-screen elements. We recommend playing around with backgroundColor, textFontFamily, buttonPrimaryColor and buttonBorderRadius to get started.
You may notice that GoCardless Components come with some default styling even when no appearance variables are provided. Any appearance variables you add will be applied on top of the default styles.
Appearance variables are now passed as a flat object, without the variables wrapper used in
earlier versions of this page, and some have been renamed (for example buttonColor is now
buttonPrimaryColor).
The appearance variables are shared with the Billing Request component. See Customisation for the full list of variables and their default values.