12/9/1
This commit is contained in:
@@ -53,10 +53,14 @@ class LoginController extends GetxController {
|
||||
if (jsonDecoeded['data'][0]['verified'] == 1) {
|
||||
box.write(BoxName.passengerID, jsonDecoeded['data'][0]['id']);
|
||||
box.write(BoxName.email, jsonDecoeded['data'][0]['email']);
|
||||
box.write(BoxName.name, jsonDecoeded['data'][0]['first_name']);
|
||||
box.write(
|
||||
BoxName.name,
|
||||
jsonDecoeded['data'][0]['first_name'] +
|
||||
' ' +
|
||||
jsonDecoeded['data'][0]['last_name']);
|
||||
box.write(BoxName.phone, jsonDecoeded['data'][0]['phone']);
|
||||
SecureStorage().saveData(BoxName.password, passwordController.text);
|
||||
Get.offAll(() => MapPagePassenger());
|
||||
Get.offAll(() => const MapPagePassenger());
|
||||
isloading = false;
|
||||
update();
|
||||
print(box.read(BoxName.passengerID).toString());
|
||||
@@ -78,7 +82,7 @@ class LoginController extends GetxController {
|
||||
'email': emailController.text,
|
||||
'token': randomNumber.toString(),
|
||||
}).then((value) => print(value));
|
||||
Get.to(() => VerifyEmailPage());
|
||||
Get.to(() => const VerifyEmailPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ class RegisterController extends GetxController {
|
||||
void register() async {
|
||||
if (formKey.currentState!.validate()) {
|
||||
var res = await CRUD().post(link: AppLink.signUp, payload: {
|
||||
'first_name': firstNameController.text,
|
||||
'last_name': lastNameController.text,
|
||||
'email': emailController.text,
|
||||
'phone': phoneController.text,
|
||||
'password': passwordController.text,
|
||||
'first_name': firstNameController.text.toString(),
|
||||
'last_name': lastNameController.text.toString(),
|
||||
'email': emailController.text.toString(),
|
||||
'phone': phoneController.text.toString(),
|
||||
'password': passwordController.text.toString(),
|
||||
'gender': gender,
|
||||
'site': siteController.text,
|
||||
'birthdate': birthDate,
|
||||
|
||||
@@ -126,8 +126,13 @@ class CRUD {
|
||||
'Authorization': 'Bearer ${AK.secretKey}',
|
||||
},
|
||||
);
|
||||
|
||||
return response.body;
|
||||
if (response.statusCode == 200) {
|
||||
print(response);
|
||||
return response.body;
|
||||
} else {
|
||||
print('eeeeeeeeerrrrorrrr ${response.statusCode}');
|
||||
print(response.body);
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> post({
|
||||
|
||||
@@ -50,8 +50,8 @@ class MapDriverController extends GetxController {
|
||||
double progress = 0;
|
||||
double progressToPassenger = 0;
|
||||
bool isRideBegin = false;
|
||||
int progressTimerToShowPassengerInfoWindowFromDriver = 20;
|
||||
int remainingTimeToShowPassengerInfoWindowFromDriver = 20;
|
||||
int progressTimerToShowPassengerInfoWindowFromDriver = 25;
|
||||
int remainingTimeToShowPassengerInfoWindowFromDriver = 25;
|
||||
int remainingTimeToPassenger = 60;
|
||||
bool isDriverNearPassengerStart = false;
|
||||
GoogleMapController? mapController;
|
||||
@@ -206,7 +206,7 @@ class MapDriverController extends GetxController {
|
||||
});
|
||||
rideIsBeginPassengerTimer();
|
||||
double pointsSubstraction = 0;
|
||||
pointsSubstraction = double.parse(paymentAmount) * -100;
|
||||
pointsSubstraction = double.parse(paymentAmount) * -1;
|
||||
var res = await CRUD().post(link: AppLink.addDriversWallet, payload: {
|
||||
'paymentID': 'rideId$rideId',
|
||||
'amount': (pointsSubstraction).toString(),
|
||||
|
||||
@@ -154,7 +154,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
// Format the message.
|
||||
String message =
|
||||
'Hi! This is ${box.read(BoxName.name)}. I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} is driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()} with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}. I am currently located at $myLocation. If you need to reach me, please contact the driver directly at $driverPhone.';
|
||||
'Hi! This is ${box.read(BoxName.name)}.\n I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} \nis driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()}\n with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}.\n I am currently located at $myLocation.\n If you need to reach me, please contact the driver directly at\n\n $driverPhone.';
|
||||
|
||||
// Launch the URL to send the SMS.
|
||||
launchCommunication('whatsapp', to, message);
|
||||
@@ -586,6 +586,7 @@ class MapPassengerController extends GetxController {
|
||||
isCashConfirmPageShown = false;
|
||||
isPassengerChosen = false;
|
||||
isCashSelectedBeforeConfirmRide = false;
|
||||
isPickerShown = false;
|
||||
timeToPassengerFromDriverAfterApplied = 0;
|
||||
update();
|
||||
} else {
|
||||
@@ -596,6 +597,7 @@ class MapPassengerController extends GetxController {
|
||||
"order_id": rideId.toString(), // Convert to String
|
||||
"status": 'Cancel'
|
||||
});
|
||||
isPickerShown = false;
|
||||
rideConfirm = false;
|
||||
shouldFetch = false;
|
||||
isPassengerChosen = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_paypal/flutter_paypal.dart';
|
||||
import 'package:flutter_stripe/flutter_stripe.dart';
|
||||
@@ -27,6 +27,10 @@ class PaymentController extends GetxController {
|
||||
int? selectedAmount = 0;
|
||||
List<dynamic> totalPassengerWalletDetails = [];
|
||||
String passengerTotalWalletAmount = '';
|
||||
String ip = '1';
|
||||
DateTime now = DateTime.now();
|
||||
late int timestamp;
|
||||
|
||||
void updateSelectedAmount(int value) {
|
||||
selectedAmount = value;
|
||||
update();
|
||||
@@ -200,7 +204,11 @@ class PaymentController extends GetxController {
|
||||
Future<String> getClientSecret(String amount, currency) async {
|
||||
var res = await CRUD().postStripe(
|
||||
link: 'https://api.stripe.com/v1/payment_intents',
|
||||
payload: {'amount': amount, 'currency': currency},
|
||||
payload: {
|
||||
'amount': amount,
|
||||
'currency': currency,
|
||||
'payment_method_types[0]': 'card'
|
||||
},
|
||||
);
|
||||
|
||||
// Convert the res object to a JSON object
|
||||
@@ -240,11 +248,11 @@ class PaymentController extends GetxController {
|
||||
builder: (BuildContext context) => UsePaypal(
|
||||
sandboxMode: true,
|
||||
clientId:
|
||||
"AW1TdvpSGbIM5iP4HJNI5TyTmwpY9Gv9dYw8_8yW5lYIbCqf326vrkrp0ce9TAqjEGMHiV3OqJM_aRT0",
|
||||
"AWj9MdPaA5Djpx8gOkvBn2qhP-3KvfB6W-l8USTsm19Xi2NhkNkE9QzosOvTPTsKjCMNffgpqStUA1-x",
|
||||
secretKey:
|
||||
"EHHtTDjnmTZATYBPiGzZC_AZUfMpMAzj2VZUeqlFUrRJA_C0pQNCxDccB5qoRQSEdcOnnKQhycuOWdP9",
|
||||
returnURL: "https://samplesite.com/return",
|
||||
cancelURL: "https://samplesite.com/cancel",
|
||||
"EKkasSl9O61lrfrbaJfXp1B-CIs2Rv71J0WPouxxugi38DsWaMhWpovJxN2ftYPQ0l6v9eoBvnyWkemp",
|
||||
returnURL: "https://mobile-app.store",
|
||||
cancelURL: "https://mobile-app.store/cancel",
|
||||
transactions: [
|
||||
{
|
||||
"amount": {
|
||||
@@ -318,8 +326,128 @@ class PaymentController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Map licenseDetailsMap = {};
|
||||
Future getLicenseInfo() async {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getLicense,
|
||||
payload: {'driverID': box.read(BoxName.driverID)});
|
||||
licenseDetailsMap = jsonDecode(res);
|
||||
// print(licenseDetailsMap['message'][0]['name']);
|
||||
}
|
||||
|
||||
Future createConnectAccount() async {
|
||||
String url = 'https://api.stripe.com/v1/accounts';
|
||||
await getLicenseInfo();
|
||||
DateTime dob =
|
||||
DateTime.parse(licenseDetailsMap['message'][0]['dateOfBirth']);
|
||||
int currentTimestamp =
|
||||
(DateTime.now().millisecondsSinceEpoch / 1000).round();
|
||||
print('Current Unix timestamp: $currentTimestamp');
|
||||
int day = dob.day;
|
||||
int month = dob.month;
|
||||
int year = dob.year;
|
||||
await getIpAddress();
|
||||
final body = {
|
||||
"type": "custom",
|
||||
"business_profile[name]": box.read(BoxName.nameDriver),
|
||||
"business_profile[product_description]": "Captain",
|
||||
"business_profile[support_address][city]": "San Francisco",
|
||||
"business_profile[support_address][country]": "US",
|
||||
"business_profile[support_address][line1]":
|
||||
licenseDetailsMap['message'][0]['address'].toString().trim()[0],
|
||||
"business_profile[support_address][postal_code]":
|
||||
licenseDetailsMap['message'][0]['postalCode'],
|
||||
"business_profile[support_address][state]": "MA",
|
||||
"business_profile[support_email]": "support@mobile-app.store",
|
||||
"business_profile[support_phone]": "555-123-4567",
|
||||
"business_profile[url]": "https://mobile-app.store",
|
||||
"business_type": "individual",
|
||||
"capabilities[card_payments][requested]": "true",
|
||||
"capabilities[transfers][requested]": "true",
|
||||
"company[address][city]": "San Francisco",
|
||||
"company[address][country]": "US",
|
||||
"company[address][line1]": "122 Main St",
|
||||
"company[address][postal_code]": "94111",
|
||||
"company[address][state]": "MA",
|
||||
"company[name]": AppInformation.companyName,
|
||||
"country": "us",
|
||||
"default_currency": "usd",
|
||||
"email": "support@mobile.store",
|
||||
// "individual[ssn]": "123-45-6789", //
|
||||
"individual[id_number]": licenseDetailsMap['message'][0]['documentNo'],
|
||||
// "individual[id_type]": "drivers_license", //
|
||||
"individual[address][city]": "San Francisco",
|
||||
"individual[address][country]": "US",
|
||||
"individual[address][line1]": licenseDetailsMap['message'][0]['address'],
|
||||
// "individual[address][postal_code]": licenseDetailsMap['message'][0]
|
||||
// ['postalCode'],
|
||||
"individual[address][state]": "CA",
|
||||
// "individual[ssn_last_4]": '1111', ////////
|
||||
"individual[dob][day]": day.toString(),
|
||||
"individual[dob][month]": month.toString(),
|
||||
"individual[dob][year]": year.toString(),
|
||||
"individual[email]": box.read(BoxName.emailDriver),
|
||||
"individual[first_name]":
|
||||
licenseDetailsMap['message'][0]['name'].toString().split(' ')[0],
|
||||
"individual[gender]":
|
||||
licenseDetailsMap['message'][0]['sex'] == 'M' ? 'male' : 'female',
|
||||
"individual[last_name]":
|
||||
licenseDetailsMap['message'][0]['name'].toString().split(' ')[1],
|
||||
// "individual[phone]": box.read(BoxName.phoneDriver),////////////
|
||||
"tos_acceptance[date]": currentTimestamp.toString(),
|
||||
"tos_acceptance[ip]": ip.toString()
|
||||
};
|
||||
|
||||
final response = await CRUD().postStripe(
|
||||
link: url,
|
||||
payload: body,
|
||||
);
|
||||
final responseData = jsonDecode(response);
|
||||
print(responseData);
|
||||
final accountId = responseData['id'];
|
||||
box.write(BoxName.accountIdStripeConnect, accountId);
|
||||
print('accountId = $accountId');
|
||||
return accountId;
|
||||
}
|
||||
|
||||
Future<String> createTransactionToCaptain(
|
||||
String amount, String account) async {
|
||||
String url = 'https://api.stripe.com//v1/transfers';
|
||||
|
||||
final body = {
|
||||
'amount': amount, //amount
|
||||
'currency': 'aed',
|
||||
'destination': account //'acct_1OKIjQRgcWrsdyDT' //account id
|
||||
};
|
||||
|
||||
final response = await CRUD().postStripe(
|
||||
link: url,
|
||||
payload: body,
|
||||
);
|
||||
final responseData = jsonDecode(response);
|
||||
print(responseData);
|
||||
final transactionId = responseData['id'];
|
||||
box.write(BoxName.accountIdStripeConnect, transactionId);
|
||||
print('transactionId = $transactionId');
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
Future getIpAddress() async {
|
||||
var url = Uri.parse('https://api.ipify.org?format=json');
|
||||
|
||||
var response = await http.get(url);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
ip = jsonDecode(response.body)['ip'];
|
||||
print(ip);
|
||||
} else {
|
||||
print('Request failed with status: ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
timestamp = now.millisecondsSinceEpoch;
|
||||
getPassengerWallet();
|
||||
final localAuth = LocalAuthentication();
|
||||
super.onInit();
|
||||
|
||||
@@ -57,6 +57,9 @@ class ProfileController extends GetxController {
|
||||
'id': prfoileData['id'].toString(),
|
||||
columnName: txtController.text,
|
||||
});
|
||||
if (columnName == 'first_name') {
|
||||
box.write(BoxName.name, txtController.text);
|
||||
}
|
||||
Get.back();
|
||||
txtController.clear();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user