Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update-jssdk-methods #136

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions docs/jssdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ InPlayer.Account.signUp({
type: 'consumer',
referrer: 'http://localhost:3000/',
metadata: {
city: 'Skopje'
country: 'Macedonia'
}
}).then(data => console.log(data));
```

Among the parameters, `fullName`, `email`, `password`, `passwordConfirmation`, `type`, and `clientId` are always **required**.

Before you start using the Inplayer SDK, we suggest that you create a new **OAUTH application** from our Dashboard and obtain your `clinetId`. In case you haven’t got an OAUTH application yet, you can use your account **UUID** as `clientId`. To find your UUID navigate to InPlayer Dashboard's 'Account' section, in the top right-hand corner menu.
Before you start using the Inplayer SDK, we suggest that you create a new [**OAUTH application** from our Dashboard](https://client.support.inplayer.com/settings/oauth-sso/#oauth-4) and obtain your `clientId`. In case you haven’t got an OAUTH application yet, you can use your account **UUID** as `clientId`. To [find your UUID](https://client.support.inplayer.com/the-dashboard/account/#basic-details-4) navigate to InPlayer Dashboard's 'Account' section, in the top right-hand corner menu.

The `type` parameter can be either `consumer` or `merchant`. In case you want to create merchant accounts via the API, you will have to use InPlayer's public UUID for the `clientId` parameter.

Expand All @@ -75,6 +75,8 @@ InPlayer.Account.authenticate({
email: 'test32@test.com',
Jasminna marked this conversation as resolved.
Show resolved Hide resolved
password: '12345678',
clientId: 'd20252cb-d057-4ce0-83e0-63da6dbabab1',
referrer: 'http://localhost:3000/',
refreshToken: '528b1b80-ddd1hj-4abc-gha3j-111111',
}).then(data => console.log(data));
```

Jasminna marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -127,7 +129,7 @@ InPlayer.subscribe(InPlayer.Account.token(), {
The InPlayer platform enables you to create digital assets to which afterwards you can attach a **price** with **currency** and **access period**, in order to create **access fees**. The `AccessFee` resource holds data of the asset’s price, and the time-frame of the **access duration period**. The access period resource refers to the **access type** which might be of the **pay-per-view** or **subscription** model. This will be elaborated further on in this tutorial. Once you have created the desired asset with price options (conducted in the Dashboard or via the API), you can fetch and present the fees by invoking the function below.

```js
InPlayer.Asset.getAccessFees({ASSET_ID}).then(data => { //do something with data }
InPlayer.Asset.getAssetAccessFees({ASSET_ID}).then(data => { //do something with data }
```

After the end-user has chosen both the price option and the preferred payment method, depending on the access type, you can either invoke the function for creating one-time purchases (pay-per-view) or the one for subscription (recurring card payment).
Expand All @@ -153,7 +155,9 @@ InPlayer.Payment
accessFee: 2341,
Jasminna marked this conversation as resolved.
Show resolved Hide resolved
paymentMethod: 1,
referrer: 'http://example-website.com',
voucherCode: 'fgh1982gff-0f2grfds'
voucherCode: 'fgh1982gff-0f2grfds',
brandingId: 1234,
returnUrl: 'https://event.inplayer.com/staging'
})
.then(data => console.log(data));
```
Expand All @@ -171,7 +175,9 @@ InPlayer.Subscription
accessFee: 2341,
Jasminna marked this conversation as resolved.
Show resolved Hide resolved
paymentMethod: 1,
referrer: 'http://example-website.com',
voucherCode: 'fgh1982gff-0f2grfds'
voucherCode: 'fgh1982gff-0f2grfds',
brandingId: 1234,
returnUrl: 'https://event.inplayer.com/staging'
})
.then(data => console.log(data));
```
Expand All @@ -185,7 +191,8 @@ InPlayer.Payment.getPayPalParams(InPlayer.Account.token(), {
origin: window.location.href,
accessFee: ACCESS_FEE_ID,
paymentMethod: 2,
voucherCode: 'some voucher code here' (not mandatory)
voucherCode: 'SomeVoucherCodeHere', /* not mandatory */
brandingId: 1234
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the voucherCode and brandingId optional here as well?

}).then(data => { /* handle paypal data here */ }
```

Expand All @@ -210,11 +217,11 @@ To create the 'My Account' menu for a logged in customer, you need the following

Jasminna marked this conversation as resolved.
Show resolved Hide resolved
### Fetching Account Details

By passing in the authorisation token, you can fetch all the account details using the `getAccountInfo` method.
Jasminna marked this conversation as resolved.
Show resolved Hide resolved
By passing in the authorisation token, you can fetch all the account details using the `getAccount` method.

```js
InPlayer.Account
.getAccountInfo(InPlayer.Account.token())
.getAccount(InPlayer.Account.token())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes here also according to the previous comment.

.then(data => console.log(data))
.catch(error => error.response.json().then(data => console.log("Error", data)));
```
Expand All @@ -223,12 +230,24 @@ InPlayer.Account

```js
InPlayer.Account
.updateAccount({fullName: 'John Doe', metadata: {country: 'Example Country'}},InPlayer.Account.token())
.updateAccount({fullName: 'John Doe', metadata: {country: 'Example Country'}, dateOfBirth: '1999-03-05'}},InPlayer.Account.token())
.then(data => console.log(data))
.catch(error => error.response.json().then(data => console.log("Error", data)));
```


## Integration checklist

Use the following checklist to make sure you have set up the SDK for JavaScript correctly.

- [Installing the SDK](https://developers.inplayer.com/docs/jssdk#installing-the-sdk)
- [Setting up the SDK](https://developers.inplayer.com/docs/jssdk#setting-up-the-sdk)
- [Setting up the registration process](https://developers.inplayer.com/docs/jssdk#how-to-register-an-account)
- [Handling account authentication](https://developers.inplayer.com/docs/jssdk#how-to-authenticate-an-account)
- [Activating notifications](https://developers.inplayer.com/docs/jssdk#real-time-notifications)
- [Creating payments for assets](https://developers.inplayer.com/docs/jssdk#how-to-create-payments)
- [Validating content access](https://developers.inplayer.com/docs/jssdk#how-to-validate-content-access)
- [Enabling 'My Account' menu for customer](https://developers.inplayer.com/docs/jssdk#how-to-create-the-my-account-menu)



Expand Down