BASE: Update Icons & Name Of The App.

This commit is contained in:
2025-12-04 10:23:59 +05:00
parent b04050384d
commit e602782edd
228 changed files with 34364 additions and 7905 deletions

View File

@@ -42,7 +42,7 @@ import '../screen_ui/multi_vendor_service/wallet_screen/wallet_screen.dart';
import '../service/fire_store_utils.dart';
import 'package:customer/utils/preferences.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:uuid/uuid.dart';
@@ -76,27 +76,31 @@ class GiftCardController extends GetxController {
giftCardList = value;
if (giftCardList.isNotEmpty) {
selectedGiftCard.value = giftCardList.first;
messageController.value.text = selectedGiftCard.value.message.toString();
messageController.value.text =
selectedGiftCard.value.message.toString();
}
});
isLoading.value = false;
await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then(
(value) {
if (value != null) {
userModel.value = value;
}
},
);
await FireStoreUtils.getUserProfile(FireStoreUtils.getCurrentUid()).then((
value,
) {
if (value != null) {
userModel.value = value;
}
});
await getPaymentSettings();
}
Future<void> placeOrder() async {
if (selectedPaymentMethod.value == PaymentGateway.wallet.name) {
if (double.parse(userModel.value.walletAmount.toString()) >= double.parse(amountController.value.text)) {
if (double.parse(userModel.value.walletAmount.toString()) >=
double.parse(amountController.value.text)) {
setOrder();
} else {
ShowToastDialog.showToast("You don't have sufficient wallet balance to purchase gift card".tr());
ShowToastDialog.showToast(
"You don't have sufficient wallet balance to purchase gift card".tr(),
);
}
} else {
setOrder();
@@ -116,26 +120,34 @@ class GiftCardController extends GetxController {
giftCardsOrderModel.giftCode = generateGiftCode();
giftCardsOrderModel.paymentType = selectedPaymentMethod.value;
giftCardsOrderModel.createdDate = Timestamp.now();
DateTime dateTime = DateTime.now().add(Duration(days: int.parse(selectedGiftCard.value.expiryDay ?? "2")));
DateTime dateTime = DateTime.now().add(
Duration(days: int.parse(selectedGiftCard.value.expiryDay ?? "2")),
);
giftCardsOrderModel.expireDate = Timestamp.fromDate(dateTime);
giftCardsOrderModel.userid = FireStoreUtils.getCurrentUid();
if (selectedPaymentMethod.value == PaymentGateway.wallet.name) {
WalletTransactionModel transactionModel = WalletTransactionModel(
id: Constant.getUuid(),
amount: double.parse(amountController.value.text),
date: Timestamp.now(),
paymentMethod: PaymentGateway.wallet.name,
transactionUser: "user",
userId: FireStoreUtils.getCurrentUid(),
isTopup: false,
orderId: giftCardsOrderModel.id,
note: "Gift card purchase amount debited".tr(),
paymentStatus: "success".tr());
id: Constant.getUuid(),
amount: double.parse(amountController.value.text),
date: Timestamp.now(),
paymentMethod: PaymentGateway.wallet.name,
transactionUser: "user",
userId: FireStoreUtils.getCurrentUid(),
isTopup: false,
orderId: giftCardsOrderModel.id,
note: "Gift card purchase amount debited".tr(),
paymentStatus: "success".tr(),
);
await FireStoreUtils.setWalletTransaction(transactionModel).then((value) async {
await FireStoreUtils.setWalletTransaction(transactionModel).then((
value,
) async {
if (value == true) {
await FireStoreUtils.updateUserWallet(amount: "-${amountController.value.text.toString()}", userId: FireStoreUtils.getCurrentUid()).then((value) {});
await FireStoreUtils.updateUserWallet(
amount: "-${amountController.value.text.toString()}",
userId: FireStoreUtils.getCurrentUid(),
).then((value) {});
}
});
}
@@ -179,54 +191,78 @@ class GiftCardController extends GetxController {
Rx<Xendit> xenditModel = Xendit().obs;
Future<void> getPaymentSettings() async {
await FireStoreUtils.getPaymentSettingsData().then(
(value) {
payFastModel.value = PayFastModel.fromJson(jsonDecode(Preferences.getString(Preferences.payFastSettings)));
mercadoPagoModel.value = MercadoPagoModel.fromJson(jsonDecode(Preferences.getString(Preferences.mercadoPago)));
payPalModel.value = PayPalModel.fromJson(jsonDecode(Preferences.getString(Preferences.paypalSettings)));
stripeModel.value = StripeModel.fromJson(jsonDecode(Preferences.getString(Preferences.stripeSettings)));
flutterWaveModel.value = FlutterWaveModel.fromJson(jsonDecode(Preferences.getString(Preferences.flutterWave)));
payStackModel.value = PayStackModel.fromJson(jsonDecode(Preferences.getString(Preferences.payStack)));
paytmModel.value = PaytmModel.fromJson(jsonDecode(Preferences.getString(Preferences.paytmSettings)));
razorPayModel.value = RazorPayModel.fromJson(jsonDecode(Preferences.getString(Preferences.razorpaySettings)));
cashOnDeliverySettingModel.value = CodSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.codSettings)));
midTransModel.value = MidTrans.fromJson(jsonDecode(Preferences.getString(Preferences.midTransSettings)));
orangeMoneyModel.value = OrangeMoney.fromJson(jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)));
xenditModel.value = Xendit.fromJson(jsonDecode(Preferences.getString(Preferences.xenditSettings)));
walletSettingModel.value = WalletSettingModel.fromJson(jsonDecode(Preferences.getString(Preferences.walletSettings)));
if (walletSettingModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.wallet.name;
} else if (stripeModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.stripe.name;
} else if (payPalModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.paypal.name;
} else if (payStackModel.value.isEnable == true) {
selectedPaymentMethod.value = PaymentGateway.payStack.name;
} else if (mercadoPagoModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.mercadoPago.name;
} else if (flutterWaveModel.value.isEnable == true) {
selectedPaymentMethod.value = PaymentGateway.flutterWave.name;
}else if (payFastModel.value.isEnable == true) {
selectedPaymentMethod.value = PaymentGateway.payFast.name;
} else if (razorPayModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.razorpay.name;
} else if (midTransModel.value.enable == true) {
selectedPaymentMethod.value = PaymentGateway.midTrans.name;
} else if (orangeMoneyModel.value.enable == true) {
selectedPaymentMethod.value = PaymentGateway.orangeMoney.name;
} else if (xenditModel.value.enable == true) {
selectedPaymentMethod.value = PaymentGateway.xendit.name;
}
Stripe.publishableKey = stripeModel.value.clientpublishableKey.toString();
Stripe.merchantIdentifier = 'GoRide';
Stripe.instance.applySettings();
setRef();
await FireStoreUtils.getPaymentSettingsData().then((value) {
payFastModel.value = PayFastModel.fromJson(
jsonDecode(Preferences.getString(Preferences.payFastSettings)),
);
mercadoPagoModel.value = MercadoPagoModel.fromJson(
jsonDecode(Preferences.getString(Preferences.mercadoPago)),
);
payPalModel.value = PayPalModel.fromJson(
jsonDecode(Preferences.getString(Preferences.paypalSettings)),
);
stripeModel.value = StripeModel.fromJson(
jsonDecode(Preferences.getString(Preferences.stripeSettings)),
);
flutterWaveModel.value = FlutterWaveModel.fromJson(
jsonDecode(Preferences.getString(Preferences.flutterWave)),
);
payStackModel.value = PayStackModel.fromJson(
jsonDecode(Preferences.getString(Preferences.payStack)),
);
paytmModel.value = PaytmModel.fromJson(
jsonDecode(Preferences.getString(Preferences.paytmSettings)),
);
razorPayModel.value = RazorPayModel.fromJson(
jsonDecode(Preferences.getString(Preferences.razorpaySettings)),
);
cashOnDeliverySettingModel.value = CodSettingModel.fromJson(
jsonDecode(Preferences.getString(Preferences.codSettings)),
);
midTransModel.value = MidTrans.fromJson(
jsonDecode(Preferences.getString(Preferences.midTransSettings)),
);
orangeMoneyModel.value = OrangeMoney.fromJson(
jsonDecode(Preferences.getString(Preferences.orangeMoneySettings)),
);
xenditModel.value = Xendit.fromJson(
jsonDecode(Preferences.getString(Preferences.xenditSettings)),
);
walletSettingModel.value = WalletSettingModel.fromJson(
jsonDecode(Preferences.getString(Preferences.walletSettings)),
);
if (walletSettingModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.wallet.name;
} else if (stripeModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.stripe.name;
} else if (payPalModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.paypal.name;
} else if (payStackModel.value.isEnable == true) {
selectedPaymentMethod.value = PaymentGateway.payStack.name;
} else if (mercadoPagoModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.mercadoPago.name;
} else if (flutterWaveModel.value.isEnable == true) {
selectedPaymentMethod.value = PaymentGateway.flutterWave.name;
} else if (payFastModel.value.isEnable == true) {
selectedPaymentMethod.value = PaymentGateway.payFast.name;
} else if (razorPayModel.value.isEnabled == true) {
selectedPaymentMethod.value = PaymentGateway.razorpay.name;
} else if (midTransModel.value.enable == true) {
selectedPaymentMethod.value = PaymentGateway.midTrans.name;
} else if (orangeMoneyModel.value.enable == true) {
selectedPaymentMethod.value = PaymentGateway.orangeMoney.name;
} else if (xenditModel.value.enable == true) {
selectedPaymentMethod.value = PaymentGateway.xendit.name;
}
Stripe.publishableKey = stripeModel.value.clientpublishableKey.toString();
Stripe.merchantIdentifier = 'GoRide';
Stripe.instance.applySettings();
setRef();
razorPay.on(Razorpay.EVENT_PAYMENT_SUCCESS, handlePaymentSuccess);
razorPay.on(Razorpay.EVENT_EXTERNAL_WALLET, handleExternalWaller);
razorPay.on(Razorpay.EVENT_PAYMENT_ERROR, handlePaymentError);
},
);
razorPay.on(Razorpay.EVENT_PAYMENT_SUCCESS, handlePaymentSuccess);
razorPay.on(Razorpay.EVENT_EXTERNAL_WALLET, handleExternalWaller);
razorPay.on(Razorpay.EVENT_PAYMENT_ERROR, handlePaymentError);
});
}
// final _flutterPaypalNativePlugin = FlutterPaypalNative.instance;
@@ -297,28 +333,34 @@ class GiftCardController extends GetxController {
// Strip
Future<void> stripeMakePayment({required String amount}) async {
try {
Map<String, dynamic>? paymentIntentData = await createStripeIntent(amount: amount);
Map<String, dynamic>? paymentIntentData = await createStripeIntent(
amount: amount,
);
if (paymentIntentData!.containsKey("error")) {
Get.back();
ShowToastDialog.showToast("Something went wrong, please contact admin.");
ShowToastDialog.showToast(
"Something went wrong, please contact admin.",
);
} else {
await Stripe.instance.initPaymentSheet(
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: paymentIntentData['client_secret'],
allowsDelayedPaymentMethods: false,
googlePay: const PaymentSheetGooglePay(
merchantCountryCode: 'US',
testEnv: true,
currencyCode: "USD",
),
customFlow: true,
style: ThemeMode.system,
appearance: PaymentSheetAppearance(
colors: PaymentSheetAppearanceColors(
primary: AppThemeData.primary300,
),
),
merchantDisplayName: 'GoRide'));
paymentSheetParameters: SetupPaymentSheetParameters(
paymentIntentClientSecret: paymentIntentData['client_secret'],
allowsDelayedPaymentMethods: false,
googlePay: const PaymentSheetGooglePay(
merchantCountryCode: 'US',
testEnv: true,
currencyCode: "USD",
),
customFlow: true,
style: ThemeMode.system,
appearance: PaymentSheetAppearance(
colors: PaymentSheetAppearanceColors(
primary: AppThemeData.primary300,
),
),
merchantDisplayName: 'GoRide',
),
);
displayStripePaymentSheet(amount: amount);
}
} catch (e, s) {
@@ -357,8 +399,14 @@ class GiftCardController extends GetxController {
"shipping[address][country]": "US",
};
var stripeSecret = stripeModel.value.stripeSecret;
var response = await http.post(Uri.parse('https://api.stripe.com/v1/payment_intents'),
body: body, headers: {'Authorization': 'Bearer $stripeSecret', 'Content-Type': 'application/x-www-form-urlencoded'});
var response = await http.post(
Uri.parse('https://api.stripe.com/v1/payment_intents'),
body: body,
headers: {
'Authorization': 'Bearer $stripeSecret',
'Content-Type': 'application/x-www-form-urlencoded',
},
);
return jsonDecode(response.body);
} catch (e) {
@@ -367,7 +415,10 @@ class GiftCardController extends GetxController {
}
//mercadoo
Future<Null> mercadoPagoMakePayment({required BuildContext context, required String amount}) async {
Future<Null> mercadoPagoMakePayment({
required BuildContext context,
required String amount,
}) async {
final headers = {
'Authorization': 'Bearer ${mercadoPagoModel.value.accessToken}',
'Content-Type': 'application/json',
@@ -381,7 +432,7 @@ class GiftCardController extends GetxController {
"quantity": 1,
"currency_id": "BRL", // or your preferred currency
"unit_price": double.parse(amount),
}
},
],
"payer": {"email": userModel.value.email},
"back_urls": {
@@ -389,7 +440,8 @@ class GiftCardController extends GetxController {
"pending": "${Constant.globalUrl}payment/pending",
"success": "${Constant.globalUrl}payment/success",
},
"auto_return": "approved" // Automatically return after payment is approved
"auto_return":
"approved", // Automatically return after payment is approved
});
final response = await http.post(
@@ -417,18 +469,22 @@ class GiftCardController extends GetxController {
///PayStack Payment Method
Future<void> payStackPayment(String totalAmount) async {
await PayStackURLGen.payStackURLGen(
amount: (double.parse(totalAmount) * 100).toString(), currency: "ZAR", secretKey: payStackModel.value.secretKey.toString(), userModel: userModel.value)
.then((value) async {
amount: (double.parse(totalAmount) * 100).toString(),
currency: "ZAR",
secretKey: payStackModel.value.secretKey.toString(),
userModel: userModel.value,
).then((value) async {
if (value != null) {
PayStackUrlModel payStackModel0 = value;
Get.to(PayStackScreen(
secretKey: payStackModel.value.secretKey.toString(),
callBackUrl: payStackModel.value.callbackURL.toString(),
initialURl: payStackModel0.data.authorizationUrl,
amount: totalAmount,
reference: payStackModel0.data.reference,
))!
.then((value) {
Get.to(
PayStackScreen(
secretKey: payStackModel.value.secretKey.toString(),
callBackUrl: payStackModel.value.callbackURL.toString(),
initialURl: payStackModel0.data.authorizationUrl,
amount: totalAmount,
reference: payStackModel0.data.reference,
),
)!.then((value) {
if (value) {
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
@@ -437,13 +493,18 @@ class GiftCardController extends GetxController {
}
});
} else {
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
}
});
}
//flutter wave Payment Method
Future<Null> flutterWaveInitiatePayment({required BuildContext context, required String amount}) async {
Future<Null> flutterWaveInitiatePayment({
required BuildContext context,
required String amount,
}) async {
final url = Uri.parse('https://api.flutterwave.com/v3/payments');
final headers = {
'Authorization': 'Bearer ${flutterWaveModel.value.secretKey}',
@@ -464,14 +525,16 @@ class GiftCardController extends GetxController {
"customizations": {
"title": "Payment for Services",
"description": "Payment for XYZ services",
}
},
});
final response = await http.post(url, headers: headers, body: body);
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((value) {
Get.to(MercadoPagoScreen(initialURl: data['data']['link']))!.then((
value,
) {
if (value) {
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
@@ -500,8 +563,14 @@ class GiftCardController extends GetxController {
// payFast
void payFastPayment({required BuildContext context, required String amount}) {
PayStackURLGen.getPayHTML(payFastSettingData: payFastModel.value, amount: amount.toString(), userModel: userModel.value).then((String? value) async {
bool isDone = await Get.to(PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value));
PayStackURLGen.getPayHTML(
payFastSettingData: payFastModel.value,
amount: amount.toString(),
userModel: userModel.value,
).then((String? value) async {
bool isDone = await Get.to(
PayFastScreen(htmlData: value!, payFastSettingData: payFastModel.value),
);
if (isDone) {
Get.back();
ShowToastDialog.showToast("Payment successfully".tr());
@@ -513,38 +582,40 @@ class GiftCardController extends GetxController {
});
}
//PayPal
//PayPal
void paypalPaymentSheet(String amount, context) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) => UsePaypal(
sandboxMode: payPalModel.value.isLive == true ? false : true,
clientId: payPalModel.value.paypalClient ?? '',
secretKey: payPalModel.value.paypalSecret ?? '',
returnURL: "com.parkme://paypalpay",
cancelURL: "com.parkme://paypalpay",
transactions: [
{
"amount": {
"total": amount,
"currency": "USD",
"details": {"subtotal": amount}
builder:
(BuildContext context) => UsePaypal(
sandboxMode: payPalModel.value.isLive == true ? false : true,
clientId: payPalModel.value.paypalClient ?? '',
secretKey: payPalModel.value.paypalSecret ?? '',
returnURL: "com.parkme://paypalpay",
cancelURL: "com.parkme://paypalpay",
transactions: [
{
"amount": {
"total": amount,
"currency": "USD",
"details": {"subtotal": amount},
},
},
}
],
note: "Contact us for any questions on your order.",
onSuccess: (Map params) async {
placeOrder();
ShowToastDialog.showToast("Payment Successful!!".tr());
},
onError: (error) {
Get.back();
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
},
onCancel: (params) {
Get.back();
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
}),
],
note: "Contact us for any questions on your order.",
onSuccess: (Map params) async {
placeOrder();
ShowToastDialog.showToast("Payment Successful!!".tr());
},
onError: (error) {
Get.back();
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
},
onCancel: (params) {
Get.back();
ShowToastDialog.showToast("Payment UnSuccessful!!".tr());
},
),
),
);
}
@@ -555,33 +626,52 @@ class GiftCardController extends GetxController {
String getChecksum = "${Constant.globalUrl}payments/getpaytmchecksum";
final response = await http.post(
Uri.parse(
getChecksum,
),
headers: {},
body: {
"mid": paytmModel.value.paytmMID.toString(),
"order_id": orderId,
"key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(),
});
Uri.parse(getChecksum),
headers: {},
body: {
"mid": paytmModel.value.paytmMID.toString(),
"order_id": orderId,
"key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(),
},
);
final data = jsonDecode(response.body);
await verifyCheckSum(checkSum: data["code"], amount: amount, orderId: orderId).then((value) {
await verifyCheckSum(
checkSum: data["code"],
amount: amount,
orderId: orderId,
).then((value) {
initiatePayment(amount: amount, orderId: orderId).then((value) {
String callback = "";
if (paytmModel.value.isSandboxEnabled == true) {
callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
callback =
"${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
} else {
callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
callback =
"${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
}
GetPaymentTxtTokenModel result = value;
startTransaction(context, txnTokenBy: result.body.txnToken ?? '', orderId: orderId, amount: amount, callBackURL: callback, isStaging: paytmModel.value.isSandboxEnabled);
startTransaction(
context,
txnTokenBy: result.body.txnToken ?? '',
orderId: orderId,
amount: amount,
callBackURL: callback,
isStaging: paytmModel.value.isSandboxEnabled,
);
});
});
}
Future<void> startTransaction(context, {required String txnTokenBy, required orderId, required double amount, required callBackURL, required isStaging}) async {
Future<void> startTransaction(
context, {
required String txnTokenBy,
required orderId,
required double amount,
required callBackURL,
required isStaging,
}) async {
// try {
// var response = AllInOneSdk.startTransaction(
// paytmModel.value.paytmMID.toString(),
@@ -616,46 +706,61 @@ class GiftCardController extends GetxController {
// }
}
Future verifyCheckSum({required String checkSum, required double amount, required orderId}) async {
Future verifyCheckSum({
required String checkSum,
required double amount,
required orderId,
}) async {
String getChecksum = "${Constant.globalUrl}payments/validatechecksum";
final response = await http.post(
Uri.parse(
getChecksum,
),
headers: {},
body: {
"mid": paytmModel.value.paytmMID.toString(),
"order_id": orderId,
"key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(),
"checksum_value": checkSum,
});
Uri.parse(getChecksum),
headers: {},
body: {
"mid": paytmModel.value.paytmMID.toString(),
"order_id": orderId,
"key_secret": paytmModel.value.pAYTMMERCHANTKEY.toString(),
"checksum_value": checkSum,
},
);
final data = jsonDecode(response.body);
return data['status'];
}
Future<GetPaymentTxtTokenModel> initiatePayment({required double amount, required orderId}) async {
Future<GetPaymentTxtTokenModel> initiatePayment({
required double amount,
required orderId,
}) async {
String initiateURL = "${Constant.globalUrl}payments/initiatepaytmpayment";
String callback = "";
if (paytmModel.value.isSandboxEnabled == true) {
callback = "${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
callback =
"${callback}https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
} else {
callback = "${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
callback =
"${callback}https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=$orderId";
}
final response = await http.post(Uri.parse(initiateURL), headers: {}, body: {
"mid": paytmModel.value.paytmMID,
"order_id": orderId,
"key_secret": paytmModel.value.pAYTMMERCHANTKEY,
"amount": amount.toString(),
"currency": "INR",
"callback_url": callback,
"custId": FireStoreUtils.getCurrentUid(),
"issandbox": paytmModel.value.isSandboxEnabled == true ? "1" : "2",
});
final response = await http.post(
Uri.parse(initiateURL),
headers: {},
body: {
"mid": paytmModel.value.paytmMID,
"order_id": orderId,
"key_secret": paytmModel.value.pAYTMMERCHANTKEY,
"amount": amount.toString(),
"currency": "INR",
"callback_url": callback,
"custId": FireStoreUtils.getCurrentUid(),
"issandbox": paytmModel.value.isSandboxEnabled == true ? "1" : "2",
},
);
print(response.body);
final data = jsonDecode(response.body);
if (data["body"]["txnToken"] == null || data["body"]["txnToken"].toString().isEmpty) {
if (data["body"]["txnToken"] == null ||
data["body"]["txnToken"].toString().isEmpty) {
Get.back();
ShowToastDialog.showToast("something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"something went wrong, please contact admin.".tr(),
);
}
return GetPaymentTxtTokenModel.fromJson(data);
}
@@ -678,8 +783,8 @@ class GiftCardController extends GetxController {
'email': userModel.value.email,
},
'external': {
'wallets': ['paytm']
}
'wallets': ['paytm'],
},
};
try {
@@ -706,14 +811,14 @@ class GiftCardController extends GetxController {
}
//Midtrans payment
Future<void> midtransMakePayment({required String amount, required BuildContext context}) async {
Future<void> midtransMakePayment({
required String amount,
required BuildContext context,
}) async {
await createPaymentLink(amount: amount).then((url) {
ShowToastDialog.closeLoader();
if (url != '') {
Get.to(() => MidtransScreen(
initialURl: url,
))!
.then((value) {
Get.to(() => MidtransScreen(initialURl: url))!.then((value) {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
@@ -727,14 +832,20 @@ class GiftCardController extends GetxController {
Future<String> createPaymentLink({required var amount}) async {
var ordersId = const Uuid().v1();
final url = Uri.parse(midTransModel.value.isSandbox! ? 'https://api.sandbox.midtrans.com/v1/payment-links' : 'https://api.midtrans.com/v1/payment-links');
final url = Uri.parse(
midTransModel.value.isSandbox!
? 'https://api.sandbox.midtrans.com/v1/payment-links'
: 'https://api.midtrans.com/v1/payment-links',
);
final response = await http.post(
url,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': generateBasicAuthHeader(midTransModel.value.serverKey!),
'Authorization': generateBasicAuthHeader(
midTransModel.value.serverKey!,
),
},
body: jsonEncode({
'transaction_details': {
@@ -742,7 +853,9 @@ class GiftCardController extends GetxController {
'gross_amount': double.parse(amount.toString()).toInt(),
},
'usage_limit': 2,
"callbacks": {"finish": "https://www.google.com?merchant_order_id=$ordersId"},
"callbacks": {
"finish": "https://www.google.com?merchant_order_id=$ordersId",
},
}),
);
@@ -750,7 +863,9 @@ class GiftCardController extends GetxController {
final responseData = jsonDecode(response.body);
return responseData['payment_url'];
} else {
ShowToastDialog.showToast("something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"something went wrong, please contact admin.".tr(),
);
return '';
}
}
@@ -767,21 +882,30 @@ class GiftCardController extends GetxController {
static String orderId = '';
static String amount = '';
Future<void> orangeMakePayment({required String amount, required BuildContext context}) async {
Future<void> orangeMakePayment({
required String amount,
required BuildContext context,
}) async {
reset();
var id = const Uuid().v4();
var paymentURL = await fetchToken(context: context, orderId: id, amount: amount, currency: 'USD');
var paymentURL = await fetchToken(
context: context,
orderId: id,
amount: amount,
currency: 'USD',
);
ShowToastDialog.closeLoader();
if (paymentURL.toString() != '') {
Get.to(() => OrangeMoneyScreen(
initialURl: paymentURL,
accessToken: accessToken,
amount: amount,
orangePay: orangeMoneyModel.value,
orderId: orderId,
payToken: payToken,
))!
.then((value) {
Get.to(
() => OrangeMoneyScreen(
initialURl: paymentURL,
accessToken: accessToken,
amount: amount,
orangePay: orangeMoneyModel.value,
orderId: orderId,
payToken: payToken,
),
)!.then((value) {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
@@ -793,19 +917,24 @@ class GiftCardController extends GetxController {
}
}
Future fetchToken({required String orderId, required String currency, required BuildContext context, required String amount}) async {
Future fetchToken({
required String orderId,
required String currency,
required BuildContext context,
required String amount,
}) async {
String apiUrl = 'https://api.orange.com/oauth/v3/token';
Map<String, String> requestBody = {
'grant_type': 'client_credentials',
};
Map<String, String> requestBody = {'grant_type': 'client_credentials'};
var response = await http.post(Uri.parse(apiUrl),
headers: <String, String>{
'Authorization': "Basic ${orangeMoneyModel.value.auth!}",
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
},
body: requestBody);
var response = await http.post(
Uri.parse(apiUrl),
headers: <String, String>{
'Authorization': "Basic ${orangeMoneyModel.value.auth!}",
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
},
body: requestBody,
);
// Handle the response
@@ -814,18 +943,32 @@ class GiftCardController extends GetxController {
accessToken = responseData['access_token'];
// ignore: use_build_context_synchronously
return await webpayment(context: context, amountData: amount, currency: currency, orderIdData: orderId);
return await webpayment(
context: context,
amountData: amount,
currency: currency,
orderIdData: orderId,
);
} else {
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
return '';
}
}
Future webpayment({required String orderIdData, required BuildContext context, required String currency, required String amountData}) async {
Future webpayment({
required String orderIdData,
required BuildContext context,
required String currency,
required String amountData,
}) async {
orderId = orderIdData;
amount = amountData;
String apiUrl =
orangeMoneyModel.value.isSandbox! == true ? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment' : 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment';
orangeMoneyModel.value.isSandbox! == true
? 'https://api.orange.com/orange-money-webpay/dev/v1/webpayment'
: 'https://api.orange.com/orange-money-webpay/cm/v1/webpayment';
Map<String, String> requestBody = {
"merchant_key": orangeMoneyModel.value.merchantKey ?? '',
"currency": orangeMoneyModel.value.isSandbox == true ? "OUV" : currency,
@@ -840,7 +983,11 @@ class GiftCardController extends GetxController {
var response = await http.post(
Uri.parse(apiUrl),
headers: <String, String>{'Authorization': 'Bearer $accessToken', 'Content-Type': 'application/json', 'Accept': 'application/json'},
headers: <String, String>{
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: json.encode(requestBody),
);
@@ -854,7 +1001,9 @@ class GiftCardController extends GetxController {
return '';
}
} else {
ShowToastDialog.showToast("Something went wrong, please contact admin.".tr());
ShowToastDialog.showToast(
"Something went wrong, please contact admin.".tr(),
);
return '';
}
}
@@ -871,12 +1020,13 @@ class GiftCardController extends GetxController {
await createXenditInvoice(amount: amount).then((model) {
ShowToastDialog.closeLoader();
if (model.id != null) {
Get.to(() => XenditScreen(
initialURl: model.invoiceUrl ?? '',
transId: model.id ?? '',
apiKey: xenditModel.value.apiKey!.toString(),
))!
.then((value) {
Get.to(
() => XenditScreen(
initialURl: model.invoiceUrl ?? '',
transId: model.id ?? '',
apiKey: xenditModel.value.apiKey!.toString(),
),
)!.then((value) {
if (value == true) {
ShowToastDialog.showToast("Payment Successful!!".tr());
placeOrder();
@@ -893,7 +1043,9 @@ class GiftCardController extends GetxController {
const url = 'https://api.xendit.co/v2/invoices';
var headers = {
'Content-Type': 'application/json',
'Authorization': generateBasicAuthHeader(xenditModel.value.apiKey!.toString()),
'Authorization': generateBasicAuthHeader(
xenditModel.value.apiKey!.toString(),
),
// 'Cookie': '__cf_bm=yERkrx3xDITyFGiou0bbKY1bi7xEwovHNwxV1vCNbVc-1724155511-1.0.1.1-jekyYQmPCwY6vIJ524K0V6_CEw6O.dAwOmQnHtwmaXO_MfTrdnmZMka0KZvjukQgXu5B.K_6FJm47SGOPeWviQ',
};
@@ -906,7 +1058,11 @@ class GiftCardController extends GetxController {
});
try {
final response = await http.post(Uri.parse(url), headers: headers, body: body);
final response = await http.post(
Uri.parse(url),
headers: headers,
body: body,
);
if (response.statusCode == 200 || response.statusCode == 201) {
XenditModel model = XenditModel.fromJson(jsonDecode(response.body));