결제 및 구독 이벤트가 발생할 때 전문적인 트랜잭셔널 이메일을 자동으로 보냅니다. 중간 서버가 필요 없이 Keplars를 통해 결제 확인, 구독 업데이트 및 실패 알림을 전달합니다. Dodo Payments는 JavaScript 변환 핸들러를 사용하여 Keplars API를 직접 호출합니다.
이 통합은 인증을 위해 Keplars API 키가 필요합니다. Keplars 대시보드에서 Settings → API Keys 아래에서 찾을 수 있으며, Domains 아래에서 발신 도메인 또는 주소를 확인하세요.
시작하기
Open the Webhook Section
Dodo Payments 대시보드에서 Webhooks → + Add Endpoint 로 이동하고 통합 드롭다운을 확장합니다.
Enter API Key
Keplars API 키를 입력합니다. 이는 모든 요청에 Bearer 토큰으로 전송됩니다.
Configure Transformation
이메일을 Keplars에 맞게 형식화하기 위해 변환 코드를 편집합니다. 자리 표시자 발신 주소 및 템플릿 ID를 자신의 것으로 교체하세요.
Test & Create
샘플 페이로드로 테스트하고 Create 를 클릭하여 이메일 보내기를 활성화합니다.
Done!
🎉 이제 결제 이벤트가 발생하면 Keplars를 통해 자동으로 트랜잭셔널 이메일이 전송됩니다.
변환 코드 예제
각 핸들러는 webhook.url을 Keplars 고우선순위 전송 엔드포인트에 설정하고 webhook.payload을 Keplars 요청으로 변환합니다 (API 키는 자동으로 Bearer 토큰으로 전송됩니다). payments@mail.yourdomain.com를 인증된 발신자로, your-keplars-*-template-id를 실제 템플릿 ID로 교체하세요.
to은 배열 이어야 하며, 수신자가 하나인 경우에도 그렇습니다. template_id를 사용할 때 subject나 body를 보내지 마십시오 . 템플릿이 이를 제공합니다.
결제 확인 이메일
function handler ( webhook ) {
if ( webhook . eventType !== "payment.succeeded" ) return webhook ;
const data = webhook . payload . data || {};
const paymentDate = new Date ( webhook . payload . timestamp ). toLocaleDateString ( "en-US" , {
year: "numeric" , month: "long" , day: "numeric" ,
});
webhook . url = "https://api.keplars.com/api/v1/send-email/high" ;
webhook . payload = {
to: [ data . customer ?. email ],
from: "payments@mail.yourdomain.com" ,
template_id: "your-keplars-payment-success-template-id" ,
params: {
customer_name: data . customer ?. name ,
amount: (( data . total_amount || 0 ) / 100 ). toFixed ( 2 ),
currency: data . currency || "USD" ,
payment_id: data . payment_id ,
payment_method: data . payment_method ,
payment_date: paymentDate ,
},
};
return webhook ;
}
See all 24 lines
결제 실패 알림
function handler ( webhook ) {
if ( webhook . eventType !== "payment.failed" ) return webhook ;
const data = webhook . payload . data || {};
const paymentDate = new Date ( webhook . payload . timestamp ). toLocaleDateString ( "en-US" , {
year: "numeric" , month: "long" , day: "numeric" ,
});
webhook . url = "https://api.keplars.com/api/v1/send-email/high" ;
webhook . payload = {
to: [ data . customer ?. email ],
from: "payments@mail.yourdomain.com" ,
template_id: "your-keplars-payment-failed-template-id" ,
params: {
customer_name: data . customer ?. name ,
amount: (( data . total_amount || 0 ) / 100 ). toFixed ( 2 ),
currency: data . currency || "USD" ,
payment_id: data . payment_id ,
error_message: data . error_message || "Your payment could not be processed." ,
payment_date: paymentDate ,
},
};
return webhook ;
}
See all 24 lines
구독 환영 이메일
function handler ( webhook ) {
if ( webhook . eventType !== "subscription.active" ) return webhook ;
const data = webhook . payload . data || {};
const nextBilling = data . next_billing_date
? new Date ( data . next_billing_date ). toLocaleDateString ( "en-US" , {
year: "numeric" , month: "long" , day: "numeric" ,
})
: "" ;
webhook . url = "https://api.keplars.com/api/v1/send-email/high" ;
webhook . payload = {
to: [ data . customer ?. email ],
from: "payments@mail.yourdomain.com" ,
template_id: "your-keplars-subscription-active-template-id" ,
params: {
customer_name: data . customer ?. name ,
subscription_id: data . subscription_id ,
product_id: data . product_id ,
amount: (( data . recurring_pre_tax_amount || 0 ) / 100 ). toFixed ( 2 ),
currency: data . currency || "USD" ,
billing_interval: data . payment_frequency_interval || "month" ,
next_billing_date: nextBilling ,
},
};
return webhook ;
}
See all 27 lines
구독 취소 이메일
subscription_cancelled.js
function handler ( webhook ) {
if ( webhook . eventType !== "subscription.cancelled" ) return webhook ;
const data = webhook . payload . data || {};
const cancellationDate = new Date ( webhook . payload . timestamp ). toLocaleDateString ( "en-US" , {
year: "numeric" , month: "long" , day: "numeric" ,
});
webhook . url = "https://api.keplars.com/api/v1/send-email/high" ;
webhook . payload = {
to: [ data . customer ?. email ],
from: "payments@mail.yourdomain.com" ,
template_id: "your-keplars-subscription-cancelled-template-id" ,
params: {
customer_name: data . customer ?. name ,
subscription_id: data . subscription_id ,
cancellation_date: cancellationDate ,
},
};
return webhook ;
}
See all 21 lines
더 나은 전달성을 위해 인증된 발신 도메인 또는 주소를 사용하세요.
각 이벤트 유형에 대해 전용 Keplars 템플릿을 생성하여 모든 이메일이 브랜드와 메시지에 부합하도록 하세요.
고객 이름, 금액, 결제 ID와 같은 데이터를 전달하여 각 이메일을 개인화하세요.
먼저 샌드박스 모드에서 테스트하세요. 샌드박스 전송은 Keplars 테스트 인박스에 캡처되며 전달되지 않습니다.
문제 해결
Keplars의 Settings → API Keys 에서 API 키가 올바르고 활성화되어 있는지 확인하세요.
발신 도메인 또는 주소가 인증되었는지 확인하세요.
Dodo Payments는 webhook 전달 로그에 Keplars의 원시 오류 응답을 보여줍니다. 세부정보를 확인하세요.
핸들러의 template_id는 Keplars 계정의 활성 템플릿과 일치해야 합니다. 대시보드에서 ID가 활성 상태인지 확인하세요.
각 핸들러는 webhook.eventType을 검사하고 일치하지 않으면 조기에 반환합니다. Dodo Payments webhook 엔드포인트에서 올바른 이벤트가 구독되었는지 확인하세요.