#How can I obtain the Retry Payment Link when a subscription creation fails due to payment issues?

1 messages · Page 1 of 1 (latest)

vagrant topaz
#

If the subscription creation fails due to a mandate or payment failure, which webhook will be called?

subscription.failed or payment.failed

In this case, I want to trigger an email to the customer to retry the payment with retry payment link.

rugged cypressBOT
#

If a subscription creation fails due to a mandate or payment failure, the subscription.failed webhook will be triggered. This event specifically indicates that the subscription creation failed during the mandate creation process【4:0†source】.

To address the situation by triggering an email to the customer with a retry payment link, you can use the payment.failed webhook to notify the customer. Here's how you can implement this:

  1. Webhook Handling: Set up your webhook endpoint to listen for payment.failed events.
  2. Email Trigger: Upon receiving a payment.failed event, use a service like SendGrid or Resend to send an email to the customer.
  3. Email Content: The email should include a message about the payment failure and a link for the customer to retry the payment. You can construct the retry link using the payment ID or a similar identifier.

Here's a basic example of how you could structure the email notification using JavaScript:

function handler(webhook) {
  if (webhook.eventType === "payment.failed") {
    const p = webhook.payload.data;
    webhook.url = "https://api.your-email-service.com/send";
    webhook.payload = {
      from: "[email protected]",
      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/retry-payment/${p.payment_id}">Retry Payment</a>
, text: Payment Failed: We couldn't process your $${(p.total_amount / 100).toFixed(2)} payment. Please update your payment method.`
};
}
return webhook;
}


This approach ensures that your customers are informed promptly and have a clear path to resolve the payment issue【4:2†source】【4:6†source】.

### Helpful Links
- [Dodo Payments Webhook Events Guide](https://docs.dodopayments.com/developer-resources/webhooks/intents/webhook-events-guide)
- [Integrating Webhooks with Dodo Payments](https://docs.dodopayments.com/developer-resources/integration-guide#implementing-webhooks)
- [Using SendGrid for Transactional Emails](https://docs.dodopayments.com/integrations/sendgrid)
Dodo Payments Documentation

Understand the different webhook events triggered by Dodo Payments during payment, refund, subscription, dispute, and license key activities

Dodo Payments Documentation

Send transactional emails based on Dodo Payments events using SendGrid's Mail Send API.

Dodo Payments Documentation

This guide will help you integrate the Dodo Payments API into your website.

vagrant topaz
lilac thunder
#

You can create a new payment link and share it to your customer.

vagrant topaz
#

Is there any resource to make payment link