Order Process
Most of the order process is done outside the scope of billwerk. The app provider simply additionally processes an order on billwerk side by providing order information (receipt) as a replacement for the cart. The billwerk order process follows the same steps as usual (Create & Commit). billwerk will verify the passed receipt against the IAP provider. If the receipt is valid, billwerk will create a customer and a contract as usual.
Warning
Keep subscriptions of the different IAP platforms and billwerk in separate contracts at all time. Once a billwerk contract holds subscriptions of a specific platform do not up/-downgrade to subscriptions of another IAP platform or non-IAP billwerk subscriptions!
Keeping in mind that billwerk takes the role of an observer for IAP the order process can be visualized as follows:
![order_process.png](../../image/165489b58656ac.png)
Checking IAP subscriptions
billwerk offers an endpoint to check which subscriptions a receipt contains and which of them are already in billwerk. To see if a subscription already has a contract in billwerk, check if the Contract field exists within the returned subscription. If not, you probably want to create an order to add it. This approach can be used to handle receipt restorations. For apple this endpoint requires the receipt and it can return multiple subscriptions. For other providers it requires the same data as creating an order does and it returns only one subscription.
POST /api/v1/ExternalSubscriptions/check
Apple
{ "Type":"AppleIap", "AppleIapReceipt": "..." }
Google
{ "Type":"GoogleIap", "GoogleIapPackageName": "...", "GoogleIapSubscriptionId": "...", "GoogleIapToken": "..." }
Amazon
{ "Type":"AmazonIap", "AmazonIapReceiptId": "...", "AmazonIapUserId": "..." }
Response :
{ "Subscriptions":[ { "Id": "<Existing ExternalSubscriptionId>", "Contract": { // present if we have a contract for that subscription in billwerk "Id": "<ContractId>", "CustomerId": "<CustomerId>" } },{ "Id": "<New ExternalSubscriptionId>" // Contract is missing here, so it's not in billwerk yet } ] }