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>
  1. initializationToken_example is basically the initializationToken. it contains encrypted payment info you should use on your website to initialize IFrame.
  2. “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.
  3. 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.
  4. 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.


What’s Next