iFrame JavaScript(widget)
When you have the initializationToken, please generate the JavaScript html code for your clients.
Please check the JavaScript example above and find the following points :
<script src="https://demo.mifinity.com/widgets/sgpg.js?58190a411dc3"></script>
<div id="widget-container"></div>
<script>
var widget = showPaymentIframe("widget-container", {
token: "initializationToken_example",
complete: function() {
// close the widget after 5s
setTimeout(function() {
widget.close();
}, 5000);
}
});
</script>
- initializationToken_example is basically the initializationToken. it contains encrypted payment info you should use on your website to initialize IFrame.
- “complete” is a function which will be called when the payment is completed irrespective of the payment status (success or fail). In this example, complete function contains the code sample which will close iFrame after 5 seconds.
- MiFinity JavaScript API also provides you with success and fail callback functions in case you wish to redirect your client to a specific page according to the result of payment. However, you should not trust these callbacks since they are client side and cannot be trusted to make any funds moving. You should wait for a notification on the returnURL and then call the /payment-status endpoint.
- When Client makes the payment and it is successfully processed, you will get a POST request on your returnUrl from MiFinity with JSON string.
You should check the authenticity of the transaction by 'traceId' and 'validationKey' you passed to the init-iframe api call, after that you can update client’s balance.
Updated 10 months ago
What’s Next