|
@@ -3,6 +3,8 @@
|
|
|
import Image from "next/image";
|
|
import Image from "next/image";
|
|
|
import { Ref, useEffect, useImperativeHandle } from "react";
|
|
import { Ref, useEffect, useImperativeHandle } from "react";
|
|
|
import { useForm, get } from "react-hook-form";
|
|
import { useForm, get } from "react-hook-form";
|
|
|
|
|
+import {useConfig} from "@/utils/hooks/useConfig";
|
|
|
|
|
+import {getPaymentMethodLogo,getPaymentDescription} from "@/utils/paymentTools";
|
|
|
import { CheckoutPaymentMethod } from "@/types/checkout/type";
|
|
import { CheckoutPaymentMethod } from "@/types/checkout/type";
|
|
|
import AirwallexCardInput from "./PaymentMethodAdditional/AirwallexCardInput";
|
|
import AirwallexCardInput from "./PaymentMethodAdditional/AirwallexCardInput";
|
|
|
import {useAirwallexCardState} from "@/lib/Airwallex/useAirwallexCard";
|
|
import {useAirwallexCardState} from "@/lib/Airwallex/useAirwallexCard";
|
|
@@ -20,14 +22,19 @@ export function PaymentMethodCheckout({
|
|
|
ref,
|
|
ref,
|
|
|
paymentMethods,
|
|
paymentMethods,
|
|
|
selectedPaymentMethod,
|
|
selectedPaymentMethod,
|
|
|
|
|
+ grandTotal,
|
|
|
onPaymentMethodChange,
|
|
onPaymentMethodChange,
|
|
|
}: {
|
|
}: {
|
|
|
ref: Ref<RefPaymentMethodsHandle>;
|
|
ref: Ref<RefPaymentMethodsHandle>;
|
|
|
paymentMethods: CheckoutPaymentMethod[];
|
|
paymentMethods: CheckoutPaymentMethod[];
|
|
|
selectedPaymentMethod: string;
|
|
selectedPaymentMethod: string;
|
|
|
|
|
+ grandTotal: number;
|
|
|
onPaymentMethodChange: (value: string) => Promise<boolean>;
|
|
onPaymentMethodChange: (value: string) => Promise<boolean>;
|
|
|
}) {
|
|
}) {
|
|
|
|
|
|
|
|
|
|
+ const {getCurrentCurrencyItem} = useConfig();
|
|
|
|
|
+ const currentCurrency = getCurrentCurrencyItem();
|
|
|
|
|
+ const currencySymbol = currentCurrency.symbol;
|
|
|
|
|
|
|
|
const airwallexCardState = useAirwallexCardState();
|
|
const airwallexCardState = useAirwallexCardState();
|
|
|
|
|
|
|
@@ -91,7 +98,13 @@ export function PaymentMethodCheckout({
|
|
|
|
|
|
|
|
const airwallexOtherInfoShow = selectedPaymentMethod === 'airwallex' && airwallexCardState.cardNumberReady && airwallexCardState.expiryReady && airwallexCardState.cvcReady;
|
|
const airwallexOtherInfoShow = selectedPaymentMethod === 'airwallex' && airwallexCardState.cardNumberReady && airwallexCardState.expiryReady && airwallexCardState.cvcReady;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const genetePaymentTips = (payment: string) => {
|
|
|
|
|
+ return getPaymentDescription({
|
|
|
|
|
+ payment: payment,
|
|
|
|
|
+ grandTotal: grandTotal,
|
|
|
|
|
+ symble: currencySymbol
|
|
|
|
|
+ })
|
|
|
|
|
+ };
|
|
|
return (<>
|
|
return (<>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -107,9 +120,17 @@ export function PaymentMethodCheckout({
|
|
|
className="group box-border flex items-center relative bg-ly-lightgray p-3 rounded-sm has-checked:bg-white has-checked:border-1 has-checked:border-ly-green"
|
|
className="group box-border flex items-center relative bg-ly-lightgray p-3 rounded-sm has-checked:bg-white has-checked:border-1 has-checked:border-ly-green"
|
|
|
>
|
|
>
|
|
|
<p className="pr-2 flex-none relative">
|
|
<p className="pr-2 flex-none relative">
|
|
|
- <Image className="block h-8 w-auto" width={32} height={32} src={item.icon || ''} alt={"Payment Method " + item.title} />
|
|
|
|
|
|
|
+ {/**这里的width=32 height=32仅仅是让next.js有一个值计算图片的比例,并不能决定图片的渲染尺寸 */}
|
|
|
|
|
+ <Image className="block h-8 w-auto"
|
|
|
|
|
+ width={32}
|
|
|
|
|
+ height={32}
|
|
|
|
|
+ src={getPaymentMethodLogo(item.method)}
|
|
|
|
|
+ alt={"Payment Method " + item.title}
|
|
|
|
|
+ />
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p className="text-ly-12 text-[#666666] ml-1">
|
|
|
|
|
+ {genetePaymentTips(item.method)}
|
|
|
</p>
|
|
</p>
|
|
|
- <p className="text-ly-12 text-[#666666] ml-1">{item.description}</p>
|
|
|
|
|
|
|
|
|
|
<div className="absolute top-1/2 -translate-y-1/2 right-3 flex items-center">
|
|
<div className="absolute top-1/2 -translate-y-1/2 right-3 flex items-center">
|
|
|
<svg className="check w-4 h-4 hidden group-has-[:checked]:block" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="1" width="14" height="14" rx="1" fill="#000000" ></rect><path stroke="rgba(255, 255, 255, 1)" strokeWidth="1.5" strokeLinecap="square" d="M5.3335 8L7.3335 10L11.3335 6"></path></svg>
|
|
<svg className="check w-4 h-4 hidden group-has-[:checked]:block" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="1" width="14" height="14" rx="1" fill="#000000" ></rect><path stroke="rgba(255, 255, 255, 1)" strokeWidth="1.5" strokeLinecap="square" d="M5.3335 8L7.3335 10L11.3335 6"></path></svg>
|