This article shares some possible use cases your app could support, as well as a sample flow that could support each use case. This can be a helpful jumping off point as you plan your app's implementation.
Every time a customer upgrades an instance of your app, Wix retrieves an initial charge limit from your app. Wix displays this limit to the customer in the checkout page of the upgrade process. This helps customers understand how much they may have to pay maximally for using your app per billing cycle.
To support app upgrades:
Your app can add custom charges to an invoice that Wix sends to a customer at the end of the billing cycle.
To bill a customer:
{"intent": "CREATE_INVOICE"}
to actually create an invoice with the charges you return. For other purposes, Wix sends {"intent": "DISPLAY_ONLY"}
.Currently, you can't receive notifications when a payment for an invoice has failed. If that happens, Wix sends an email to the customer and retries to collect the payment several times. In case all retries fail, Wix cancels the app instance. Your app could get notified in this situation, and you could reach out to the customer.
To receive notifications when an app instance is canceled:
{"cancelReason": "FAILED_PAYMENT"}
in case an app instance is canceled due to a failed payment.