자동결제

() .

.
() .

()는 promise .
const { tossAutomaticPaymentsResponse: response } = await fetchProducePaymentRequest({
      pgServiceCode: 'toss',
      type: 'automatic',
    }).unwrap();

    tossPayments = await loadTossPayments(response.clientKey);
    tossPayments
      .requestBillingAuth('카드', {
        customerKey: response.customerKey,
        successUrl: `${env('APP_BASE_URL')}/test/paygate`,
        failUrl: `${env('APP_BASE_URL')}api/paygate/close`,
      })
      .catch((err) => {
        Object.keys(TossPaymentsErrorCode).forEach((errCode) => {
          if (err.code === errCode) {
            return notify.error(TossPaymentsErrorCode[errCode]);
          } else {
            return notify.error('잠시후 다시 시도해주세요');
          }
        });
      });


successUrl 나 failUrl location.href router.push (promise ) ifame 내부에서 이동하는 방식.
Was this page helpful?