Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In order to create a widget instance through the FlexitiSDK, you should use the following:

var FlexitiSdk = new FlexitiSdk({
  clientId: {{your_client_id}},
  accessToken : {{access_token}},
  iframeContainer: {{container_id}},
  env:"training",
  failureCallback: handleCallbackFailure,
  cancelCallback: handleCallbackCancel,
  successCallback: handleCallbackSuccess,
});

function handleCallbackSuccess (data) {
  console.log("successCallback:", data);
  alert('Success');
}

function handleCallbackFailure (data) {
  console.log("failureCallback:", data);
  alert('Failure');
}

function handleCallbackCancel (data) {
  console.log("cancelCallback:", data);
  alert('Cancel');
}

Parameters

Parameter

Required

Details

clientId

Yes

  • ASCII string (100)

  • From the Developer Portal account settings.

accessToken

Yes

  • ASCII string

  • OAuth token given by the POST /oauth/token, it should be called by the merchant on server side. For more information click here.

iframeContainer

Yes

  • ASCII string

  • ID of the html element used as the container

<div id=”{{iframeContainer}}”>
	//this is where the iframe will be created by the FlexitiSDK init method, and where the widget will be rendered.
</div>

env

Yes

  • ASCII string

  • Determines which API environment is accessed by the SDK - Training or Production

  • Available values: training, prod

failureCallback

Yes

  • ASCII string

  • Function to handle flow failures to be implemented by the Merchant

cancelCallback

Yes

  • ASCII string

  • Function to handle flow cancellations to be implemented by the Merchant

successCallback

Yes

  • ASCII string

  • Function to handle flow successes to be implemented by the Merchant

Access Token Notes:

In order to control the data flow Flexiti takes the access_token as a referential value of the entire flow. Usually there are several steps before and after reaching this widget implementation so:

  • Once you need to call to the first POS-API method, usually the GET /information, you must to call to the oAuth POST /token to get access.

  • You have to ensure to use a refreshed token in order to have all the time available to complete the flow once you reach the widget page.

  • Please refer to the Oauth 2 Authorization Method and Refresh Token documentation for refreshing tokens.

  • No labels