Tutorial: Roku In-App Purchase
Prerequisites
For Roku in-app purchases to be connected to Cleeng's system, the following steps must be completed:
-
Configure in-app products for your Roku channel app
-
Note: Each Roku Product ID should match its Cleeng Offer ID with one minor exception: becasue the
_
(underscore) character is not supported, you must use a-
(dash) instead:Cleeng Offer ID | Roku Product ID ----------------|------------------- S123123123_US | S123123123-US
-
-
Set your Roku push notification URL to this Cleeng endpoint:
https://cleeng.com/roku/push-notification/publisher_id
-
Contact Cleeng to finalize Roku in-app purchase setup.
Purchase Flow
The Roku channel app is responsible for displaying the “buy" button to initiate the payment. Once successful payment is completed through Roku Billing, the Cleeng receipt endpoint must be notified.
Receipt Endpoint
Endpoints:
* Production URL: `https://cleeng.com/roku/payment`
* Sandbox URL: `https://sandbox.cleeng.com/roku/payment`
Request:
- Request method: POST
-
Required headers:
Content-Type: application/json
X-Publisher-Token: publisher_token
- Json payload example:
{
"customerToken": "4pHxQda1-aoxvYIyaWdo487XsWBsM6UJSmnJVS6Oqr4r3HNg",
"offerId": "S598742062_US",
"order": {
"amount": amount_number,
"code": "product_code",
"purchaseId": "purchase_id",
"qty": qunatity,
"total": total_amount,
},
"ipAddress": "192.168.1.1"
}
-
Parameters describe
customerToken
- Cleeng customer token. generateCustomerToken can be used for it.offerId
- identifier for Cleeng offer (egE123123123_US
)amount
- Price of each purchased itemcode
- Product code, this corresponds to the product identifier that the developer assigns to the specific in-app purchase productpurchaseId
- Contains the unique transaction ID of the transaction, channels often use this value to entitle users to purchased subscriptions, etc. in their back end systemsqty
- Quantity of the specific product purchasedtotal
- Total purchase amount (including taxes) in the local currencyipAddress
- viewer ip address, optional parameter
-
Example json response:
{
"message": "OK"
}
-
Response describe
message
- processing result
-
HTTP status codes
- 400 - Invalid parameters
- 401 - Invalid authentication // broadcaster and viewer
- 422 - Unprocessable entity
- 200 - OK
- 500 - Internal Server Error
Validate Access
Payment processing is asynchronous and may take up to 1-2 minutes between purchase and validation in Cleeng. Because of this, the app should grant temporary access to the user while the transaction is processed. However, every time after the inital purchase, the middleware will be the source of truth to check the user's access status.
Note: If this is not completed within 1-2 minutes, the app should assume that the payment failed and notify the user.

End User Registration and In-App Purchase Diagram
