-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from sw326/dev
Dev
- Loading branch information
Showing
28 changed files
with
8,822 additions
and
7,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"CORSRules": [ | ||
{ | ||
"AllowedOrigins": [ | ||
"https://your-domain.com" | ||
], | ||
"AllowedMethods": [ | ||
"GET", | ||
"HEAD" | ||
], | ||
"AllowedHeaders": [ | ||
"*" | ||
], | ||
"MaxAgeSeconds": 3000 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import api from './axiosConfig'; | ||
import { PaymentRequest, PaymentResponse } from '../types/portone'; | ||
|
||
export const getPaymentData = async ( | ||
estimateId: number, | ||
): Promise<PaymentRequest> => { | ||
const response = await api.get<PaymentRequest>( | ||
`/payments/data/${estimateId}`, | ||
); | ||
return response.data; | ||
}; | ||
|
||
export const completePayment = async ( | ||
impUid: string, | ||
): Promise<PaymentResponse> => { | ||
const response = await api.get<PaymentResponse>(`/payments/${impUid}`); | ||
return response.data; | ||
}; | ||
|
||
export const cancelPayment = async ( | ||
merchantUid: string, | ||
reason: string, | ||
): Promise<PaymentResponse> => { | ||
const response = await api.post<PaymentResponse>( | ||
`/payment/cancel/${merchantUid}`, | ||
{ reason }, | ||
); | ||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
|
||
interface SimplePayButtonProps { | ||
id: string; | ||
name: string; | ||
icon: string; | ||
isSelected: boolean; | ||
onClick: (id: string) => void; | ||
} | ||
|
||
const SimplePayButton: React.FC<SimplePayButtonProps> = ({ | ||
id, | ||
name, | ||
icon, | ||
isSelected, | ||
onClick, | ||
}) => ( | ||
<button | ||
className={`flex items-center justify-start w-full p-3 border rounded-lg transition-colors ${ | ||
isSelected ? 'bg-brand text-white' : 'hover:bg-gray-50' | ||
}`} | ||
onClick={() => onClick(id)} | ||
> | ||
<img src={icon} alt={name} className="w-6 h-6 mr-3" /> | ||
<span className="flex-grow text-left">{name}</span> | ||
</button> | ||
); | ||
|
||
const SimplePaySection: React.FC<{ | ||
simplePayMethod: string; | ||
setSimplePayMethod: (method: string) => void; | ||
}> = ({ simplePayMethod, setSimplePayMethod }) => { | ||
const simplePay = [ | ||
{ id: 'naverpay', name: '네이버 페이', icon: '/public/NaverIcon.webp' }, | ||
{ id: 'kakaopay', name: '카카오 페이', icon: '/public/KakaoIcon.webp' }, | ||
{ id: 'ssgpay', name: 'SSG 페이', icon: '/public/SsgIcon.webp' }, | ||
{ id: 'samsungpay', name: '삼성 페이', icon: '/public/SamsungIcon.png' }, | ||
]; | ||
|
||
return ( | ||
<div className="mb-8"> | ||
<h3 className="text-lg font-semibold mb-2">간편 결제 선택</h3> | ||
<div className="grid grid-cols-2 gap-4"> | ||
{simplePay.map(method => ( | ||
<SimplePayButton | ||
key={method.id} | ||
{...method} | ||
isSelected={simplePayMethod === method.id} | ||
onClick={setSimplePayMethod} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SimplePaySection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useMutation, useQuery } from '@tanstack/react-query'; | ||
import * as api from '../api/payment'; | ||
import { PaymentRequest, PaymentResponse } from '../types/portone'; | ||
|
||
export const useGetPaymentData = (estimateId: number) => { | ||
return useQuery<PaymentRequest, Error>({ | ||
queryKey: ['paymentData', estimateId], | ||
queryFn: () => api.getPaymentData(estimateId), | ||
}); | ||
}; | ||
|
||
export const useCompletePayment = () => { | ||
return useMutation<PaymentResponse, Error, string>({ | ||
mutationFn: (impUid: string) => api.completePayment(impUid), | ||
}); | ||
}; | ||
|
||
export const useCancelPayment = () => { | ||
return useMutation< | ||
PaymentResponse, | ||
Error, | ||
{ merchantUid: string; reason: string } | ||
>({ | ||
mutationFn: ({ merchantUid, reason }) => | ||
api.cancelPayment(merchantUid, reason), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.