fix(appointment): initiate payment against real gateway endpoint
POST /api/v1/payment/appointment expects { appointment_uuid, gateway,
frontend_address } and returns data.redirect_url. Send that body, redirect
to the gateway URL the backend returns (instead of hand-building one),
align the bank options with the real mellat/sep gateways, and remove the
hard-coded 10,000 toman amount (no real price available at this step).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ function Paying({ setStep, appointmentId }) {
|
||||
|
||||
const banks = [
|
||||
{ id: "mellat", title: "بانک ملت" },
|
||||
{ id: "saman", title: "سامان کیش" }
|
||||
{ id: "sep", title: "سامان (سپ)" }
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
@@ -44,17 +44,16 @@ function Paying({ setStep, appointmentId }) {
|
||||
setLoading(true);
|
||||
try {
|
||||
const paymentPayload = {
|
||||
payment_method: selectedBank,
|
||||
bundle: "appointment",
|
||||
entity_reference_id: appointmentId
|
||||
appointment_uuid: appointmentId,
|
||||
gateway: selectedBank,
|
||||
frontend_address: `${window.location.origin}/payment/result`,
|
||||
};
|
||||
|
||||
const response = await request.postPayment(paymentPayload);
|
||||
const res = await request.postAppointmentPayment(paymentPayload);
|
||||
|
||||
// Redirect to payment gateway
|
||||
if (response?.uuid) {
|
||||
const paymentUrl = `${process.env.NEXT_PUBLIC_API_URL}/payment/${response.uuid}`;
|
||||
window.location.href = paymentUrl;
|
||||
const redirectUrl = res?.data?.redirect_url;
|
||||
if (redirectUrl) {
|
||||
window.location.href = redirectUrl;
|
||||
} else {
|
||||
setStep((prev) => prev + 1);
|
||||
}
|
||||
@@ -114,10 +113,7 @@ function Paying({ setStep, appointmentId }) {
|
||||
<span className="bg-[#D7D7D7] hidden md:block h-px w-full mt-[32px] mb-[25px]"></span>
|
||||
|
||||
<ButtonFixed>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<p className="text-[#616161] md:text-[#3B3B3B] text-[14px] md:text-[16px] font-bold">
|
||||
مبلغ قابل پرداخت : 10،000 تومان
|
||||
</p>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<Button
|
||||
className="!gap-[4px] !mr-auto !flex !px-[12px] !p-[7px] md:!py-[9px] !min-w-[157px]"
|
||||
onClick={handlePayment}
|
||||
|
||||
Reference in New Issue
Block a user