A Flutter plugin for making payments via IppoPay Payment Gateway. Fully supports Android and iOS.
IppoPay Payment
A Flutter plugin for making payments via IppoPay Payment Gateway. Fully supports Android and iOS.
Installation
In the dependencies: section of your pubspec.yaml, add the following line:
ippo_pay:^1.0.0
Import in your project:
import'package:ippo_pay/ippo_pay.dart';
Create Order
Create order from Server side using below API and get the Order id. Click here to know how to create a order.
Basic Usage
import'dart:convert';import'package:flutter/material.dart';import'dart:async';import'package:flutter/services.dart';import'package:ippo_pay/ippo_pay.dart';voidmain() {runApp(MyApp());}classMyAppextendsStatefulWidget {@override_MyAppStatecreateState() =>_MyAppState();}class_MyAppStateextendsState<MyApp> {TextEditingController orderIdTextField =newTextEditingController();final key =newGlobalKey<ScaffoldState>();@overridevoidinitState() { super.initState();initPlatformState(); }// Platform messages are asynchronous, so we initialize in an async method.Future<void> initPlatformState() async {if (orderIdTextField.text.trim().isNotEmpty) {try {IppoPay.initSdk("Public_Key");IppoPay.setLogVisible(true);var result =awaitIppoPay.makePayment( json.encode({"order_id": orderIdTextField.text}));print(result); } onExceptioncatch (exception) {} } else { key.currentState.showSnackBar(newSnackBar( content:newText("Please enter orderid"), )); }// Platform messages may fail, so we use a try/catch PlatformException.// If the widget was removed from the tree while the asynchronous platform// message was in flight, we want to discard the reply rather than calling// setState to update our non-existent appearance.if (!mounted) return;setState(() {// _platformVersion = platformVersion; }); }@overrideWidgetbuild(BuildContext context) {returnMaterialApp( home:Scaffold( key: key, appBar:AppBar( title:constText('Ippopay Example'), ), body:Container( child:Center( child:Column( crossAxisAlignment:CrossAxisAlignment.center, mainAxisAlignment:MainAxisAlignment.center, children: [Container( margin:EdgeInsets.all(20), child:TextField( controller: orderIdTextField, decoration:InputDecoration(hintText:"Enter the Order id"), ), ),InkWell( onTap: () {initPlatformState(); }, child:Container( margin:EdgeInsets.all(20), height:50, color:Colors.blue, child:Center( child:Text("Proceed Payment", style:TextStyle(color:Colors.white, fontSize:18), ), ), ), ) ], ), ), ), ), ); }}
Note: If you're using the IppoPay public as a string in flutter, remember to escape the $ dollar signs although it is recommended to load these from your backend