## Confirm event The `confirm` event is triggered from an Express Checkout Element when the customer finalizes their payment. Use this event to trigger payment confirmation. **Syntax:** `expressCheckoutElement.on(...)` - `event` (string) **required** The name of the event. In this case, `confirm`. - `handler` (function) **required** A callback function `handler(event) => void` you provide that's called after the event is fired. When called, it passes an event object with the following properties: - `elementType` ('expressCheckout') **required** The type of element the event fires from, which is `expressCheckout` in this case. - `expressPaymentType` ('apple_pay' | 'google_pay' | 'amazon_pay' | 'paypal' | 'link' | 'klarna') **required** The payment method the customer checks out with. - `paymentFailed` (function) **required** A function `paymentFailed(payload) => void` that's called if you're unable to process the customer's payment. - `reason` ('fail' | 'invalid_shipping_address' | 'invalid_billing_address' | 'invalid_payment_data' | 'address_unserviceable') Default is `'fail'`. The payment interface might surface the reason to provide a hint to the customer on why their payment failed. - `message` (string) A short, concise, localized error message to display on the payment sheet. If none is provided, the payment sheet will display a generic error message for the given reason. **Note:** Custom error messages may not be supported or may be truncated by certain wallets. - `billingDetails` (object) Object containing information about the customer's billing details. - `name` (string) The name of the customer. - `email` (string) The email address of the customer. - `phone` (string) The phone number of the customer. - `address` (string) The billing address of the customer. **Note:** When using PayPal, the full billing address of the customer is not always exposed. Typically, only the country code is passed back from PayPal. To access the full billing address, you would need to request it from PayPal directly. - `line1` (string) - `line2` (string) - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) - `shippingAddress` (object) Object containing information about the customer's shipping address. - `name` (string) The name of the recipient. - `address` (string) The shipping address of the customer. - `line1` (string) - `line2` (string) - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) - `shippingRate` (object) Object containing information about the selected shipping rate. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. ### Handle 'confirm' event ```js expressCheckoutElement.on('confirm', function(event) { // call Stripe function to initiate payment confirmation stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com', }, }) .then(function(result) { if (result.error) { // Inform the customer that there's an error. } }); }); ``` ```es_next expressCheckoutElement.on('confirm', (event) => { // call Stripe function to initiate payment confirmation const {error} = await stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com', }, }); }); ```