Prerequisites
For Android in-app purchases to be connected to Cleeng's system, the following steps must be completed:
In order to validate Android receipt, Cleeng requires Android OAuth Client ID
in JSON format. The Client ID
should be created with permission to use google API’s on behalf end user, with privileges to view finance reports.
Product ID (SKU) should be the reference of Cleeng Offer ID but must be composed of only lowercase letters (a-z).
For example:
Cleeng Offer ID | Product ID (SKU) |
---|---|
S123123123_US | S123123123_US |
To process receipt validation App or Middleware has to send POST request in JSON format with authorization credentials to Cleeng after successful purchase on Google Play service. The request has to contain Customer Token, Offer ID and Receipt object that should be taken from Google Play Purchase object that is passed back to the listener after purchase.
Contact us to finalize Android in-app purchase setup.
Purchase Flow
The Android app is responsible for displaying the “buy" button to initiate the payment. Once successful payment is completed through Android Billing, the Cleeng receipt endpoint must be notified.
Receipt Endpoint
Production URL:
https://cleeng.com/android/payment
Sandbox URL:http://sandbox.cleeng.com/android/payment
Request
- Request method: POST
- Required headers:
Content-Type: application/json
X-Publisher-Token: publisher_token
- Json payload example
{
"customerEmail": "[email protected]",
"offerId": "S598742062_US",
"receipt": {
"productId": "s598742062_us",
"purchaseToken": "rojeslcdyyiapnqcynkjyyjh",
"packageName": "com.cleeng.iap.android.demo",
"orderId": "n9lGZjAWtRNhc98",
"purchaseState": "0",
"purchaseTime": "1495672338713",
"developerPayload": "39772f248878a8ff130c0b167caa45e7"
},
"ipAddress": "192.168.1.1"
}
- Available Parameters
Parameters | Description |
---|---|
| Customer email |
| an identifier for Cleeng offer (eg |
| Product ID from Purchase object from Google Play response after a successful purchase |
| Purchase Token from Purchase object from Google Play response after a successful purchase |
| Package Name from Purchase object from Google Play response after a successful purchase |
| Order ID from Purchase object from Google Play response after a successful purchase |
| Purchase State from Purchase object from Google Play response after a successful purchase |
| Purchase Time from Purchase object from Google Play response after a successful purchase |
| viewer IP address, optional parameter |
- Example Response,
{
"message": "OK"
}
- Response Description
message
- Processing result
- Error Codes
Code | Description |
---|---|
400 | Invalid Parameters |
401 | Invalid Authentication (Broadcaster and Viewer) |
422 | Unprocessable Entity |
200 | OK |
500 | Internal Server Error |
Validate Access
In order to register a transaction in Cleeng, the receipt data returned from Android Billing must be passed to the secure Cleeng endpoint for validation. The endpoint accepts a POST request of a JSON payload.
Payment processing is an asynchronous process. Even that most responses are within 4 seconds, it can take up to 30 seconds. Our recommendation is that the application polls the Cleeng API using the getAccessStatus()
or getAccessibleTags()
method until the transaction is completed and access is granted.
The below flowchart shows the process:

Updated 9 days ago