payu_ppi_flutter 1.1.0-alpha.1
payu_ppi_flutter: ^1.1.0-alpha.1 copied to clipboard
The PPI for Flutter provides a complete Mobile solution for the Flutter App and allows you to integrate Virtual CARD DISPLAY POWERED BY PayU for iOS and Android.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:payu_ppi_flutter_example/HashService.dart';
import 'package:payu_ppi_flutter/payu_ppi_flutter.dart';
import 'package:payu_ppi_flutter/PayUConstantKeys.dart';
void main() {
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> implements PayUPPIProtocol {
late PayUPPIFlutter _ppi;
@override
void initState() {
super.initState();
_ppi = PayUPPIFlutter(this);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('PayU PPI SDK'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: const Text("Show Cards"),
onPressed: () async {
_ppi.showCards(
payUPPIParams: PayUParams.createPayUPPIParams()
);
},
),
SizedBox(height: 20),
ElevatedButton(
child: const Text("Initiate KYC"),
onPressed: () async {
_ppi.initiateKYC(
kycParams: PayUParams.createKYCParams()
);
},
),
],
),
),
),
);
}
showAlertDialog(BuildContext context, String title, String content) {
Widget okButton = TextButton(
child: const Text("OK"),
onPressed: () {
Navigator.pop(context);
},
);
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: new Text(content),
),
actions: [okButton],
);
});
}
@override
generateHash(Map response) {
// Pass response param to your backend server
// Backend will generate the hash and will callback to
Map hashResponse = HashService.generateHash(response);
_ppi.hashGenerated(hash: hashResponse);
}
@override
onCancel() {
showAlertDialog(context, "onCancel", "Cancel By user");
}
@override
onError(Map? response) {
showAlertDialog(context, "onError", response.toString());
}
}
class PayUTestCredentials {
static const merchantKey = "smsplus";//TODO: Add Merchant Key
//Use your success and fail URL's.
}
//Pass these values from your app to SDK, this data is only for test purpose
class PayUParams {
static Map createPayUPPIParams() {
var payUParams = {
PayUPPIParamKey.merchantKey: PayUTestCredentials.merchantKey,
PayUPPIParamKey.referenceId: "payu${DateTime.now().millisecondsSinceEpoch}", // inCase of skudDetails pass amount equal to total skuAmount
PayUPPIParamKey.walletUrn: "1003097",
PayUPPIParamKey.environment: "0",
PayUPPIParamKey.walletIdentifier: "OLW",
PayUPPIParamKey.mobileNumber: "9528340384"
};
return payUParams;
}
static Map createKYCParams() {
var kycParams = {
PayUKYCParamKey.clientTxnId: "TXN${DateTime.now().millisecondsSinceEpoch}",
PayUKYCParamKey.customerMobile: "9308654573",
PayUKYCParamKey.consent: "1",
PayUKYCParamKey.clientId: "2070",
PayUKYCParamKey.entityId: "503",
PayUKYCParamKey.bankId: "6050",
PayUKYCParamKey.modeId: "10",
PayUKYCParamKey.redirectionUrl: "https://www.google.com",
PayUKYCParamKey.secureCode: "NcRfUjXn2r5u8x",
PayUKYCParamKey.environment: PayUEnvironment.test // Using test environment
};
return kycParams;
}
}