Overview
Billing attempt webhooks notify your app when subscription billing attempts succeed or fail, and when billing cycles are skipped. These webhooks are essential for implementing dunning management, payment retry logic, and customer notifications.Webhook Topics
subscription_billing_attempts/success
Triggered when a billing attempt for a subscription contract succeeds and an order is created.This webhook fires after Shopify successfully charges the customer’s payment method and creates a new order for the subscription.
Webhook Configuration
Payload Structure
The numeric ID of the billing attempt
The GraphQL Admin API ID of the billing attempt (format:
gid://shopify/SubscriptionBillingAttempt/{id})A unique key that can be used to identify this billing attempt across retries
The numeric ID of the order created by this billing attempt (may be null initially)
The GraphQL Admin API ID of the order created (may be null initially)
The numeric ID of the subscription contract being billed
The GraphQL Admin API ID of the subscription contract
Indicates whether the billing attempt is ready for processing
Error message if there were any issues (null for successful attempts)
Error code if there were any issues (null for successful attempts)
Example Payload
Handler Implementation
The reference app stops any active dunning processes and tags the recurring order:The handler immediately stops any dunning process (payment retry sequence) since the payment was successful, and tags the order for easy identification.
subscription_billing_attempts/failure
Triggered when a billing attempt for a subscription contract fails.This webhook is critical for implementing dunning management - the process of retrying failed payments and notifying customers about payment issues.
Webhook Configuration
Payload Structure
The numeric ID of the billing attempt
The GraphQL Admin API ID of the billing attempt
A unique key for this billing attempt
The order ID (null for failed attempts)
The GraphQL Admin API order ID (null for failed attempts)
The numeric ID of the subscription contract
The GraphQL Admin API ID of the subscription contract
Indicates whether the billing attempt is ready
A description of why the billing attempt failed
A code identifying the type of error. Common codes include:
insufficient_inventory- Not enough product inventoryinventory_allocations_not_found- Inventory allocation issuespayment_method_declined- Payment method was declinedauthentication_required- Payment requires authentication (3D Secure)
Example Payload
Handler Implementation
The reference app starts a dunning process to handle the failed payment:The dunning process typically includes:
- Sending customer notifications about the failed payment
- Attempting to retry the payment on a schedule
- Pausing or cancelling the subscription after multiple failures
subscription_billing_cycles/skip
Triggered when a billing cycle is skipped for a subscription contract.Customers can skip upcoming deliveries, which triggers this webhook. This is useful for notifying customers about the skipped cycle.
Webhook Configuration
Payload Structure
The numeric ID of the subscription contract (as a string)
ISO 8601 timestamp of when the cycle starts
ISO 8601 timestamp of when the cycle ends
The index number of the billing cycle being skipped (0-based)
ISO 8601 timestamp of when the billing attempt was expected
Indicates that the cycle was skipped (will be true)
Indicates whether the cycle was edited
Contract edit details (typically null for skip operations)
Example Payload
Handler Implementation
The reference app sends a notification email to the customer about the skipped cycle:The handler converts the numeric subscription contract ID to a GraphQL GID format using the
composeGid utility from @shopify/admin-graphql-api-utilities.Error Handling
When handling billing attempt failures, you should implement logic based on the error code:| Error Code | Description | Recommended Action |
|---|---|---|
payment_method_declined | Payment method was declined | Notify customer to update payment method |
authentication_required | 3D Secure authentication needed | Send customer link to authenticate |
insufficient_inventory | Not enough product stock | Notify merchant, pause subscription |
inventory_allocations_not_found | Inventory system issue | Retry later, notify merchant |
Best Practices
- Dunning Management: Implement a progressive dunning strategy that retries payments over several days before cancelling
- Customer Communication: Always notify customers about failed payments and provide clear instructions for updating payment methods
- Inventory Errors: Handle inventory-related failures differently from payment failures
- Monitoring: Track billing attempt success/failure rates to identify issues early
- Idempotency: Use the
idempotency_keyto prevent duplicate processing of the same billing attempt