Webhook handling
Here is how Stripe Billing Events are integrated into Piano, so that you can understand how critical subscription actions take place between the Stripe and Piano systems.
Stripe Billing Events
|
Event Type |
Description |
Piano Billing Integration Processing |
|
Customer's subscription ends. |
Expire Piano subscription by setting to Expired status when deleted in Stripe (by setting it to expired it will become inactive). |
|
|
New invoice created. |
Extend Piano access, confirm or update TaxRate ID, verify invoice.
|
|
|
Draft invoice deleted. |
Piano access not extended, set payment status to ABORTED. If Stripe invoice is deleted, charge is skipped for that cycle. |
|
|
Emit an event X days before an auto-charged subscription invoice is generated (configurable; recommended X = 3 days). |
Verify the invoice. If the invoice is invalid, then:
|
|
|
Occurs whenever a tax rate is updated. |
Tax rates created by Piano are immutable. If a tax rate is modified directly in Stripe, Piano flags the original tax rate ID as corrupted and creates a new tax rate in Stripe. |
|
|
Draft invoice cannot be finalized. |
Extend Piano access, so that it is not shorter than 3 days. Piano payment is NOT PENDING (we do not touch Piano payment on this event). Alert, so that Piano can fix the invoice and re-finalize it. |
|
|
Draft invoice finalized. |
Handling depends on the payment path:
|
|
|
Invoice payment succeeds. |
Renew Piano subscription, set payment status to COMPLETED. For synchronous payment:
For asynchronous payment:
|
|
|
Payment requires user action. |
Start preset 30-day grace period, extend access, send failure notification. If the end-user updates the method, payment either succeeds or fails, at which point Smart Retry starts. If the user does not update the method and the preset 30-day period runs its course, Piano expires the subscription. |
|
|
Payment attempt fails. |
Grace period logic applies. Piano does not inspect the decline code. It reads the
Stripe returns |
|
|
Subscription schedule aborted. |
Internal System Validation only. |
|
|
Subscription schedule canceled. |
Internal System Validation only. |
|
|
Subscription schedule completed. |
Internal System Validation only. |
|
|
Subscription schedule created. |
Internal System Validation only. |
|
|
Subscription schedule expiring. |
Internal System Validation only. |
|
|
Subscription schedule released. |
Internal System Validation only. |
|
|
Subscription schedule updated. |
Internal System Validation only. |