Tyro Health SDK setup

There is a three-step process to get you started with the Tyro Health SDK:

1)Set up the transaction SDK
2)Submit transaction details
3)Record Transaction Outcome

1)Set up the transaction SDK

Requirements:

Requirement Notes
API KEY An API Key grants you access to a business and all related providers resources.
API Keys can only be created by a business admin.
How to obtain an API Key:
Once the admin is logged into the Medipass portal
1. Go to ‘Business settings’ and navigate to the ‘API keys’ tab,
2. Select ‘Generate a new key’ and the API Key will be displayed.
App ID This is your Tyro health unique Identifier. Issued by our partner integration team. Please contact healthpartnerships@tyro.com
App Version This is typically aligned to your software release version. Used for debug and support efforts. This value is determined by you.

Environments

Tyro Health has to two environments for partner integration:

  1. Non- Prod/ testing environment (stg):This represents a production like environment but uses test account details and stubs to simulate responses from funders.
  2. Production (PROD): Tyro Health production environment.

Installation

There are two options to install theTyro Health transaction SDK:

Installation via NPM/Yarn or, Download the SDK via unpkg.com

Note: If you intend to use the SDK as a JavaScript module you will need to install the NPM/Yarn package. If you will be using the SDK with a <script> tag or other URL direction method then you will need to install the unpkg.com version.

Installation via NPM/Yarn

npm install @medipass/partner-sdk
// or, with yarn:
yarn add @medipass/partner-sdk

Or

Download the SDK via unpkg.com

https://unpkg.com/@medipass/partner-sdk@1.10.1/umd/@medipass/partner-sdk.min.js

Using the JavaScript Module

Copy
Copied
import medipassSDK from '@medipass/partner-sdk';
// or: const medipassSDK = require('@medipass/partner-sdk');

medipassSDK.setConfig({
  env: 'stg',
  apiKey: '[insert your API key here]',
  appId: '[insert your App ID here]',
  appVersion: '[insert your App version here]'
});

medipassSDK.renderCreateTransaction({}, {
  onSuccess: function (transaction) {
    // handle successful submission of transaction
  },
  onError: function (error) {
    // handle errored submission of transaction
  },
  onCancel: function () {
    // handle when create transaction flow has been cancelled
  }
});

Using a <script> tag

Copy
Copied
<html>
<head>
  <script src="https://unpkg.com/@medipass/partner-sdk@1.10.1/umd/@medipass/partner-sdk.min.js"></script>
</head>
<body>
  <script>
    MedipassTransactionSDK.setConfig({
      env: 'stg',
      apiKey: '[insert your API key here]',
      appId: '[insert your App ID here]',
      appVersion: '[insert App version key here]'
    });

    MedipassTransactionSDK.renderCreateTransaction({}, {
      onSuccess: data => {
        // handle success
      },
      onError: data => {
        // handle error
      },
      onCancel: () => {
        // handle cancel
      }
    });
  </script>
</body>
</html>

Short-lived SDK token

In order to mitigate potential risks of unauthorised API keys, Tyro Health provides the option of a short-lived SDK authentication token.

To use the short-lived token you will need to follow the below three step process:

1) On your server-side, use the Business Admin API key to call:

Resource POST <base-url>/v3/auth/token

Where base-url:

Staging: stg-api-au.medipass.io

Production: api-au.medipass.io

Required headers

  • authorization: Bearer <Business_Admin_API_key>
  • x-appid: your App ID

Payload

{
    "audience": "aud:business-sdk",
    "expiresIn": "1h"    // e.g. 30m, 1h, 6h, 24h. Defaults to 1h, max is 24h.
}

2) The response will contain a short-lived token that is restricted to SDK features. For example, it can't be used to generate more tokens, update business details or create other users in a business.

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXIiOjEsImlhdCI6MTU5Mzc1NzI1MCwiZXhwIjoxNTkzNzYwODUwLCJhdWQiOiJhdWQ6YnVzaW5lc3Mtc2RrIiwic3ViIjoiNTc0M2NiNWI1YjI0Y2MxNDAwOTk5MTcwIiwianRpIjoiNVctZDZLIn0.YbbogFjmk7-BT15aY7vqHfFcXpH5Smr9LT96hHUjlWQ"
}

3) Return this token to your portal, and use it for the SDK apiKey field.

2024 Copyright © Tyro Health and Tyro Payments 2024. All right reserved.