BASE: Update Icons & Name Of The App.
This commit is contained in:
@@ -5,7 +5,7 @@ import 'dart:convert';
|
||||
import 'package:customer/models/payment_model/orange_money.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
@@ -17,7 +17,15 @@ class OrangeMoneyScreen extends StatefulWidget {
|
||||
String orderId = '';
|
||||
String amount = '';
|
||||
|
||||
OrangeMoneyScreen({super.key, required this.initialURl, required this.orangePay, required this.accessToken, required this.payToken, required this.orderId, required this.amount});
|
||||
OrangeMoneyScreen({
|
||||
super.key,
|
||||
required this.initialURl,
|
||||
required this.orangePay,
|
||||
required this.accessToken,
|
||||
required this.payToken,
|
||||
required this.orderId,
|
||||
required this.amount,
|
||||
});
|
||||
|
||||
@override
|
||||
State<OrangeMoneyScreen> createState() => _OrangeMoneyScreenState();
|
||||
@@ -41,7 +49,12 @@ class _OrangeMoneyScreenState extends State<OrangeMoneyScreen> {
|
||||
timer = Timer.periodic(const Duration(seconds: 3), (Timer t) async {
|
||||
if (!mounted) return;
|
||||
|
||||
String status = await transactionStatus(accessToken: widget.accessToken, amount: widget.amount, orderId: widget.orderId, payToken: widget.payToken);
|
||||
String status = await transactionStatus(
|
||||
accessToken: widget.accessToken,
|
||||
amount: widget.amount,
|
||||
orderId: widget.orderId,
|
||||
payToken: widget.payToken,
|
||||
);
|
||||
|
||||
if (status == 'SUCCESS') {
|
||||
timer?.cancel();
|
||||
@@ -72,15 +85,31 @@ class _OrangeMoneyScreenState extends State<OrangeMoneyScreen> {
|
||||
..loadRequest(Uri.parse(widget.initialURl));
|
||||
}
|
||||
|
||||
Future<String> transactionStatus({required String orderId, required String amount, required String payToken, required String accessToken}) async {
|
||||
String apiUrl = widget.orangePay.isSandbox == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/transactionstatus' : 'https://api.orange.com/orange-money-webpay/cm/v1/transactionstatus';
|
||||
Future<String> transactionStatus({
|
||||
required String orderId,
|
||||
required String amount,
|
||||
required String payToken,
|
||||
required String accessToken,
|
||||
}) async {
|
||||
String apiUrl =
|
||||
widget.orangePay.isSandbox == true
|
||||
? 'https://api.orange.com/orange-money-webpay/dev/v1/transactionstatus'
|
||||
: 'https://api.orange.com/orange-money-webpay/cm/v1/transactionstatus';
|
||||
|
||||
Map<String, String> requestBody = {"order_id": orderId, "amount": amount, "pay_token": payToken};
|
||||
Map<String, String> requestBody = {
|
||||
"order_id": orderId,
|
||||
"amount": amount,
|
||||
"pay_token": payToken,
|
||||
};
|
||||
|
||||
try {
|
||||
var response = await http.post(
|
||||
Uri.parse(apiUrl),
|
||||
headers: {'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'},
|
||||
headers: {
|
||||
'Authorization': 'Bearer $accessToken',
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: json.encode(requestBody),
|
||||
);
|
||||
|
||||
@@ -107,10 +136,16 @@ class _OrangeMoneyScreenState extends State<OrangeMoneyScreen> {
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(icon: const Icon(Icons.arrow_back, color: Colors.white), onPressed: _showCancelDialog),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||
onPressed: _showCancelDialog,
|
||||
),
|
||||
title: Text('Orange Money Payment'.tr()),
|
||||
),
|
||||
body: isLoading ? const Center(child: CircularProgressIndicator()) : WebViewWidget(controller: controller),
|
||||
body:
|
||||
isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: WebViewWidget(controller: controller),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -124,9 +159,12 @@ class _OrangeMoneyScreenState extends State<OrangeMoneyScreen> {
|
||||
title: Text('Cancel Payment'.tr()),
|
||||
content: Text('Are you sure you want to cancel this payment?'.tr()),
|
||||
actions: [
|
||||
TextButton(child: Text('No', style: TextStyle(color: Colors.green)), onPressed: () => Get.back()),
|
||||
TextButton(
|
||||
child: Text('Yes'.tr(), style: TextStyle(color: Colors.red)),
|
||||
child: Text('No', style: TextStyle(color: Colors.green)),
|
||||
onPressed: () => Get.back(),
|
||||
),
|
||||
TextButton(
|
||||
child: Text('Yes'.tr(), style: TextStyle(color: Colors.red)),
|
||||
onPressed: () {
|
||||
timer?.cancel();
|
||||
Get.back(); // close dialog
|
||||
@@ -152,8 +190,7 @@ class _OrangeMoneyScreenState extends State<OrangeMoneyScreen> {
|
||||
// import 'dart:convert';
|
||||
// import 'package:customer/models/payment_model/orange_money.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:get/get.dart';
|
||||
// import 'package:http/http.dart' as http;
|
||||
// import 'package:get/get.dart' hide Trans;// import 'package:http/http.dart' as http;
|
||||
// import 'package:webview_flutter/webview_flutter.dart';
|
||||
//
|
||||
// class OrangeMoneyScreen extends StatefulWidget {
|
||||
|
||||
Reference in New Issue
Block a user