## Create an embedded Checkout instance

`stripe.createEmbeddedCheckoutPage(options: object)`

This method creates an embedded Checkout instance.

- `options`
  - `fetchClientSecret` A callback function `fetchClientSecret() => Promise` that resolves with the [client secret](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-client_secret) for the [Checkout Session](docs/api/checkout/sessions/object).
  - `clientSecret (deprecated)` _This param has been deprecated in favor of the `fetchClientSecret` param, which offers a faster loading experience._ The [client secret](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-client_secret) for the [Checkout Session](docs/api/checkout/sessions/object).
  - `onComplete` An optional callback function `onComplete() => void` that is called on completion for Checkout Sessions with `redirect_on_completion: if_required`.

### Example

```javascript
const stripe = await loadStripe('pk_test_...');

const checkout = await stripe.createEmbeddedCheckoutPage({
  fetchClientSecret: async () => {
    const res = await fetch('/create-checkout-session', {
      method: 'POST',
    });
    const {client_secret: clientSecret} = await res.json();
    return clientSecret;
  },
});
```