> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resend

> Dodo Payments 이벤트에 따라 높은 배달률로 Resend를 통해 거래 이메일을 전송합니다.

## 소개

결제 이벤트가 발생할 때 전문적인 거래 이메일을 자동으로 전송합니다. Resend의 신뢰할 수 있는 이메일 인프라와 우수한 배달률을 통해 결제 확인, 구독 업데이트 및 중요한 알림을 전달하세요.

<Info>
  이 통합에는 인증을 위해 Resend API 키가 필요합니다.
</Info>

## 시작하기

<Steps>
  <Step title="Open the Webhook Section">
    Dodo Payments 대시보드에서 <b>Webhooks → + 엔드포인트 추가</b>로 이동하고 통합 드롭다운을 확장합니다.

    <Frame>
      <img src="https://mintcdn.com/dodopayments/slbAEdrLLwKHfaRf/images/integrations/resend.png?fit=max&auto=format&n=slbAEdrLLwKHfaRf&q=85&s=80191f648ad4a4f4b5e8186668da0791" alt="Add Endpoint and integrations dropdown" style={{ maxHeight: '500px', width: 'auto' }} width="1668" height="946" data-path="images/integrations/resend.png" />
    </Frame>
  </Step>

  <Step title="Select Resend">
    <b>Resend</b> 통합 카드를 선택합니다.
  </Step>

  <Step title="Enter API Key">
    구성에 Resend API 키를 입력합니다.
  </Step>

  <Step title="Configure Transformation">
    Resend API에 맞게 이메일 형식을 지정하도록 변환 코드를 편집합니다.
  </Step>

  <Step title="Test & Create">
    샘플 페이로드로 테스트한 후 <b>Create</b>를 클릭하여 이메일 전송을 활성화합니다.
  </Step>

  <Step title="Done!">
    🎉 이제 결제 이벤트가 Resend를 통해 자동으로 트랜잭션 이메일을 트리거합니다.
  </Step>
</Steps>

## 변환 코드 예제

### 결제 확인 이메일

```javascript payment_confirmation.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType === "payment.succeeded") {
    const p = webhook.payload.data;
    webhook.url = "https://api.resend.com/emails";
    webhook.payload = {
      from: "payments@yourdomain.com",
      to: [p.customer.email],
      subject: "Payment Confirmation - $" + (p.total_amount / 100).toFixed(2),
      html: `
        <h2>Payment Successful!</h2>
        <p>Hi ${p.customer.name},</p>
        <p>Your payment of $${(p.total_amount / 100).toFixed(2)} has been processed successfully.</p>
        <ul>
          <li><strong>Payment ID:</strong> ${p.payment_id}</li>
          <li><strong>Amount:</strong> $${(p.total_amount / 100).toFixed(2)}</li>
          <li><strong>Date:</strong> ${new Date(webhook.payload.timestamp).toLocaleDateString()}</li>
          <li><strong>Method:</strong> ${p.payment_method || "Unknown"}</li>
        </ul>
        <p>Thank you for your business!</p>
      `,
      text: `Payment Successful! Your payment of $${(p.total_amount / 100).toFixed(2)} has been processed. Payment ID: ${p.payment_id}`
    };
  }
  return webhook;
}
```

### 구독 환영 이메일

```javascript subscription_welcome.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType === "subscription.active") {
    const s = webhook.payload.data;
    webhook.url = "https://api.resend.com/emails";
    webhook.payload = {
      from: "welcome@yourdomain.com",
      to: [s.customer.email],
      subject: "Welcome to Your Subscription!",
      html: `
        <h2>Welcome to Your Subscription!</h2>
        <p>Hi ${s.customer.name},</p>
        <p>Your subscription has been activated successfully.</p>
        <ul>
          <li><strong>Subscription ID:</strong> ${s.subscription_id}</li>
          <li><strong>Product:</strong> ${s.product_id}</li>
          <li><strong>Amount:</strong> $${(s.recurring_pre_tax_amount / 100).toFixed(2)}/${s.payment_frequency_interval}</li>
          <li><strong>Next Billing:</strong> ${new Date(s.next_billing_date).toLocaleDateString()}</li>
        </ul>
        <p>You can manage your subscription anytime from your account dashboard.</p>
      `,
      text: `Welcome! Your subscription is now active. Amount: $${(s.recurring_pre_tax_amount / 100).toFixed(2)}/${s.payment_frequency_interval}`
    };
  }
  return webhook;
}
```

### 결제 실패 알림

```javascript payment_failure.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType === "payment.failed") {
    const p = webhook.payload.data;
    webhook.url = "https://api.resend.com/emails";
    webhook.payload = {
      from: "support@yourdomain.com",
      to: [p.customer.email],
      subject: "Payment Failed - Action Required",
      html: `
        <h2>Payment Failed</h2>
        <p>Hi ${p.customer.name},</p>
        <p>We were unable to process your payment of $${(p.total_amount / 100).toFixed(2)}.</p>
        <ul>
          <li><strong>Payment ID:</strong> ${p.payment_id}</li>
          <li><strong>Amount:</strong> $${(p.total_amount / 100).toFixed(2)}</li>
          <li><strong>Error:</strong> ${p.error_message || "Payment processing failed"}</li>
        </ul>
        <p>Please update your payment method or contact support for assistance.</p>
        <a href="https://yourdomain.com/update-payment">Update Payment Method</a>
      `,
      text: `Payment Failed: We couldn't process your $${(p.total_amount / 100).toFixed(2)} payment. Please update your payment method.`
    };
  }
  return webhook;
}
```

## 팁

* 더 나은 배달률을 위해 검증된 발신자 도메인을 사용하세요
* 이메일의 HTML 및 텍스트 버전을 모두 포함하세요
* 고객 데이터로 콘텐츠를 개인화하세요
* 명확하고 행동 지향적인 제목을 사용하세요
* 준수를 위해 구독 취소 링크를 포함하세요
* 라이브 전 이메일 템플릿을 테스트하세요

## 문제 해결

<AccordionGroup>
  <Accordion title="Emails not being sent">
    * API 키가 올바르고 활성 상태인지 확인합니다
    * 발신자 도메인이 Resend에서 확인되었는지 확인합니다
    * 수신자 이메일 주소가 유효한지 확인합니다
    * Resend 전송 한도 및 할당량을 검토합니다
  </Accordion>

  <Accordion title="Transformation errors">
    * JSON 구조가 Resend API 형식과 일치하는지 검증합니다
    * 모든 필수 필드가 있는지 확인합니다
    * HTML 콘텐츠가 올바르게 형식화되었는지 확인합니다
    * 보내는 이메일 주소가 확인되었는지 검증합니다
  </Accordion>
</AccordionGroup>
