fawry_sdk 0.0.2+1 fawry_sdk: ^0.0.2+1 copied to clipboard
Fawry Plugin
import 'package:fawry_sdk/model/bill_item.dart';
import 'package:fawry_sdk/model/fawry_launch_model.dart';
import 'package:fawry_sdk/model/launch_customer_model.dart';
import 'package:fawry_sdk/model/launch_merchant_model.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:fawry_sdk/fawry_sdk.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
Future<void> initiateSDK() async {
BillItem item = BillItem(
itemId: "ITEM_ID",
description: "",
quantity: 4,
price: 15);
List<BillItem>? chargeItems = [item];
FawryLaunchModel model = FawryLaunchModel(
allow3DPayment: true,
allowMockData: false,
beid: null,
branchCode: null,
branchName: null,
chargeItems: chargeItems,
launchCustomerModel: LaunchCustomerModel(
customerName: "John Doe",
customerEmail: "john.doe@xyz.com",
customerMobile: "+201000000000",
customerProfileId: null,
customerCif: null,
customerToken: null),
launchMerchantModel: LaunchMerchantModel(
merchantCode: "MERCHANT_CODE",
merchantRefNum: "MERCHANT_REF_NUM",
secureKey: "SECURE_KEY"),
paymentMethods: null,
scheduledTime: null,
secretCode: "SECRET_CODE",
serviceTypeCode: "",
shippingAddress: null,
skipLogin: true,
skipReceipt: true,
skipCustomerInput: true,
signature: null);
await FawrySdk.instance.init(
launchModel: model,
baseURL: "https://www.atfawry.com/",
lang: FawrySdk.LANGUAGE_ENGLISH);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Fawry SDK Flutter example'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () async {
initiateSDK();
},
child: const Text("Init fawry SDK"),
)
],
),
),
);
}
}