메인 콘텐츠로 건너뛰기

소개

결제 이벤트가 발생할 때 서버리스 함수 및 백그라운드 작업을 자동으로 실행합니다. 결제를 처리하고, 알림을 전송하며, 데이터베이스를 업데이트하고, Inngest의 신뢰할 수 있는 함수 실행 플랫폼을 통해 복잡한 워크플로를 실행합니다.
이 통합은 함수 구성에서 Inngest 웹훅 URL이 필요합니다.

시작하기

1

웹훅 섹션 열기

Dodo Payments 대시보드에서 Webhooks → + Add Endpoint로 이동하고 통합 드롭다운을 확장합니다.
Add Endpoint and integrations dropdown
2

Inngest 선택하기

Inngest 통합 카드를 선택합니다.
3

Inngest 함수 만들기

Inngest에서 새 함수를 만들고 함수 구성에서 웹훅 URL을 복사합니다.
4

웹훅 URL 붙여넣기

Inngest 웹훅 URL을 엔드포인트 구성에 붙여넣습니다.
5

변환 구성하기

Inngest 함수에 맞게 이벤트를 포맷하기 위해 변환 코드를 편집합니다.
6

테스트 및 생성

샘플 페이로드로 테스트하고 Create를 클릭하여 통합을 활성화합니다.
7

완료!

🎉 이제 결제 이벤트가 자동으로 Inngest 함수를 트리거합니다.

변환 코드 예제

기본 이벤트 페이로드

basic_event.js
function handler(webhook) {
  if (webhook.eventType === "payment.succeeded") {
    const p = webhook.payload.data;
    webhook.payload = {
      name: "payment.succeeded",
      data: {
        payment_id: p.payment_id,
        amount: (p.total_amount / 100).toFixed(2),
        currency: p.currency || "USD",
        customer_email: p.customer.email,
        customer_name: p.customer.name,
        payment_method: p.payment_method || "unknown"
      },
      user: {
        email: p.customer.email
      },
      ts: Math.floor(new Date(webhook.payload.timestamp).getTime() / 1000)
    };
  }
  return webhook;
}

구독 이벤트 핸들러

subscription_event.js
function handler(webhook) {
  const s = webhook.payload.data;
  switch (webhook.eventType) {
    case "subscription.active":
      webhook.payload = {
        name: "subscription.started",
        data: {
          subscription_id: s.subscription_id,
          customer_email: s.customer.email,
          customer_name: s.customer.name,
          product_id: s.product_id,
          amount: (s.recurring_pre_tax_amount / 100).toFixed(2),
          frequency: s.payment_frequency_interval,
          next_billing: s.next_billing_date
        },
        user: {
          email: s.customer.email
        },
        ts: Math.floor(new Date(webhook.payload.timestamp).getTime() / 1000)
      };
      break;
    case "subscription.cancelled":
      webhook.payload = {
        name: "subscription.cancelled",
        data: {
          subscription_id: s.subscription_id,
          customer_email: s.customer.email,
          cancelled_at: s.cancelled_at,
          cancel_at_next_billing: s.cancel_at_next_billing_date
        },
        user: {
          email: s.customer.email
        },
        ts: Math.floor(new Date(webhook.payload.timestamp).getTime() / 1000)
      };
      break;
  }
  return webhook;
}

분쟁 이벤트 핸들러

dispute_event.js
function handler(webhook) {
  if (webhook.eventType.startsWith("dispute.")) {
    const d = webhook.payload.data;
    webhook.payload = {
      name: webhook.eventType,
      data: {
        dispute_id: d.dispute_id,
        payment_id: d.payment_id,
        amount: (d.amount / 100).toFixed(2),
        status: d.dispute_status,
        stage: d.dispute_stage,
        remarks: d.remarks || "",
        urgent: webhook.eventType === "dispute.opened"
      },
      user: {
        email: d.customer?.email || "unknown"
      },
      ts: Math.floor(new Date(webhook.payload.timestamp).getTime() / 1000)
    };
  }
  return webhook;
}

일반적인 Inngest 사용 사례

  • 확인 이메일 전송
  • 고객 기록 업데이트
  • 환불 처리
  • 송장 생성
  • 재고 업데이트
  • 신규 구독자 환영
  • 취소 처리
  • 갱신 알림 전송
  • 청구 주기 업데이트
  • 실패한 결제 처리
  • 수익 지표 업데이트
  • 고객 행동 추적
  • 보고서 생성
  • 데이터 분석 플랫폼에 동기화
  • 이탈률 계산

  • 더 나은 함수 조직을 위해 설명적인 이벤트 이름 사용
  • 함수 실행을 위한 사용자 컨텍스트 포함
  • 이벤트 순서를 위한 적절한 타임스탬프 설정
  • 이벤트 간 데이터 구조를 일관되게 유지
  • Inngest의 재시도 및 오류 처리 기능 사용

문제 해결

  • 웹훅 URL이 올바르고 활성화되어 있는지 확인
  • Inngest 함수가 배포되고 활성화되어 있는지 확인
  • 이벤트 이름이 함수 트리거와 일치하는지 확인
  • Inngest 함수 로그에서 오류 검토
  • 페이로드 구조가 Inngest의 기대와 일치하는지 확인
  • 이벤트 이름이 올바르게 포맷되었는지 확인
  • 모든 필수 필드가 포함되어 있는지 확인
  • Inngest의 웹훅 테스트 도구로 테스트