feat(payment): integrate epay (易支付) gateway for CNY recharges
release / release (release) Canceled after 0s

- new EpayClient: V1 md5 signing, submit.php page pay, api.php order query
- create/verify epay payment links with CNY exchange-rate conversion
- signed async notify handler (/admin/payment/callback_epay) with amount
  check plus idempotent crediting, and a gateway query fallback
- epay channel config form, channel row and payment_method enum extended
- RechargeModal: send payment_method (was payment_channel, so every recharge
  fell through to Stripe and 500'd) and re-enable the channel picker
- payment config encryption key moved to a local .env, never committed
This commit is contained in:
jinghui committed 2026-11-13 15:17:05 +08:00
1 parent 1fbb6711f2
commit 721a2be32b
12 files changed
+770 -12

No files matched your search

@@ -33,6 +33,17 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
paymentChannels[0]?.id || ""
);
// payment channels arrive asynchronously -- fall back to the first one so the
// confirm button is not stuck disabled on a modal opened before they load.
const effectiveChannel = selectedPaymentChannel || paymentChannels[0]?.id || "";
const currencySymbol = effectiveChannel === "epay" ? "¥" : "$";
const channelLabel = (id: string, name: string) => {
if (id === "epay") return t("Epay (Alipay / WeChat)");
if (id === "stripe") return name || t("Credit Card");
return name || id;
};
const [paymentId, setPaymentId] = useState("");
const [isConfirmOpen, setIsConfirmOpen] = useState(false);
@@ -48,7 +59,7 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
return;
}
if (!selectedPaymentChannel) {
if (!effectiveChannel) {
setError(t("Please select a payment method"));
return;
}
@@ -57,7 +68,9 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
method: "POST",
body: {
amount: numAmount,
payment_channel: selectedPaymentChannel,
currency: effectiveChannel === "epay" ? "cny" : "usd",
// channel id doubles as the payment method the backend switches on
payment_method: effectiveChannel,
success_url: window.location.origin + "/pay_success",
} as unknown as BodyInit,
});
@@ -128,7 +141,9 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
onChange={handleAmountChange}
startContent={
<div className="pointer-events-none flex items-center">
<span className="text-default-400 text-small">$</span>
<span className="text-default-400 text-small">
{currencySymbol}
</span>
</div>
}
type="text"
@@ -144,15 +159,13 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
}
}}
/>
{/**coming soon : select payment channel*/}
{/* {paymentChannels.length > 0 && (
{paymentChannels.length > 1 && (
<div className="space-y-2">
<label className="text-sm font-medium text-default-700">
{t("Payment Method")}
</label>
<RadioGroup
value={selectedPaymentChannel}
value={effectiveChannel}
onValueChange={setSelectedPaymentChannel}
isInvalid={!!error && error.includes("payment method")}
errorMessage={
@@ -165,12 +178,20 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
>
{paymentChannels.map((channel) => (
<Radio key={channel.id} value={channel.id}>
{channel.name}
{channelLabel(channel.id, channel.name)}
</Radio>
))}
</RadioGroup>
</div>
)} */}
)}
{effectiveChannel === "epay" && (
<p className="text-xs text-default-500">
{t(
"Billed in CNY via your epay gateway (Alipay / WeChat Pay), credited to your balance 1:1"
)}
</p>
)}
</ModalBody>
<ModalFooter>
<Button variant="light" onPress={handleClose}>
@@ -179,7 +200,7 @@ export const RechargeModal: React.FC<RechargeModalProps> = ({
<Button
color="primary"
onPress={handlePurchase}
isDisabled={!selectedPaymentChannel || !amount}
isDisabled={!effectiveChannel || !amount}
>
{t("Confirm")}
</Button>