2025-08-11 06:34:44 +00:00
|
|
|
|
import React, { useEffect, useState } from 'react'
|
2025-08-17 19:07:04 +00:00
|
|
|
|
import {
|
|
|
|
|
|
FaCreditCard,
|
|
|
|
|
|
FaLock,
|
|
|
|
|
|
FaArrowLeft,
|
|
|
|
|
|
FaUser,
|
|
|
|
|
|
FaBuilding,
|
|
|
|
|
|
FaMailBulk,
|
|
|
|
|
|
FaPhone,
|
|
|
|
|
|
FaMapMarkerAlt,
|
|
|
|
|
|
FaMap,
|
|
|
|
|
|
FaGlobe,
|
|
|
|
|
|
FaMoneyBillWave,
|
|
|
|
|
|
FaDollarSign,
|
|
|
|
|
|
FaUserPlus,
|
|
|
|
|
|
} from 'react-icons/fa'
|
2025-08-11 06:34:44 +00:00
|
|
|
|
import {
|
|
|
|
|
|
BillingCycle,
|
|
|
|
|
|
BasketItem,
|
|
|
|
|
|
InstallmentOptionDto,
|
|
|
|
|
|
PaymentMethodDto,
|
|
|
|
|
|
} from '@/proxy/order/models'
|
|
|
|
|
|
import { OrderService } from '@/services/order.service'
|
|
|
|
|
|
import { CustomTenantDto } from '@/proxy/config/models'
|
2025-08-17 19:07:04 +00:00
|
|
|
|
import { useLocalization } from '@/utils/hooks/useLocalization'
|
2025-08-11 06:34:44 +00:00
|
|
|
|
|
|
|
|
|
|
interface CartState {
|
|
|
|
|
|
items: BasketItem[]
|
|
|
|
|
|
total: number
|
|
|
|
|
|
globalBillingCycle: BillingCycle
|
|
|
|
|
|
globalPeriod: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface PaymentFormProps {
|
|
|
|
|
|
tenant: CustomTenantDto
|
|
|
|
|
|
onBack: () => void
|
|
|
|
|
|
onComplete: (paymentData: Record<string, unknown>) => void
|
|
|
|
|
|
cartState: CartState
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const PaymentForm: React.FC<PaymentFormProps> = ({
|
|
|
|
|
|
tenant,
|
|
|
|
|
|
onBack,
|
|
|
|
|
|
onComplete,
|
|
|
|
|
|
cartState,
|
|
|
|
|
|
}) => {
|
2025-10-08 14:08:34 +00:00
|
|
|
|
const defaultPaymentMethod = 'Kredi Kartı'
|
|
|
|
|
|
const [selectedPaymentMethod, setSelectedPaymentMethod] = useState<string>(defaultPaymentMethod)
|
2025-08-11 06:34:44 +00:00
|
|
|
|
const [selectedInstallment, setSelectedInstallment] = useState<InstallmentOptionDto>()
|
|
|
|
|
|
const [paymentData, setPaymentData] = useState({
|
|
|
|
|
|
cardNumber: '',
|
|
|
|
|
|
expiryDate: '',
|
|
|
|
|
|
cvv: '',
|
|
|
|
|
|
cardName: '',
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-17 19:07:04 +00:00
|
|
|
|
const { translate } = useLocalization()
|
2025-08-11 06:34:44 +00:00
|
|
|
|
const [paymentMethods, setPaymentMethods] = useState<PaymentMethodDto[]>([])
|
|
|
|
|
|
const [installmentOptions, setInstallmentOptions] = useState<InstallmentOptionDto[]>([])
|
|
|
|
|
|
const [loading, setLoading] = useState<boolean>(true)
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
|
const orderService = new OrderService()
|
|
|
|
|
|
try {
|
|
|
|
|
|
const paymentResponse = await orderService.getPaymentMethodList()
|
|
|
|
|
|
setPaymentMethods(paymentResponse.data)
|
|
|
|
|
|
if (paymentResponse.data.length > 0) {
|
2025-10-08 14:08:34 +00:00
|
|
|
|
setSelectedPaymentMethod(paymentResponse.data[1].name)
|
2025-08-11 06:34:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const installmentResponse = await orderService.getInstallmentOptionList()
|
|
|
|
|
|
setInstallmentOptions(installmentResponse.data)
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('Ödeme şekilleri ve Komisyon Bilgileri alınamadı', err)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setLoading(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fetchData()
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
2025-10-08 14:08:34 +00:00
|
|
|
|
const selectedMethod = paymentMethods.find((m) => m.name === selectedPaymentMethod)
|
2025-08-11 06:34:44 +00:00
|
|
|
|
|
|
|
|
|
|
let commission = 0
|
2025-10-08 14:08:34 +00:00
|
|
|
|
if (selectedPaymentMethod === defaultPaymentMethod && selectedInstallment) {
|
2025-08-11 06:34:44 +00:00
|
|
|
|
commission = cartState.total * selectedInstallment.commission
|
|
|
|
|
|
} else if (selectedMethod) {
|
|
|
|
|
|
commission = cartState.total * selectedMethod.commission
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const finalTotal = cartState.total + commission
|
|
|
|
|
|
|
|
|
|
|
|
const formatPrice = (price: number) =>
|
|
|
|
|
|
new Intl.NumberFormat('tr-TR', {
|
|
|
|
|
|
style: 'currency',
|
|
|
|
|
|
currency: 'TRY',
|
|
|
|
|
|
minimumFractionDigits: 2,
|
|
|
|
|
|
}).format(price)
|
|
|
|
|
|
|
|
|
|
|
|
const handleSubmit = (e: React.FormEvent) => {
|
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
onComplete({
|
|
|
|
|
|
...paymentData,
|
2025-10-08 14:08:34 +00:00
|
|
|
|
paymentMethodId: selectedMethod?.id,
|
|
|
|
|
|
installment:
|
|
|
|
|
|
selectedPaymentMethod === defaultPaymentMethod
|
|
|
|
|
|
? (selectedInstallment?.installment ?? 1)
|
|
|
|
|
|
: 1,
|
2025-08-11 06:34:44 +00:00
|
|
|
|
commission,
|
|
|
|
|
|
total: finalTotal,
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleInputChange = (field: string, value: string) => {
|
|
|
|
|
|
setPaymentData((prev) => ({ ...prev, [field]: value }))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div className="mx-auto px-4 lg:px-8 mb-6">
|
|
|
|
|
|
{loading ? (
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<div className="text-center py-12 text-gray-500">
|
2025-11-10 18:29:21 +00:00
|
|
|
|
{translate('::App.Loading')}
|
2025-08-17 19:07:04 +00:00
|
|
|
|
</div>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
) : (
|
|
|
|
|
|
<form onSubmit={handleSubmit} className="flex flex-col lg:flex-row gap-6">
|
|
|
|
|
|
{/* 3 Sütun: Ödeme Yöntemi | Taksit Seçenekleri | Sipariş Özeti */}
|
|
|
|
|
|
<div className="w-full lg:w-1/3 flex flex-col gap-6">
|
|
|
|
|
|
<div className="bg-white rounded-xl shadow border p-6">
|
|
|
|
|
|
{tenant && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<h2 className="text-lg font-semibold mb-4 flex items-center">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<FaUser className="w-5 h-5 text-green-600 mr-2" />{' '}
|
|
|
|
|
|
{translate('::Public.payment.customerInfo')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</h2>
|
|
|
|
|
|
<div className="pt-4 border-t border-gray-200">
|
|
|
|
|
|
<div className="grid grid-cols-1 gap-y-3 text-sm text-gray-700">
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaUser className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.code')}
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.name}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaUser className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
2025-11-10 18:29:21 +00:00
|
|
|
|
{translate('::LoginPanel.Profil')}
|
2025-08-17 19:07:04 +00:00
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.founder}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaBuilding className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.company')}
|
|
|
|
|
|
</span>
|
2025-08-23 17:56:54 +00:00
|
|
|
|
<span>{tenant.organizationName}</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaMailBulk className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
2025-11-10 18:29:21 +00:00
|
|
|
|
{translate('::Abp.Account.EmailAddress')}
|
2025-08-17 19:07:04 +00:00
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.email}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaPhone className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
2025-11-10 18:29:21 +00:00
|
|
|
|
{translate('::Abp.Identity.User.UserInformation.PhoneNumber')}
|
2025-08-17 19:07:04 +00:00
|
|
|
|
</span>
|
2025-11-03 20:31:28 +00:00
|
|
|
|
<span>{tenant.phoneNumber}</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-start gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaMapMarkerAlt className="w-4 h-4 text-gray-500 mt-0.5" />
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<div>
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
2025-11-10 18:29:21 +00:00
|
|
|
|
{translate('::App.Address')}:
|
2025-08-17 19:07:04 +00:00
|
|
|
|
</span>
|
2025-10-21 14:32:50 +00:00
|
|
|
|
<div>{tenant.address1}</div>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaGlobe className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.country')}
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.country}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaGlobe className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.city')}
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.city}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaMap className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.district')}
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.district}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaMapMarkerAlt className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.postalCode')}:
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.postalCode}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaMoneyBillWave className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.taxOffice')}:
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.taxOffice}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaDollarSign className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.taxNumber')}:
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.vknTckn}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{tenant.reference && (
|
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaUserPlus className="w-4 h-4 text-gray-500" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span className="font-medium">
|
|
|
|
|
|
{translate('::Public.payment.customer.reference')}:
|
|
|
|
|
|
</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{tenant.reference}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="w-full lg:w-1/3 flex flex-col gap-6">
|
|
|
|
|
|
{/* 1. Sütun: Ödeme Yöntemi */}
|
|
|
|
|
|
<div className="bg-white rounded-xl shadow border p-6">
|
|
|
|
|
|
<h2 className="text-lg font-semibold mb-4 flex items-center">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<FaLock className="w-5 h-5 text-green-600 mr-2" />{' '}
|
|
|
|
|
|
{translate('::Public.payment.method.title')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</h2>
|
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
{paymentMethods.map((method) => (
|
|
|
|
|
|
<label
|
|
|
|
|
|
key={method.id}
|
|
|
|
|
|
className={`flex items-center p-3 border-2 rounded-lg cursor-pointer transition-all ${
|
2025-10-08 14:08:34 +00:00
|
|
|
|
selectedPaymentMethod === method.name
|
2025-08-11 06:34:44 +00:00
|
|
|
|
? 'border-blue-500 bg-blue-50'
|
|
|
|
|
|
: 'border-gray-200 hover:border-gray-300'
|
|
|
|
|
|
}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="radio"
|
2025-10-08 14:08:34 +00:00
|
|
|
|
name="paymentMethodId"
|
|
|
|
|
|
value={method.name}
|
|
|
|
|
|
checked={selectedPaymentMethod === method.name}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
setSelectedPaymentMethod(e.target.value)
|
|
|
|
|
|
}}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
className="sr-only"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<span className="text-2xl mr-3">{method.logo}</span>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div className="font-medium text-gray-900">{method.name}</div>
|
|
|
|
|
|
<div className="text-sm text-gray-600">
|
2025-10-08 14:08:34 +00:00
|
|
|
|
{method.name === defaultPaymentMethod
|
2025-08-17 19:07:04 +00:00
|
|
|
|
? translate('::Public.payment.method.installmentsAvailable')
|
|
|
|
|
|
: translate('::Public.payment.method.noCommission')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Taksit Seçenekleri */}
|
2025-10-08 14:08:34 +00:00
|
|
|
|
{selectedPaymentMethod === defaultPaymentMethod && (
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<div className="bg-white rounded-xl shadow border p-4">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<h3 className="text-md font-medium text-gray-800 mb-2">
|
|
|
|
|
|
{translate('::Public.payment.installments.title')}
|
|
|
|
|
|
</h3>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<div className="grid grid-cols-2 md:grid-cols-3 gap-3">
|
|
|
|
|
|
{installmentOptions.map((option) => (
|
|
|
|
|
|
<label
|
|
|
|
|
|
key={option.id}
|
|
|
|
|
|
className={`flex flex-col items-center justify-center h-full p-4 border-2 rounded-xl cursor-pointer transition-all text-xs md:text-sm text-center select-none ${
|
2025-10-08 14:08:34 +00:00
|
|
|
|
selectedInstallment?.installment === option.installment
|
2025-08-11 06:34:44 +00:00
|
|
|
|
? 'border-blue-500 bg-blue-50 shadow-md scale-105'
|
|
|
|
|
|
: 'border-gray-200 hover:border-blue-200'
|
|
|
|
|
|
}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="radio"
|
|
|
|
|
|
name="installment"
|
2025-10-08 14:08:34 +00:00
|
|
|
|
value={option.installment}
|
|
|
|
|
|
checked={selectedInstallment?.installment === option.installment}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
onChange={() => setSelectedInstallment(option)}
|
|
|
|
|
|
className="sr-only"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div className="font-semibold text-base mb-1">{option.name}</div>
|
|
|
|
|
|
<div className="text-gray-500 mb-1">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
{translate('::Public.payment.installments.commission')}{' '}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span className="font-semibold">
|
|
|
|
|
|
%{(option.commission * 100).toFixed(1)}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="text-blue-700 font-bold mb-1">
|
2025-10-08 14:08:34 +00:00
|
|
|
|
{option.installment > 1
|
|
|
|
|
|
? `${option.installment} ${translate('::Public.payment.installments.monthly')}`
|
2025-08-17 19:07:04 +00:00
|
|
|
|
: translate('::Public.payment.installments.single')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
<div className="font-extrabold text-lg text-gray-900 mt-1">
|
|
|
|
|
|
{formatPrice(
|
2025-10-08 14:08:34 +00:00
|
|
|
|
(cartState.total + cartState.total * option.commission) /
|
|
|
|
|
|
option.installment,
|
2025-08-11 06:34:44 +00:00
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* 3. Sütun: Kart Bilgileri + Sipariş Özeti ve Butonlar */}
|
|
|
|
|
|
<div className="w-full lg:w-1/3 flex flex-col gap-6">
|
|
|
|
|
|
{/* Kart Bilgileri */}
|
2025-10-08 14:08:34 +00:00
|
|
|
|
{selectedPaymentMethod !== defaultPaymentMethod && (
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<div className="bg-white rounded-xl shadow border p-6 space-y-3">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<h3 className="text-md font-medium text-gray-800 mb-3">
|
|
|
|
|
|
{translate('::Public.payment.card.title')}
|
|
|
|
|
|
</h3>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
required
|
|
|
|
|
|
value={paymentData.cardName}
|
|
|
|
|
|
onChange={(e) => handleInputChange('cardName', e.target.value)}
|
|
|
|
|
|
className="w-full px-4 py-2 border border-gray-300 rounded-lg"
|
2025-08-17 19:07:04 +00:00
|
|
|
|
placeholder={translate('::Public.payment.card.name')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
/>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
required
|
|
|
|
|
|
value={paymentData.cardNumber}
|
|
|
|
|
|
onChange={(e) => handleInputChange('cardNumber', e.target.value)}
|
|
|
|
|
|
className="w-full px-4 py-2 border border-gray-300 rounded-lg"
|
2025-08-17 19:07:04 +00:00
|
|
|
|
placeholder={translate('::Public.payment.card.number')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
maxLength={19}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div className="grid grid-cols-2 gap-3">
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
required
|
|
|
|
|
|
value={paymentData.expiryDate}
|
|
|
|
|
|
onChange={(e) => handleInputChange('expiryDate', e.target.value)}
|
|
|
|
|
|
className="w-full px-4 py-2 border border-gray-300 rounded-lg"
|
|
|
|
|
|
placeholder="MM/YY"
|
|
|
|
|
|
maxLength={5}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
required
|
|
|
|
|
|
value={paymentData.cvv}
|
|
|
|
|
|
onChange={(e) => handleInputChange('cvv', e.target.value)}
|
|
|
|
|
|
className="w-full px-4 py-2 border border-gray-300 rounded-lg"
|
|
|
|
|
|
placeholder="CVV"
|
|
|
|
|
|
maxLength={4}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Sipariş Özeti ve Butonlar */}
|
|
|
|
|
|
<div className="bg-white rounded-xl shadow border p-6">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<h3 className="text-lg font-semibold text-gray-900 mb-4">
|
|
|
|
|
|
{translate('::Public.payment.summary.title')}
|
|
|
|
|
|
</h3>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
|
|
|
|
|
|
<div className="space-y-4 mb-4">
|
|
|
|
|
|
{cartState.items.map((item, index) => (
|
|
|
|
|
|
<div key={`${item.product.id}-${index}`} className="flex justify-between text-sm">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div className="font-medium">{item.product.name}</div>
|
|
|
|
|
|
<div className="text-gray-500">
|
|
|
|
|
|
{item.quantity}x -{' '}
|
|
|
|
|
|
{item.billingCycle === 'monthly'
|
|
|
|
|
|
? 'Aylık'
|
|
|
|
|
|
: item.billingCycle === 'yearly'
|
|
|
|
|
|
? 'Yıllık'
|
|
|
|
|
|
: 'Aylık'}{' '}
|
|
|
|
|
|
{cartState.globalPeriod > 1 &&
|
|
|
|
|
|
`(${cartState.globalPeriod} ${item.billingCycle === 'monthly' ? 'Ay' : 'Yıl'})`}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="font-medium">{formatPrice(item.totalPrice)}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="space-y-1 text-sm border-t border-gray-200 pt-4 text-gray-600">
|
|
|
|
|
|
<div className="flex justify-between">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span>{translate('::Public.payment.summary.subtotal')}</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{formatPrice(cartState.total)}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex justify-between">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span>{translate('::Public.payment.summary.commission')}</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>{formatPrice(commission)}</span>
|
|
|
|
|
|
</div>
|
2025-10-08 14:08:34 +00:00
|
|
|
|
{selectedPaymentMethod === defaultPaymentMethod &&
|
|
|
|
|
|
selectedInstallment?.installment &&
|
|
|
|
|
|
selectedInstallment.installment > 1 && (
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<div className="flex justify-between text-blue-600">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span>{translate('::Public.payment.summary.monthlyInstallment')}: </span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span>
|
2025-10-08 14:08:34 +00:00
|
|
|
|
{formatPrice(finalTotal / selectedInstallment.installment)} x{' '}
|
|
|
|
|
|
{selectedInstallment.installment}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<div className="flex justify-between text-base font-bold pt-2 text-gray-900">
|
2025-08-17 19:07:04 +00:00
|
|
|
|
<span>{translate('::Public.payment.summary.total')}</span>
|
2025-08-11 06:34:44 +00:00
|
|
|
|
<span className="text-blue-600">{formatPrice(finalTotal)}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Butonlar */}
|
|
|
|
|
|
<div className="flex justify-between items-center mt-6">
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
onClick={onBack}
|
|
|
|
|
|
className="flex items-center px-6 py-3 border border-gray-300 text-gray-700 rounded-lg"
|
|
|
|
|
|
>
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaArrowLeft className="w-4 h-4 mr-2" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
{translate('::Public.payment.buttons.back')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="submit"
|
|
|
|
|
|
className="flex items-center justify-center px-6 py-3 bg-green-600 text-white rounded-lg"
|
|
|
|
|
|
>
|
2025-08-16 19:47:24 +00:00
|
|
|
|
<FaCreditCard className="w-5 h-5 mr-2" />
|
2025-08-17 19:07:04 +00:00
|
|
|
|
{selectedPaymentMethod === 'bank-transfer'
|
|
|
|
|
|
? translate('::Public.payment.buttons.completeOrder')
|
|
|
|
|
|
: translate('::Public.payment.buttons.pay')}
|
2025-08-11 06:34:44 +00:00
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|