Develop
This commit is contained in:
parent
bb8d8073e3
commit
ab9250f5c3
@ -17,6 +17,7 @@ interface ICheckoutFormProps {
|
|||||||
subscriptionReceiptId?: string;
|
subscriptionReceiptId?: string;
|
||||||
returnUrl?: string;
|
returnUrl?: string;
|
||||||
confirmType?: "payment" | "setup";
|
confirmType?: "payment" | "setup";
|
||||||
|
isHide?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CheckoutForm({
|
export default function CheckoutForm({
|
||||||
@ -24,6 +25,7 @@ export default function CheckoutForm({
|
|||||||
subscriptionReceiptId,
|
subscriptionReceiptId,
|
||||||
returnUrl,
|
returnUrl,
|
||||||
confirmType = "payment",
|
confirmType = "payment",
|
||||||
|
isHide = false,
|
||||||
}: ICheckoutFormProps) {
|
}: ICheckoutFormProps) {
|
||||||
const stripe = useStripe();
|
const stripe = useStripe();
|
||||||
const elements = useElements();
|
const elements = useElements();
|
||||||
@ -70,13 +72,19 @@ export default function CheckoutForm({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
className="payment-form-stripe"
|
className={`payment-form-stripe ${isHide ? styles.hide : ""}`}
|
||||||
id="payment-form"
|
id="payment-form"
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
>
|
>
|
||||||
{children ? children : null}
|
{children ? children : null}
|
||||||
<PaymentElement
|
<PaymentElement
|
||||||
options={{ terms: { card: "never" } }}
|
options={{
|
||||||
|
terms: { card: "never" },
|
||||||
|
wallets: {
|
||||||
|
googlePay: "never",
|
||||||
|
applePay: "never",
|
||||||
|
},
|
||||||
|
}}
|
||||||
onReady={() => setFormReady(true)}
|
onReady={() => setFormReady(true)}
|
||||||
/>
|
/>
|
||||||
<MainButton
|
<MainButton
|
||||||
|
|||||||
@ -9,6 +9,11 @@
|
|||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hide {
|
||||||
|
height: 0;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.payment-loader {
|
.payment-loader {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@ -94,7 +94,10 @@ function ExpressCheckoutStripe({
|
|||||||
<div className={`${styles.container} ${isHideForm ? styles.hide : ""}`}>
|
<div className={`${styles.container} ${isHideForm ? styles.hide : ""}`}>
|
||||||
<ExpressCheckoutElement
|
<ExpressCheckoutElement
|
||||||
onReady={onReady}
|
onReady={onReady}
|
||||||
onLoadError={() => onChangeLoading && onChangeLoading(false)}
|
onLoadError={(e) => {
|
||||||
|
console.log("Error: ", e);
|
||||||
|
onChangeLoading && onChangeLoading(false);
|
||||||
|
}}
|
||||||
onConfirm={onConfirm}
|
onConfirm={onConfirm}
|
||||||
options={{
|
options={{
|
||||||
layout: {
|
layout: {
|
||||||
@ -102,6 +105,10 @@ function ExpressCheckoutStripe({
|
|||||||
overflow: "never",
|
overflow: "never",
|
||||||
},
|
},
|
||||||
paymentMethodOrder: ["apple_pay", "google_pay", "amazon_pay", "link"],
|
paymentMethodOrder: ["apple_pay", "google_pay", "amazon_pay", "link"],
|
||||||
|
wallets: {
|
||||||
|
googlePay: "always",
|
||||||
|
applePay: "always",
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errorMessage && <p className={styles.error}>{errorMessage}</p>}
|
{errorMessage && <p className={styles.error}>{errorMessage}</p>}
|
||||||
|
|||||||
@ -160,28 +160,31 @@ function PaymentModal({
|
|||||||
)}
|
)}
|
||||||
<div className={styles["payment-method-container"]}>
|
<div className={styles["payment-method-container"]}>
|
||||||
{stripePromise && clientSecret && (
|
{stripePromise && clientSecret && (
|
||||||
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
<>
|
||||||
<ExpressCheckoutStripe
|
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
||||||
clientSecret={clientSecret}
|
<ExpressCheckoutStripe
|
||||||
returnUrl={returnUrl}
|
clientSecret={clientSecret}
|
||||||
isHide={
|
returnUrl={returnUrl}
|
||||||
selectedPaymentMethod !== EPaymentMethod.PAYMENT_BUTTONS
|
isHide={
|
||||||
}
|
selectedPaymentMethod !== EPaymentMethod.PAYMENT_BUTTONS
|
||||||
onAvailable={(_isAvailable, _availableMethods) =>
|
}
|
||||||
onAvailableExpressCheckout(_isAvailable, _availableMethods)
|
onAvailable={(_isAvailable, _availableMethods) =>
|
||||||
}
|
onAvailableExpressCheckout(_isAvailable, _availableMethods)
|
||||||
onChangeLoading={(isLoading) =>
|
}
|
||||||
setIsLoadingExpressCheckout(isLoading)
|
onChangeLoading={(isLoading) =>
|
||||||
}
|
setIsLoadingExpressCheckout(isLoading)
|
||||||
/>
|
}
|
||||||
{selectedPaymentMethod === EPaymentMethod.CREDIT_CARD && (
|
/>
|
||||||
|
</Elements>
|
||||||
|
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
||||||
<CheckoutForm
|
<CheckoutForm
|
||||||
confirmType={paymentType}
|
confirmType={paymentType}
|
||||||
subscriptionReceiptId={paymentIntentId}
|
subscriptionReceiptId={paymentIntentId}
|
||||||
returnUrl={returnUrl}
|
returnUrl={returnUrl}
|
||||||
|
isHide={selectedPaymentMethod !== EPaymentMethod.CREDIT_CARD}
|
||||||
/>
|
/>
|
||||||
)}
|
</Elements>
|
||||||
</Elements>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<SecurityPayments />
|
<SecurityPayments />
|
||||||
|
|||||||
@ -165,28 +165,31 @@ function PaymentModal({
|
|||||||
)}
|
)}
|
||||||
<div className={styles["payment-method-container"]}>
|
<div className={styles["payment-method-container"]}>
|
||||||
{stripePromise && clientSecret && (
|
{stripePromise && clientSecret && (
|
||||||
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
<>
|
||||||
<ExpressCheckoutStripe
|
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
||||||
clientSecret={clientSecret}
|
<ExpressCheckoutStripe
|
||||||
returnUrl={returnUrl}
|
clientSecret={clientSecret}
|
||||||
isHide={
|
returnUrl={returnUrl}
|
||||||
selectedPaymentMethod !== EPaymentMethod.PAYMENT_BUTTONS
|
isHide={
|
||||||
}
|
selectedPaymentMethod !== EPaymentMethod.PAYMENT_BUTTONS
|
||||||
onAvailable={(_isAvailable, _availableMethods) =>
|
}
|
||||||
onAvailableExpressCheckout(_isAvailable, _availableMethods)
|
onAvailable={(_isAvailable, _availableMethods) =>
|
||||||
}
|
onAvailableExpressCheckout(_isAvailable, _availableMethods)
|
||||||
onChangeLoading={(isLoading) =>
|
}
|
||||||
setIsLoadingExpressCheckout(isLoading)
|
onChangeLoading={(isLoading) =>
|
||||||
}
|
setIsLoadingExpressCheckout(isLoading)
|
||||||
/>
|
}
|
||||||
{selectedPaymentMethod === EPaymentMethod.CREDIT_CARD && (
|
/>
|
||||||
|
</Elements>
|
||||||
|
<Elements stripe={stripePromise} options={{ clientSecret }}>
|
||||||
<CheckoutForm
|
<CheckoutForm
|
||||||
confirmType={paymentType}
|
confirmType={paymentType}
|
||||||
subscriptionReceiptId={paymentIntentId}
|
subscriptionReceiptId={paymentIntentId}
|
||||||
returnUrl={returnUrl}
|
returnUrl={returnUrl}
|
||||||
|
isHide={selectedPaymentMethod !== EPaymentMethod.CREDIT_CARD}
|
||||||
/>
|
/>
|
||||||
)}
|
</Elements>
|
||||||
</Elements>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<SecurityPayments />
|
<SecurityPayments />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user