Skip to content

Commit

Permalink
fix: 결제 수정
Browse files Browse the repository at this point in the history
fix: 결제 수정
  • Loading branch information
jeongs9203 committed Nov 29, 2023
2 parents 585c90c + d5831f8 commit 42888d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
13 changes: 4 additions & 9 deletions src/components/CheckoutList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
'use client';

import ShippingAddress from '@/components/Checkout/ShippingAddress';
import { paymentProductList } from '@/data/paymentProductList';
import ButtonPrimary from '@/shared/Button/ButtonPrimary';
import {
DeliveryOrdersInRequest,
PaymentByProductList,
vendorsOrderListInRequest,
} from '@/types/payment/payment';
import {
CheckoutPriceType,
Expand All @@ -17,8 +14,9 @@ import { useEffect, useState } from 'react';
import Payment from './Payment';
import RenderProduct2 from './RenderProduct2';
import Icon from './Icon';
import { BrandProductCartDto, CartIdType } from '@/types/cartType';
import { CartIdType } from '@/types/cartType';
import { AddressType } from '@/types/userType';
import { nanoid } from "nanoid";

/**
* 장바구니 상품 출력
Expand All @@ -33,8 +31,6 @@ export default function CheckoutList() {
const [paymentProduct, setPaymentProduct] = useState<PaymentByProductList[]>(
[]
); // 결제할 상품들
const [delivery, setDelivery] = useState<DeliveryOrdersInRequest>();
const [order, setOrder] = useState<vendorsOrderListInRequest[]>([]);
const [paymentClicked, setPaymentClicked] = useState(false);
// 페칭 후 저장할 가격 정보
const [price, setPrice] = useState<CheckoutPriceType>();
Expand Down Expand Up @@ -234,7 +230,7 @@ export default function CheckoutList() {
brandProduct.orderProductInfoDto.map((product) => ({
vendorEmail: product.vendorEmail, // 여기에 적절한 값 필요
productName: product.productName,
productCode: product.productCode, // 여기에 적절한 값 필요
productCode: nanoid(), // 여기에 적절한 값 필요
productMainImageUrl: product.imgUrl,
productAmount: product.productPrice,
count: product.count,
Expand Down Expand Up @@ -307,7 +303,7 @@ export default function CheckoutList() {

return productInCartIds;
};

/**
* 주문자 정보, 결제 수단 출력
*/
Expand All @@ -328,7 +324,6 @@ export default function CheckoutList() {
paymentClicked={paymentClicked}
setPaymentClicked={setPaymentClicked}
paymentProduct={paymentProduct}

// price={parseInt(price?.totalPriceString.replace(/[₩,]/g, ""))}
price={price?.totalPrice || 0}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ function Payment({
const paymentMethodsWidgetRef = useRef<ReturnType<
PaymentWidgetInstance["renderPaymentMethods"]
> | null>(null);

useAsync(async () => {
const paymentWidget = await loadPaymentWidget('test_ck_jExPeJWYVQ1RezQ2XYPnV49R5gvN', nanoid());
const paymentMethodsWidget = paymentWidget.renderPaymentMethods(

"#payment-widget",
{ value: price },
// { variantKey: "DEFAULT" }
{ variantKey: "DEFAULT" }
);
paymentWidget.renderAgreement("#agreement");

Expand All @@ -54,6 +54,7 @@ function Payment({
totalAmount: price,
successUrl: `${window.location.origin}/checkout/success`,
failUrl: `${window.location.origin}/checkout/fail`,
amount: price,
});
} catch (error) {
toast.custom((t) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ai/Ai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Ai() {
console.log('formData: ', formData.get('img'))
try {

const res = await fetch(`https://gentledog-ai.duckdns.org/image_predict`, {
const res = await fetch(`https://gentledogai.duckdns.org/image_predict`, {
method: 'POST',
body: formData,
});
Expand Down

0 comments on commit 42888d2

Please sign in to comment.