Enable web payments with Stripe
JWP enables you to monetize your content through web payments.
For your videos that require registration and payment, a new user must register and provide payment details. Your app makes an API call to create an account and recurring subscription. 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, SDK methods and API calls will use the following namespaces and domains:
- InPlayer
- inplayer.com
- jwplayer.com
#
PrerequisitesItem | Description |
---|---|
New or existing app | Web-based app that displays content to users |
Web Payment Entitlement | Entitlement required to set up web payments Contact your JWP representative for more information. |
Payment Plan | Plan 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 ID | IDs that enable access to content when combined:
|
Stripe Account | JWP-supported web payment provider JWP only supports Stripe as a web payment provider. If you use another web payment provider, you will need to migrate to Stripe. |
#
Configure WebSocket notificationsWebSocket notifications enable communication between your app and JWP. Whether you implement web payments with the JavaScript SDK or REST API, you must set up JavaScript to set up and configure WebSockets notifications.
You can provide updates to your users by displaying a WebSocket notification.
Follow these steps to listen for a subscription notification and display a message to your users:
Add the following code to your app.
Replace
uuid
with your UUID.Configure the appearance of the popup in the
.popup
CSS settings.Define how long the popup displays by adjusting the
setTimeout
values.
You can now set up web payments through the JavaScript API or REST API.
#
Set up web paymentsJWP enables you to set up web payments using either a JavaScript SDK or REST API:
- JavaScript SDK: Use for a direct integration between the app and JWP.
- REST API: Use this for integrations where the app communicates with JWP using middleware.
info
This web payment solution only supports single packages.
#
JavaScript SDK#
New UserFollow these steps to enable web payments with Stripe for a new user:
Create a new user account by calling
InPlayer.Account.signUp()
.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.
Retrieve the subscription price by calling
InPlayer.Asset
. The SDK will return thecurrency
andamount
in the response that can be used to display the subscription price in your app.Create a recurring payment card subscription by calling
InPlayer.Subscription()
.If the request succeeds, the following actions occur:
- JWP sends a subscription record to Stripe.
- Stripe creates a subscription and sends it to JWP.
- JWP sends your app a
subscribe.success
WebSocket notification. - Your app displays the notification to the user.
If the request fails, the following actions occurs:
- JWP sends your app a
subscribe.failed
WebSocket notification. - Your app displays a failure or error message to the user.
Validate the user's access by calling
checkAccessForAsset()
.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.
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 UserFollow these steps to enable web payments with Stripe for an existing user:
Create a new user account by calling
InPlayer.Account.signIn()
.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.
Retrieve the subscription price by calling
InPlayer.Asset
. The SDK will return thecurrency
andamount
in the response that can be used to display the subscription price in your app.Create a recurring payment card subscription by calling
InPlayer.Subscription()
.If the request succeeds, the following actions occur:
- JWP sends a subscription record to Stripe.
- Stripe creates a subscription and sends it to JWP.
- JWP sends your app a
subscribe.success
WebSocket notification. - Your app displays the notification to the user.
If the request fails, the following actions occurs:
- JWP sends your app a
subscribe.failed
WebSocket notification. - Your app displays a failure or error message to the user.
Validate the user's access by calling
checkAccessForAsset()
.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.
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.
#
REST API#
New UserFollow these steps to enable web payments with Stripe for a new user:
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.
Retrieve the subscription price by calling
GET /v2/items/{id}/access-fees
. The API will return thecurrency
andamount
in the response that can be used to display the subscription price in your app.Create a recurring payment card subscription by calling
POST /subscriptions
.If the request succeeds, the following actions occur:
- JWP sends a subscription record to Stripe.
- Stripe creates a subscription and sends it to JWP.
- JWP sends your app a
subscribe.success
WebSocket notification. - Your app displays the notification to the user.
If the request fails, the following actions occurs:
- JWP sends your app a
subscribe.failed
WebSocket notification. - Your app displays a failure or error message to the user.
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.
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 UserFollow these steps to enable web payments with Stripe for an existing user:
Create a new 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 that is valid for 30 days. When the request fails, JWP returns a failure response.
Retrieve the subscription price by calling
GET /v2/items/{id}/access-fees
. The API will return thecurrency
andamount
in the response that can be used to display the subscription price in your app.Create a recurring payment card subscription by calling
POST /subscriptions
.If the request succeeds, the following actions occur:
- JWP sends a subscription record to Stripe.
- Stripe creates a subscription and sends it to JWP.
- JWP sends your app a
subscribe.success
WebSocket notification. - Your app displays the notification to the user.
If the request fails, the following actions occurs:
- JWP sends your app a
subscribe.failed
WebSocket notification. - Your app displays a failure or error message to the user.
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.
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.