The Billing API allows to charge site owners for using your app.
With the Billing API, you can:
See the App Instance API for more information on how to track data that's associated with individual app instances. Learn more about charging customers varying amounts each billing cycle with the Custom Charges service plugin.
It’s important to note the following points before starting to code:
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.
successURL
that you've submitted in the API call. If you haven't passed success URL, Wix
redirects the user to the default Wix success page.https://www.wix.com/my-account/app/<appID>/<AppInstanceID>
During development, all your plans will be automatically set to a price of 0.00, so you can test the flow. Once your app's approved, your plans' real prices will be activated and you'll receive a coupon for testing.Retrieves the URL for a Wix checkout page for the specified paid plan of your app.
This call succeeds only in case you have previously set up an external pricing page in your app's dashboard.
The returned checkout URL is valid for 48 hours.
This API allows your app to manage your pricing page outside of Wix while still using the standard Wix checkout flow.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of your app's paid plan to retrieve the Wix checkout URL for. Check your app's dashboard for a list of your app's supported product IDs.
URL for the Wix checkout page. Redirect site owners to this URL after they've successfully purchased a paid plan for your app.
Whether the checkout is for testing purposes only. Testing is mainly
relevant for in-app purchase flows. When true
, Wix charges the site
owners an amount of 0.00
.
Information about the paid plan's billing cycle.
2-letter country code in ISO-3166 alpha-2 format.
Default: "US"
2-letter language code in ISO 639-1 alpha-2 format.
Default: "EN"
Coupon code for the paid plan. Available only in case there is a discount.
URL for the Wix checkout page.
Token for the Wix checkout page. The token holds all data about the order you're creating a checkout for. It is signed, so you can verify that it comes from Wix.
curl -X POST \
https://www.wixapis.com/apps/v1/checkout \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
"productId": "e8f429d4-0a6a-468f-8044-87f519a53202",
"billingCycle": "MONTHLY"
}'
{
"checkoutUrl": "https://www.wix.com/apps/upgrade/order-checkout?token=JWS.eyJraWQiOiJaUnliMG5pbCIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wib3JkZXJJdGVtc1wiOlt7XCJwcm9kdWN0SWRdIjpcImIwZjgwOGMz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FwicXVhbnRpdHlcIjoxLFwicGF5bWVudEN5Y2xlXCI6XCJNT05USExZXCIsXCJkaXNwbGF5TmFtZVwiOlwiXCIsXCJjb3Vwb25Db2RlXCI6bnVsbCxcImJpbGxpbmdTZXJ2aWNlSWRcIjpudWxsLFwib3ZlcnJpZGVQcmljZVwiOlwiOC4wXCIsXCJleHRlcm5hbE9yZGVySXRlbUlkXCI6XCJMaW5lSXRlbV8wXCJ9XSxcInN1Y2Nlc3NVcmxcIjpcImh0dHBzOi8vd3d3LndpeC5jb20vYXBwcy91cGdyYWRlL29yZGVyLXJlc3VsdFwiLFwid2l4VXNlckd1aWRcIjpudWxsLFwidXNlckVtYWlsXCI6bnVsbCxcImxhbmd1YWdlQ29kZVwiOlwiZW5cIixcImN1cnJlbmN5Q29kZVwiOlwiVVNEXCIsXCJvcmRlclBhcmFtc1wiOntcInNpdGVHdWlkXCI6XCIxMTE0MjExNC0yZDExLTRkNzYtOWEzZS0zZjUzMzBiNjBhYzdcIn0sXCJldmVudEFnZ3JlZ2F0b3JcIjpcImYzNGY1MGE4LTc3ZDMtNDE1Ny1iM2Q3LTZiMDJkYzI2ODQ1NlwiLFwiaW5pdGlhdG9yXCI6XCJBcHAgTWFya2V0IFRQQSBBUElcIixcImNvdXBvbkRpc3BsYXlOYW1lXCI6bnVsbH0iLCJpYXQiOjE1NzQ1OTAyMDcsImV4cCI6MTU3NDc2MzAwN30.quYK2ND5tCTsaRPlQA5349ULQoWUwkdPzQEwcQhqc9s"
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
Retrieves a list of the site owner's past purchases for your app.
You don't have to explicitly pass an identifier for the Wix site as part of the request, since this information is taken automatically from the context.
The response doesn't include any details about cancellations.
You can only call this method when authenticated as a Wix app or Wix user identity.
Retrieved purchases the site owners have completed for you app.
curl -X GET \
https://www.wixapis.com/apps/v1/checkout/history\
-H 'Authorization: <AUTH>' \
{
"purchases": [
{
"productId": "mid-tier",
"price": "0",
"currency": "USD",
"billingCycle": "YEARLY",
"dateCreated": "2020-07-21T08:45:18Z"
}
]
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.