Medipass Checkout SDK
The Medipass Checkout SDK is a client-side TypeScript library which allows you to interact with Medipass from your web interface. It has full TypeScript support.
Table of Contents
Install
yarn add @medipass/checkout-sdk
or NPM:
npm install @medipass/checkout-sdk
Create Checkout
A payment request URL is passed to the createCheckout function, which opens a secure pop-up window to Medipass to take the payment.
Basic Usage
import medipassCheckoutSDK from '@medipass/checkout-sdk';
medipassCheckoutSDK.init({
env: 'stg',
onSuccess: ({ transactionId }) => {
},
onFailure: ({ transactionId }) => {
},
onCancel: ({ transactionId }) => {
},
onClose: () => {
}
});
const paymentRequestUrl = getPaymentRequestUrl();
await medipassCheckoutSDK.createCheckout({
paymentRequestUrl
});
With a <script>
tag
<html>
<head>
<script src="https://unpkg.com/@medipass/checkout-sdk/dist/umd/index.min.js"></script>
</head>
<body>
<script>
medipassCheckoutSDK.init({
env: 'stg',
onSuccess: ({ transactionId }) => {
},
onFailure: ({ transactionId }) => {
},
onCancel: ({ transactionId }) => {
},
onClose: () => {
}
});
const paymentRequestUrl = getPaymentRequestUrl();
medipassCheckoutSDK.createCheckout({
paymentRequestUrl
});
</script>
</body>
</html>
Request To Update Patient Card Details
You can update a patient's payment details using the requestUpdatePaymentDetails function.
Example
import medipassCheckoutSDK from '@medipass/checkout-sdk';
await medipassCheckoutSDK.requestUpdatePaymentDetails({
apiKey,
token,
patientRefId,
env,
onSuccess,
onFailure,
onCancel,
onClose,
callbackOrigin
});
Using <script>
tag
<html>
<head>
<script src="https://unpkg.com/@medipass/checkout-sdk/dist/umd/index.min.js"></script>
</head>
<body>
<script>
medipassCheckoutSDK.requestUpdatePaymentDetails({
apiKey,
token,
patientRefId,
env,
onSuccess,
onFailure,
onCancel,
onClose,
callbackOrigin
});
</script>
</body>
</html>
Take note of the following:
- medipassCheckoutSDK.int() should not be called when using requestUpdatePaymentDetails
- it is required that you pass either an apiKey or a token
API
sdk.init(config)
config
Object
| required
{
env: 'stg' | 'prod',
onSuccess: function({ transactionId }) {},
onFailure: function({ transactionId }) {},
onCancel: function({ transactionId }) {},
onClose: function() {}
}
sdk.createCheckout(config)
config
Object
| required
{
paymentRequestUrl: string,
}