Tutorial: FireTv Payments

Prerequisites

Before FireTv application and middleware can be connected to Amazon, following steps must be completed:

  1. Setting up Amazon account and creating application.
  2. Adding test products - see tutorial.

    Important notes for setting up products compatible with Cleeng:

    • Item ID (SKU) should be the reference of Cleeng Offer ID example S123123123_US.
    • Use subscription purchasable item for subscriptions for a specific period of time. It means that application must rely on Cleeng when checking entitlement.
  3. In order to validate receipt Cleeng require Amazon “Shared Secret”. The shared secret can be found on the Shared Key page for your developer account with the Amazon Appstore link

General Amazon IAP FAQ.

Authentication is described in this section.

Communication with Receipt Endpoint

Endpoints:

  • Production URL: https://cleeng.com/amazon/payment
  • Sandbox URL: https://sandbox.cleeng.com/amazon/payment

Request:

  1. Request method: POST
  2. Required headers:
    • Content-Type: application/json
    • X-Publisher-Token: Publisher_token
    • Authorization: Basic auth_token - token provided by Cleeng
  3. Json payload example

    {
      customerEmail: "example@email.com",
      offerId: "S598742062_US",
      receipt: {
        receiptId: "CM8NBdCpsfsdfJHKAlMQadkMzZMRi2t0dc5aYS1tw=",
        userId: "YHSmjGja82Qf1TwrfghdfFmIhA1a7SlfIaFusML0="
      },
      ipAddress: "192.168.1.1"
    }
    
  4. Parameters describe

    • customerEmail - email registered to customer account (eg. example@email.com)
    • offerId - identifier for Cleeng offer (eg E123123123_US)
    • receiptId - receipt ID of the purchase returned by Amazon
    • userId - user ID of the purchase returned by Amazon
    • ipAddress - viewer ip address, optional parameter
  5. Example json response:

    {
      "message": "OK"
    }
    
  6. Response describe

    • message - processing result
  7. Error codes

    • 400 - Invalid parameters
    • 401 - Invalid authentication // broadcaster and viewer
    • 422 - Unprocessable entity
    • 200 - OK
    • 500 - Internal Server Error

Receipt processing is an asynchronous process that may take up to 30 seconds, therefore application needs to poll Cleeng API (getAccessStatus method) until transaction is completed and access is granted.

Android purchase flow


We use cookies to ensure that we provide you the best service and website experience. Read our Cookie policy for more details.