11/3/1
This commit is contained in:
64
lib/controller/functions/wallet.dart
Normal file
64
lib/controller/functions/wallet.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:sefer_admin1/constant/colors.dart';
|
||||
|
||||
import '../../constant/links.dart';
|
||||
import '../firebase/firbase_messge.dart';
|
||||
import 'crud.dart';
|
||||
|
||||
class WalletController extends GetxController {
|
||||
String paymentToken = '';
|
||||
Future<String> generateTokenDriver(String amount, driverID) async {
|
||||
var res = await CRUD().post(link: AppLink.addPaymentTokenDriver, payload: {
|
||||
'driverID': driverID.toString(),
|
||||
'amount': amount.toString(),
|
||||
});
|
||||
var d = jsonDecode(res);
|
||||
return d['message'];
|
||||
}
|
||||
|
||||
addPaymentToDriver(String amount, driverID, token) async {
|
||||
paymentToken = await generateTokenDriver(amount.toString(), driverID);
|
||||
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
|
||||
'rideId': 'gift$driverID',
|
||||
'amount': amount,
|
||||
'payment_method': 'visaRide',
|
||||
'passengerID': 'passengerId',
|
||||
'token': paymentToken,
|
||||
'driverID': driverID.toString(),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
FirebaseMessagesController().sendNotificationToAnyWithoutData(
|
||||
'you have gift from SEFER'.tr,
|
||||
'',
|
||||
token, // Access token correctly
|
||||
'ding.wav',
|
||||
);
|
||||
Get.snackbar('success', 'addPaymentToDriver',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
Get.snackbar('error', 'addPaymentToDriver',
|
||||
backgroundColor: AppColor.redColor);
|
||||
}
|
||||
}
|
||||
|
||||
Future addSeferWallet(String point, driverID) async {
|
||||
var amount = (int.parse(point) * -1).toStringAsFixed(0);
|
||||
var seferToken = await generateTokenDriver(amount, driverID);
|
||||
var res = await CRUD().post(link: AppLink.addSeferWallet, payload: {
|
||||
'amount': amount.toString(),
|
||||
'paymentMethod': 'visaRide',
|
||||
'passengerId': 'gift$driverID',
|
||||
'token': seferToken,
|
||||
'driverId': driverID.toString(),
|
||||
});
|
||||
if (res != 'failure') {
|
||||
Get.snackbar('success', 'addSeferWallet',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
Get.snackbar('error', 'addSeferWallet',
|
||||
backgroundColor: AppColor.redColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user