After installing and adding the finswich package to your code, here is a sample dart code to complete your set up
import'package:finswich_checkout/finswich_checkout.dart';import'package:flutter/widgets.dart';classMyWidgetextendsStatefulWidget {constMyWidget({super.key});@overrideState<MyWidget> createState() =>_MyWidgetState();}class_MyWidgetStateextendsState<MyWidget> {bool isCheckoutVisible =false;//to pop out the checkout set isCheckoutVisible to true@overrideWidgetbuild(BuildContext context) {returnStack( children: [Container(),//the container should be replaced by your code/// Your widget should go here in place of container (your application) ischeckoutvisible?FinswichIframe( balance:"your_user_balance", isCheckoutVisible: isCheckoutVisible, origin:"your_apps_origin",///To get your origin use this [window.location.origin], publicKey:"your_finswich_live_public_key", reference:"your_user_reference", refreshUI: () {setState(() {}); }, ):constSizedBox(), ], ); }}
The table below helps to explain the objects passed to the inline JS during initialiazation
Key
Description
Type
reference
This is your user's reference on your platform
String
public_key
Your live public key from Finswich app
String
balance
the user's balance on your app
Number
origin
your whitelisted IP saved on the Finswich platform
String
4. Pseudocode for Integrating Finswich Checkout in Application (Native iOS & Android)
Introduction
This pseudocode outlines the implementation of an iframe for the Finswich Checkout system. It dynamically configures the iframe's parameters, listens for messages from the iframe, handles closure events, and updates the UI accordingly.
This documentation is designed for developers who want to understand and implement the integration in their Mobile applications.
## Features-Dynamically constructs the iframe URL using provided parameters.-Registers a custom HTML iframe element.-Listensfor `MessageEvent` objects from the iframe for communication.-Handles iframe closure and triggers UI updates through a callback function.---## Prerequisites-**Mid-level ProgrammingKnowledge**:Basic understanding of syntax, logics and state management.-**WebIntegration**:Familiaritywith using HTML elements in your framework.<!---**Tools**:Ensure you have a Flutter development environment set up. -->---## PseudocodeBelowis the pseudocode for the `FinswichIframe` widget:```pseudocodeCLASS:FinswichIframeINPUT:- ischeckoutVisible (Boolean)- reference (String)- publicKey (String)- balance (String)- origin (String)- refreshUI (Function)BEGIN// Constructor to initialize FinswichIframeFUNCTIONFinswichIframe( ischeckoutVisible, reference, publicKey, balance, origin, refreshUI )DECLARE messageSubscription (StreamSubscription<MessageEvent>) // Listens for `MessageEvent` objects from the iframe for communication (Closing the iframe) // Register a custom HTML iframe element (Create the iframe) WITHPARAMETERS:-'iframeElement'-FUNCTION:CreateIFrameElement:SET className ="MyIframe"SET id ="_fswich_iframe"SET src ="https://checkout-1.fuspay.finance/?reference={{reference}}&public_key={{publicKey}}&balance={{balance}}&origin={{origin}}"SET style.border ='none'// Listen for messages from the iframeSET messageSubscription = window.onMessage.listen(FUNCTION(event):// Get the iframe element by IDSET checkoutIframe = document.getElementById("_fswich_iframe")// Check if the received message signals to "Close"IF event.data["name"] =="Close"THENIF debugMode THENPRINT"Closing iframe"// Remove the iframe and update visibilityCALL checkoutIframe.parent.remove()SET ischeckoutVisible =FALSECANCEL messageSubscriptionCALLrefreshUI()ENDIFENDFUNCTION)ENDFUNCTION// Widget build functionFUNCTIONbuild(context)RETURNHtmlElementViewWITHPARAMETERS:- viewType ='iframeElement'- onPlatformViewCreated = (callback function)ENDFUNCTIONENDCLASS
On the flutter package website they click the installing tab