10/25/1
This commit is contained in:
@@ -10,6 +10,7 @@ class AppCredintials {
|
||||
static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS';
|
||||
static const String accountSIDTwillo = 'ACb4ad857efe0903bfd6238a763a2ce4d1';
|
||||
static const String authTokenTwillo = '14f39ef4628bb8a4f18469f462f8af75';
|
||||
static const String Publishablekey = '14f39ef4628bb8a4f18469f462f8af75';
|
||||
String getBasicAuthCredentials() {
|
||||
return base64Encode(utf8.encode(basicAuthCredentials));
|
||||
}
|
||||
@@ -18,6 +19,13 @@ class AppCredintials {
|
||||
'Authorization:API_EMDJX6BHQ67DBGT6WV:DG2XPU7YEN02M0VJ2F';
|
||||
}
|
||||
|
||||
class StripeKey {
|
||||
static const String publishableKey =
|
||||
'pk_test_51O4WTODMEVrOCA5SN5e6b8pAvF5CPDC3c3Pif18q74NEQApU5AfmZZEN9X2WIayfIrUTjju1pUavmgoeLgb3FR5k00pn4oMHGO';
|
||||
static const String secretKey =
|
||||
'sk_test_51O4WTODMEVrOCA5SBgaoSS69nNFRyfZx2Tl5ODswYyjqLpc0RxBHW3hhcP38Tp78TZ1PQoZo7eHFllRiQd3rMHPN00Lr9WD3n2';
|
||||
}
|
||||
|
||||
class MyClass {
|
||||
static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
|
||||
static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class AppInfo {
|
||||
class AppInformation {
|
||||
static const String companyName = 'Mobile-App';
|
||||
static const String appName = 'SEFER';
|
||||
static const String phoneNumber = '962798583052';
|
||||
|
||||
@@ -33,6 +33,25 @@ class CRUD {
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> postStripe({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
var url = Uri.parse(
|
||||
link,
|
||||
);
|
||||
var response = await http.post(
|
||||
url,
|
||||
body: payload,
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization': 'Bearer ${StripeKey.secretKey}',
|
||||
},
|
||||
);
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
Future<dynamic> post({
|
||||
required String link,
|
||||
Map<String, dynamic>? payload,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_stripe/flutter_stripe.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:ride/controller/home/map_passenger_controller.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
@@ -58,7 +60,7 @@ class PaymentController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void applyPromoCodetoPassenger() async {
|
||||
void applyPromoCodeToPassenger() async {
|
||||
//TAWJIHI
|
||||
CRUD().get(link: AppLink.getPassengersPromo, payload: {
|
||||
'promo_code': promo.text,
|
||||
@@ -77,6 +79,35 @@ class PaymentController extends GetxController {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> makePayment(int amount, String currency) async {
|
||||
try {
|
||||
String clientSecret =
|
||||
await _getClientSecret((amount).toString(), currency);
|
||||
await initializePaymentSheet(clientSecret);
|
||||
await Stripe.instance.presentPaymentSheet();
|
||||
} catch (e) {
|
||||
throw Exception(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initializePaymentSheet(String clientSecret) async {
|
||||
Stripe.instance.initPaymentSheet(
|
||||
paymentSheetParameters: SetupPaymentSheetParameters(
|
||||
paymentIntentClientSecret: clientSecret,
|
||||
merchantDisplayName: 'Sefer',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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},
|
||||
);
|
||||
final jsonResponse = jsonDecode(res);
|
||||
return jsonResponse['client_secret'];
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
getPassengerWallet();
|
||||
|
||||
0
lib/controller/payment/stripe.dart
Normal file
0
lib/controller/payment/stripe.dart
Normal file
@@ -3,8 +3,10 @@ import 'dart:io';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_stripe/flutter_stripe.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:ride/constant/info.dart';
|
||||
import 'package:ride/views/auth/captin/login_captin.dart';
|
||||
import 'package:ride/views/auth/login_page.dart';
|
||||
@@ -31,7 +33,7 @@ Future<void> backgroundMessageHandler(RemoteMessage message) async {
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await GetStorage.init();
|
||||
|
||||
Stripe.publishableKey = StripeKey.publishableKey;
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
@@ -64,7 +66,7 @@ class MyApp extends StatelessWidget {
|
||||
LocaleController controller = Get.put(LocaleController());
|
||||
|
||||
return GetMaterialApp(
|
||||
title: AppInfo.appName,
|
||||
title: AppInformation.appName,
|
||||
translations: MyTranslation(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: controller.language,
|
||||
|
||||
@@ -49,7 +49,7 @@ class BarChartWidget extends StatelessWidget {
|
||||
: Column(
|
||||
children: [
|
||||
Text(
|
||||
'Average of Hours of ${AppInfo.appName} is ON for this month'
|
||||
'Average of Hours of ${AppInformation.appName} is ON for this month'
|
||||
.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:ride/controller/home/captin/order_request_controller.dart';
|
||||
import 'package:ride/controller/payment/payment_controller.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/Rate/ride_calculate_driver.dart';
|
||||
import 'package:ride/views/home/Captin/text_scanner.dart';
|
||||
@@ -192,6 +193,14 @@ class HomeCaptain extends StatelessWidget {
|
||||
"Text FlutterMLGoogle",
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
PaymentController().makePayment(18, 'JOD');
|
||||
},
|
||||
child: const Text(
|
||||
"Pay 18 dollar",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -63,13 +63,13 @@ class PassengerWallet extends StatelessWidget {
|
||||
box.read(BoxName.passengerWalletTotal) == null
|
||||
? Text(
|
||||
'You Dont Have Any amount in'.tr +
|
||||
' ${AppInfo.appName}' +
|
||||
' ${AppInformation.appName}' +
|
||||
'Wallet!'.tr,
|
||||
style: AppStyle.title,
|
||||
)
|
||||
: Text(
|
||||
'You Have'.tr +
|
||||
' ${box.read(BoxName.passengerWalletTotal).toString()} JD in ${AppInfo.appName} Wallet',
|
||||
' ${box.read(BoxName.passengerWalletTotal).toString()} JD in ${AppInformation.appName} Wallet',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
),
|
||||
@@ -357,7 +357,7 @@ class PassengerWallet extends StatelessWidget {
|
||||
"items": [
|
||||
{
|
||||
"name":
|
||||
"${AppInfo.appName} Wallet ",
|
||||
"${AppInformation.appName} Wallet ",
|
||||
"quantity": 1,
|
||||
"price":
|
||||
'${controller.selectedAmount}',
|
||||
@@ -368,7 +368,7 @@ class PassengerWallet extends StatelessWidget {
|
||||
// shipping address is not required though
|
||||
"shipping_address": const {
|
||||
"recipient_name":
|
||||
"${AppInfo.appName} Wallet",
|
||||
"${AppInformation.appName} Wallet",
|
||||
"line1": "Shafa Badran",
|
||||
"line2": "",
|
||||
"city": "Amman",
|
||||
|
||||
Reference in New Issue
Block a user