Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fetchClientSecret param to Embedded Checkout #481

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

tiff-stripe
Copy link
Contributor

@tiff-stripe tiff-stripe commented Mar 6, 2024

Summary & motivation

Adds support for passing the fetchClientSecret param to <EmbeddedCheckoutProvider>'s options prop.

Example usage:

import * as React from 'react';
import {loadStripe} from '@stripe/stripe-js';
import {
  EmbeddedCheckoutProvider,
  EmbeddedCheckout
} from '@stripe/react-stripe-js';

const stripePromise = loadStripe('pk_test_123', {betas: ['embedded_checkout_beta_1']}));

const App = ({createCheckoutSession}) => {
  const options = {
    fetchClientSecret: async () => { 
      const clientSecret = await createCheckoutSession(); 
      return clientSecret;
    }
  };

  return (
    <EmbeddedCheckoutProvider
      stripe={stripePromise}
      options={options}
    />
      <EmbeddedCheckout />
    </EmbeddedCheckoutProvider>
  )
}

Testing & documentation

Unit tests and manual testing locally.

cweiss-stripe
cweiss-stripe previously approved these changes Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants