12/9/1
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user