Enable third-party platform payments

JWP enables you to monetize your content through third-party platform payments.

For your videos that require registration and payment, a new user must register or an existing user must log in. Then, the user must provide payment details.

Your app makes an API call to create an account or authenticate an existing account. Then, a recurring subscription is initiated. Payment is processed. After a successful payment, the app validates the user's access and begins content playback.

info

Since this implementation uses both JWP and InPlayer technologies, API calls will use the following namespaces and domains:

  • InPlayer
  • inplayer.com
  • jwplayer.com

Prerequisites#

ItemDescription
New or existing appApp connected to a JWP property
Payment & Subscription EntitlementEntitlement required to set up payments

Contact your JWP representative for more information.
Payment PlanPlan that allows access to specified app content

You can create basic payment plans or complex payment plans that include features such as discount codes.
Asset ID & Client IDIDs that enable access to content when combined:
  • Asset ID: Subscription asset that must be purchased to watch content on the app
  • Client ID: Authentication realm where user account is created
Contact your JWP representative for more information.

Set up third-party payments#


New User#

Follow these steps to enable third-party payments for a new user:

  1. Create a new user account by calling POST /accounts.

    When the request succeeds, JWP creates a new user object and returns a unique user authentication token that is valid for 30 days. When the request fails, JWP returns a failure response.

    curl -L -X POST 'https://services.inplayer.com/accounts' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'full_name=John Doe' \
    --data-urlencode 'username=john@example.com' \
    --data-urlencode 'password=foobar123' \
    --data-urlencode 'password_confirmation=foobar123' \
    --data-urlencode 'type=consumer' \
    --data-urlencode 'grant_type=password' \
    --data-urlencode 'client_id=12345678-90ab-1c23-4567-89d0e123f45' \
    --data-urlencode 'metadata%5Bphone%5D=bar'
  2. Use the app store's API to create an in-app purchase. This includes displaying the subscription price and setting up a subscription:

  3. Validate the user's purchase by calling POST /external-payments/<platform>/validate. After making this API call, JWP verifies the payment on the third-party platform, stores transaction and subscription details, and grants the user access to the purchased content.

    info

    See the following links for more information about each vendor-specific route:

    curl POST https://services.inplayer.com/v2/external-payments/amazon/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<AMZ_RVS_RECEIPT>' \
    --data-urlencode 'product_name=<AMZ_PRODUCT_ID>'
    curl POST https://services.inplayer.com/v2/external-payments/apple/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<APP_STORE_JSON_PURCHASE_OBJECT>' \
    --data-urlencode 'product_name=<APPLE_PRODUCT_ID>'
    curl POST https://services.inplayer.com/v2/external-payments/google-play/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<GOOGLE_JSON_PURCHASE_OBJECT>' \
    --data-urlencode 'product_name=<GOOGLE_PRODUCT_ID>'
    curl POST https://services.inplayer.com/v2/external-payments/roku/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<ROKU_RECEIPT>' \
    --data-urlencode 'product_name=<ROKU_PRODUCT_ID>'
  4. Validate the user's access by calling GET /items/{asset-ID}/access.

    If access to the asset is verified, the method returns the content in the response that you can display in your app. If access to the asset cannot be verified, your app should redirect the user to your payment page to re-enter payment details.

    curl https://services.inplayer.com/items/{id}/access \
    -H "Authorization:Bearer <TOKEN>"

After you have validated the user's access, you can fetch the content by media ID and begin playback.

If you use an app config to manage your content, you can obtain the media ID from the contentId parameter of the app config URL.

tip

You can add URL signing or digital rights management (DRM) for extra layers of content protection.



Existing User#

Follow these steps to enable third-party payments for an existing user:

  1. Log in an existing user account by calling POST /v2/accounts/authenticate.

    When the request succeeds, JWP creates a new user object and returns a unique user authentication token. When the request fails, JWP returns a failure response.

    curl -L -X POST 'https://services.inplayer.com/v2/accounts/authenticate' \
    -H 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'username=test@test.com' \
    --data-urlencode 'password=test123' \
    --data-urlencode 'grant_type=password' \
    --data-urlencode 'client_id=123-123-hf1hd1-12dhd1' \
  2. Use the app store's API to create an in-app purchase. This includes displaying the subscription price and setting up a subscription:

  3. Validate the user's purchase by calling POST /external-payments/<platform>/validate. After making this API call, JWP verifies the payment on the third-party platform, stores transaction and subscription details, and grants the user access to the purchased content.

    info

    See the following links for more information about each vendor-specific route:

    curl POST https://services.inplayer.com/v2/external-payments/amazon/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<AMZ_RVS_RECEIPT>' \
    --data-urlencode 'product_name=<AMZ_PRODUCT_ID>'
    curl POST https://services.inplayer.com/v2/external-payments/apple/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<APP_STORE_JSON_PURCHASE_OBJECT>' \
    --data-urlencode 'product_name=<APPLE_PRODUCT_ID>'
    curl POST https://services.inplayer.com/v2/external-payments/google-play/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<GOOGLE_JSON_PURCHASE_OBJECT>' \
    --data-urlencode 'product_name=<GOOGLE_PRODUCT_ID>'
    curl POST https://services.inplayer.com/v2/external-payments/roku/validate \
    -H 'Authorization: <TOKEN>' \
    --data-urlencode 'receipt=<ROKU_RECEIPT>' \
    --data-urlencode 'product_name=<ROKU_PRODUCT_ID>'
  4. Validate the user's access by calling GET /items/{asset-ID}/access.

    If access to the asset is verified, the method returns the content in the response that you can display in your app. If access to the asset cannot be verified, your app should redirect the user to your payment page to re-enter payment details.

    curl https://services.inplayer.com/items/{id}/access \
    -H "Authorization:Bearer <TOKEN>"

After you have validated the user's access, you can fetch the content by media ID and begin playback.

If you use an app config to manage your content, you can obtain the media ID from the contentId parameter of the app config URL.

tip

You can add URL signing or digital rights management (DRM) for extra layers of content protection.