Developer Docs

Developer Docs

  • Getting Started
  • SubscriptionJS
  • REST API
  • Webhooks
  • Code Samples
  • UseCases
  • Request a Demo

›In App Purchase

Introduction

  • Schema
  • Errors
  • HTTP Verbs
  • Authentication
  • Pagination
  • Rate Limiting
  • Conditional Requests

Reference

  • API Reference

In App Purchase

  • Integration
  • Product Definition
  • Order Process
  • Billing & Cancellation Process
  • IAP KPIs & Reporting

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.

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:

orderProcess

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
        }
    ]
}

IAP Orders

In contrast to non IAP orders, where the Cartproperty is used, an IAP order accepts an ExternalSubscriptionId at the top level, which can be obtained from the Check REST API endpoint. This approach works for all providers. It is mandatory for Apple. For Amazon and Google both the ExternalSubscriptionId approach and using ExternalCart approach will work.

Apple, Google, Amazon

{
    "ExternalSubscriptionId": "<SubscriptionId>",
    "CustomerId":"599d51f823a1610b27a76252",
    ...
}

Google

{
    "Customer":{
        "FirstName":"Marcellus",
        "LastName":"Wallace"
    },
    "ExternalCart":{
        "Type":"GoogleIap",
        "GoogleIapPackageName":"...",
        "GoogleIapSubscriptionId":"...",
        "GoogleIapToken":"..."
    },
    ...
}

Amazon

{
    "Customer":{
        "FirstName":"Marcellus",
        "LastName":"Wallace"
    },
    "ExternalCart":{
        "Type":"AmazonIap",
        "AmazonIapReceiptId":"...",
        "AmazonIapUserId":"..."
    },
    ...
}
Last updated on 2/2/2021 by Thomas Tauber
← Product DefinitionBilling & Cancellation Process →
  • Checking IAP subscriptions
  • IAP Orders
Docs
Getting StartedAPI Reference
Resource
Help CenterSupportBlogTutorials
Start with billwerk
Test for free
Request a Demo
Already started?
billwerk Sandboxbillwerk Production
billwerk GmbH
© Made with ❤ in Germany for Europe by billwerk GmbH | 2022
Imprint
|
Data Privacy Rules
|
Disclaimer