import * as React from "react";
import { MetadataContext, MetadataProvider } from "../utils/MetadataProvider";
import Error from "../pages/error";
interface Stripe {
/**
* A custom button which will act as the checkout button
*/
button: JSX.Element;
/**
* The product SKU
*/
sku: string;
/**
* The product quantity to be purchased
*/
quantity: number;
/**
* The customers email. (Optional) Used to prefill the checkout form
*/
customerEmail?: string;
/**
* A custom error message to show incase of bad api/secret key being provided. (Optional) Default text -
* No metadata provided, please check your configuration.
*/
customErrorMessage?: string;
}
const StripeButton = ({
button,
plan,
quantity,
customerEmail,
customErrorMessage
}: Stripe) => {
const metadata = React.useContext(MetadataContext);
if (!metadata) {
return (