결제 이벤트가 발생할 때 서버리스 함수 및 백그라운드 작업을 자동으로 실행합니다. 결제를 처리하고, 알림을 전송하며, 데이터베이스를 업데이트하고, Inngest의 신뢰할 수 있는 함수 실행 플랫폼을 통해 복잡한 워크플로를 실행합니다.
이 통합을 사용하려면 함수 구성에서 Inngest 웹후크 URL이 필요합니다.
시작하기
Open the Webhook Section
Dodo Payments 대시보드에서 Webhooks → + Add Endpoint로 이동하고 통합 드롭다운을 확장합니다. Select Inngest
Inngest 통합 카드를 선택합니다.
Create Inngest Function
Inngest에서 새 함수를 생성하고 함수 구성에서 웹후크 URL을 복사합니다.
Paste Webhook URL
Inngest 웹후크 URL을 엔드포인트 구성에 붙여넣습니다.
Configure Transformation
Inngest 함수에 맞게 이벤트를 형식화하도록 변환 코드를 편집합니다.
Test & Create
샘플 페이로드로 테스트한 다음 Create를 클릭하여 통합을 활성화합니다.
Done!
🎉 결제 이벤트가 이제 Inngest 함수를 자동으로 트리거합니다.
변환 코드 예제
기본 이벤트 페이로드
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;
}
구독 이벤트 핸들러
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;
}
분쟁 이벤트 핸들러
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 함수 로그에서 오류를 검토
Data not received correctly
- 페이로드 구조가 Inngest 기대치와 일치하는지 확인
- 이벤트 이름이 올바르게 형식화되었는지 확인
- 필수 필드가 모두 포함되었는지 확인
- Inngest의 웹후크 테스트 도구로 테스트