Nuevos cambios hechos de diseño
This commit is contained in:
195
desarrollo2/source_code/lib/screens/payments/bkash_screen.dart
Normal file
195
desarrollo2/source_code/lib/screens/payments/bkash_screen.dart
Normal file
@@ -0,0 +1,195 @@
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class BkashScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
BkashScreen({Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "", this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_BkashScreenState createState() => _BkashScreenState();
|
||||
}
|
||||
|
||||
class _BkashScreenState extends State<BkashScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String? _initial_url = "";
|
||||
bool _initial_url_fetched = false;
|
||||
|
||||
|
||||
WebViewController _webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||
String? _token = "";
|
||||
bool showLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_webViewController.setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onProgress: (int progress) {
|
||||
// Update loading bar.
|
||||
},
|
||||
onPageStarted: (String url) {},
|
||||
onPageFinished: (String page) {
|
||||
if (page.contains("/bkash/api/success")) {
|
||||
getData();
|
||||
} else if (page.contains("/bkash/api/fail")) {
|
||||
ToastComponent.showDialog("Payment cancelled",
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
},
|
||||
onWebResourceError: (WebResourceError error) {},
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// on cart payment need proper order id
|
||||
getSetInitialUrl();
|
||||
}
|
||||
|
||||
|
||||
getSetInitialUrl() async {
|
||||
var bkashUrlResponse = await PaymentRepository().getBkashBeginResponse(
|
||||
widget.payment_type, _combined_order_id, widget.package_id,
|
||||
widget.amount);
|
||||
|
||||
if (bkashUrlResponse.result == false) {
|
||||
ToastComponent.showDialog(bkashUrlResponse.message!, gravity: Toast.center,
|
||||
duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
_token = bkashUrlResponse.token;
|
||||
|
||||
_initial_url = bkashUrlResponse.url;
|
||||
_initial_url_fetched = true;
|
||||
|
||||
_webViewController.loadRequest(Uri.parse(_initial_url!));
|
||||
setState(() {});
|
||||
|
||||
// print(_initial_url);
|
||||
// print(_initial_url_fetched);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
buildBody() {
|
||||
if (_initial_url_fetched == false) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(AppLocalizations
|
||||
.of(context)!
|
||||
.fetching_bkash_url),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
height: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height,
|
||||
child: showLoading ? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 1, height: 1,),
|
||||
CircularProgressIndicator(strokeWidth: 3,)
|
||||
],
|
||||
) : WebViewWidget(
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
onPaymentSuccess(payment_details) async {
|
||||
showLoading = true;
|
||||
setState(() {});
|
||||
var bkashPaymentProcessResponse = await PaymentRepository()
|
||||
.getBkashPaymentProcessResponse(
|
||||
amount: widget.amount,
|
||||
token: _token,
|
||||
payment_type: widget.payment_type,
|
||||
combined_order_id: _combined_order_id,
|
||||
package_id: widget.package_id,
|
||||
payment_id: payment_details['paymentID'],
|
||||
);
|
||||
ToastComponent.showDialog(bkashPaymentProcessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
String? payment_details = '';
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if (responseJSON.runtimeType == String) {
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
print(data);
|
||||
if (responseJSON["result"] == false) {
|
||||
Toast.show(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
} else if (responseJSON["result"] == true) {
|
||||
payment_details = responseJSON['payment_details'];
|
||||
onPaymentSuccess(responseJSON);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) =>
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations
|
||||
.of(context)!
|
||||
.pay_with_bkash,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
|
||||
|
||||
class FlutterwaveScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
FlutterwaveScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_FlutterwaveScreenState createState() => _FlutterwaveScreenState();
|
||||
}
|
||||
|
||||
class _FlutterwaveScreenState extends State<FlutterwaveScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String? _initial_url = "";
|
||||
bool _initial_url_fetched = false;
|
||||
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onProgress: (int progress) {
|
||||
// Update loading bar.
|
||||
},
|
||||
onPageStarted: (String url) {},
|
||||
onPageFinished: (page) {
|
||||
//print(page.toString());
|
||||
|
||||
if (page.contains("/flutterwave/payment/callback")) {
|
||||
getData();
|
||||
}
|
||||
},
|
||||
onWebResourceError: (WebResourceError error) {},
|
||||
|
||||
),
|
||||
);
|
||||
|
||||
getSetInitialUrl();
|
||||
|
||||
}
|
||||
|
||||
|
||||
getSetInitialUrl() async {
|
||||
|
||||
var flutterwaveUrlResponse = await PaymentRepository().getFlutterwaveUrlResponse(
|
||||
widget.payment_type, _combined_order_id,widget.package_id ,widget.amount);
|
||||
|
||||
if (flutterwaveUrlResponse.result == false) {
|
||||
ToastComponent.showDialog(flutterwaveUrlResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
_initial_url = flutterwaveUrlResponse.url;
|
||||
_initial_url_fetched = true;
|
||||
|
||||
_webViewController.loadRequest(Uri.parse(_initial_url!));
|
||||
setState(() {});
|
||||
|
||||
//print(_initial_url);
|
||||
//print(_initial_url_fetched);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(data.toString());
|
||||
if (responseJSON["result"] == false) {
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
} else if (responseJSON["result"] == true) {
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buildBody() {
|
||||
if (_order_init == false &&
|
||||
_combined_order_id == 0 &&
|
||||
widget.payment_type == "cart_payment") {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text("Creating order ..."),
|
||||
),
|
||||
);
|
||||
} else if (_initial_url_fetched == false) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text("Fetching Flutterwave url ..."),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: WebViewWidget(
|
||||
controller: _webViewController,
|
||||
|
||||
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
"Pay with Flutterwave",
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
172
desarrollo2/source_code/lib/screens/payments/iyzico_screen.dart
Normal file
172
desarrollo2/source_code/lib/screens/payments/iyzico_screen.dart
Normal file
@@ -0,0 +1,172 @@
|
||||
import 'package:active_ecommerce_seller_app/app_config.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
|
||||
class IyzicoScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
IyzicoScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_IyzicoScreenState createState() => _IyzicoScreenState();
|
||||
}
|
||||
|
||||
class _IyzicoScreenState extends State<IyzicoScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String initial_url="";
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
initial_url =
|
||||
"${AppConfig.BASE_URL}/iyzico/init?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
print(page.toString());
|
||||
getData();
|
||||
},
|
||||
),
|
||||
)
|
||||
..loadRequest(Uri.parse(initial_url));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
print('called.........');
|
||||
String? payment_details = '';
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
try {
|
||||
|
||||
if (responseJSON["result"] == false) {
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
Navigator.pop(context);
|
||||
} else if (responseJSON["result"] == true) {
|
||||
print("a");
|
||||
payment_details = responseJSON['payment_details'];
|
||||
onPaymentSuccess(payment_details);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
print("error");
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onPaymentSuccess(payment_details) async{
|
||||
print("b");
|
||||
|
||||
var iyzicoPaymentSuccessResponse = await PaymentRepository().getIyzicoPaymentSuccessResponse(widget.payment_type, widget.amount,_combined_order_id, payment_details);
|
||||
|
||||
if(iyzicoPaymentSuccessResponse.result == false ){
|
||||
print("c");
|
||||
ToastComponent.showDialog(iyzicoPaymentSuccessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
}
|
||||
print("Success package Payment");
|
||||
|
||||
ToastComponent.showDialog(iyzicoPaymentSuccessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
if (widget.payment_type == "cart_payment") {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
//return OrderList(from_checkout: true);
|
||||
} as Widget Function(BuildContext)));
|
||||
} else if (widget.payment_type == "wallet_payment") {
|
||||
print("d");
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
//return Wallet(from_recharge: true);
|
||||
} as Widget Function(BuildContext)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
buildBody() {
|
||||
//print("init url");
|
||||
//print(initial_url);
|
||||
|
||||
if (_order_init == false &&
|
||||
_combined_order_id == 0 &&
|
||||
widget.payment_type == "cart_payment") {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context)!.no_ucf),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SizedBox.expand(
|
||||
child: Container(
|
||||
child: WebViewWidget(
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_iyzico,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
175
desarrollo2/source_code/lib/screens/payments/nagad_screen.dart
Normal file
175
desarrollo2/source_code/lib/screens/payments/nagad_screen.dart
Normal file
@@ -0,0 +1,175 @@
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
|
||||
class NagadScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
NagadScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_NagadScreenState createState() => _NagadScreenState();
|
||||
}
|
||||
|
||||
class _NagadScreenState extends State<NagadScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String? _initial_url = "";
|
||||
bool _initial_url_fetched = false;
|
||||
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
//print(page.toString());
|
||||
|
||||
if (page.contains("/nagad/verify/") ||
|
||||
page.contains('/check-out/confirm-payment/')) {
|
||||
getData();
|
||||
} else {
|
||||
if (page.contains('confirm-payment')) {
|
||||
print('yessssssss');
|
||||
} else {
|
||||
print('nooooooooo');
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
)
|
||||
;
|
||||
getSetInitialUrl();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
getSetInitialUrl() async {
|
||||
var nagadUrlResponse = await PaymentRepository().getNagadBeginResponse(
|
||||
widget.payment_type, _combined_order_id, widget.package_id,widget.amount);
|
||||
|
||||
if (nagadUrlResponse.result == false) {
|
||||
ToastComponent.showDialog(nagadUrlResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
_initial_url = nagadUrlResponse.url;
|
||||
_initial_url_fetched = true;
|
||||
_webViewController.loadRequest(Uri.parse(_initial_url!));
|
||||
|
||||
setState(() {});
|
||||
|
||||
//print(_initial_url);
|
||||
//print(_initial_url_fetched);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
String? payment_details = '';
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
if (responseJSON["result"] == false) {
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
} else if (responseJSON["result"] == true) {
|
||||
payment_details = responseJSON['payment_details'];
|
||||
onPaymentSuccess(payment_details);
|
||||
}
|
||||
});
|
||||
}
|
||||
onPaymentSuccess(payment_details) async{
|
||||
|
||||
var nagadPaymentProcessResponse = await PaymentRepository().getNagadPaymentProcessResponse(widget.payment_type, widget.amount,_combined_order_id, payment_details);
|
||||
|
||||
if(nagadPaymentProcessResponse.result == false ){
|
||||
|
||||
ToastComponent.showDialog(nagadPaymentProcessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
}
|
||||
|
||||
ToastComponent.showDialog(nagadPaymentProcessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
buildBody() {
|
||||
if (_initial_url_fetched == false) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context)!.fetching_nagad_url),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: WebViewWidget(
|
||||
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_nagad,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
|
||||
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_app_bar.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/file_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/file_repository.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
|
||||
class OfflineScreen extends StatefulWidget {
|
||||
|
||||
String? details;
|
||||
int? offline_payment_id;
|
||||
final int? package_id;
|
||||
final double? rechargeAmount;
|
||||
|
||||
OfflineScreen(
|
||||
{Key? key,
|
||||
this.details,
|
||||
this.offline_payment_id,
|
||||
this.rechargeAmount, this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_OfflineState createState() => _OfflineState();
|
||||
}
|
||||
|
||||
class _OfflineState extends State<OfflineScreen> {
|
||||
ScrollController _mainScrollController = ScrollController();
|
||||
|
||||
TextEditingController _amountController = TextEditingController();
|
||||
TextEditingController _nameController = TextEditingController();
|
||||
TextEditingController _trxIdController = TextEditingController();
|
||||
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
XFile? _photo_file;
|
||||
String? _photo_path = "";
|
||||
int? _photo_upload_id = 0;
|
||||
late BuildContext loadingcontext;
|
||||
|
||||
Future<void> _onPageRefresh() async {
|
||||
reset();
|
||||
}
|
||||
|
||||
reset() {
|
||||
_amountController.clear();
|
||||
_nameController.clear();
|
||||
_trxIdController.clear();
|
||||
_photo_path = "";
|
||||
_photo_upload_id = 0;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
onPressSubmit() async {
|
||||
var amount = _amountController.text.toString();
|
||||
var name = _nameController.text.toString();
|
||||
var trx_id = _trxIdController.text.toString();
|
||||
|
||||
if (amount == "" || name == "" || trx_id == "") {
|
||||
ToastComponent.showDialog(
|
||||
AppLocalizations.of(context)!.amount_name_and_transaction_id_are_necessary,
|
||||
|
||||
gravity: Toast.center,
|
||||
duration: Toast.lengthLong);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_photo_path == "" || _photo_upload_id == 0) {
|
||||
ToastComponent.showDialog(
|
||||
AppLocalizations.of(context)!.photo_proof_is_necessary,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
}
|
||||
loading();
|
||||
var submitResponse = await PaymentRepository()
|
||||
.getOfflinePaymentResponse(
|
||||
amount: amount,
|
||||
name: name,
|
||||
trx_id: trx_id,
|
||||
photo: _photo_upload_id,
|
||||
package_id: widget.package_id);
|
||||
Navigator.pop(loadingcontext);
|
||||
if (submitResponse.result == false) {
|
||||
ToastComponent.showDialog(submitResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
} else {
|
||||
ToastComponent.showDialog(submitResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onPickPhoto(context) async {
|
||||
|
||||
|
||||
//file = await ImagePicker.pickImage(source: ImageSource.camera);
|
||||
_photo_file = await _picker.pickImage(source: ImageSource.gallery);
|
||||
|
||||
if (_photo_file == null) {
|
||||
ToastComponent.showDialog(
|
||||
AppLocalizations.of(context)!.no_file_is_chosen,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
}
|
||||
|
||||
//return;
|
||||
String base64Image = FileHelper.getBase64FormateFile(_photo_file!.path);
|
||||
String fileName = _photo_file!.path.split("/").last;
|
||||
|
||||
var imageUpdateResponse =
|
||||
await FileRepository().getSimpleImageUploadResponse(
|
||||
base64Image,
|
||||
fileName,
|
||||
);
|
||||
|
||||
if (imageUpdateResponse.result == false) {
|
||||
print(imageUpdateResponse.message);
|
||||
ToastComponent.showDialog(imageUpdateResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
} else {
|
||||
ToastComponent.showDialog(imageUpdateResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
|
||||
_photo_path = imageUpdateResponse.path;
|
||||
_photo_upload_id = imageUpdateResponse.upload_id;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_amountController.text = widget.rechargeAmount.toString();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: MyAppBar(context: context,title: AppLocalizations.of(context)!.offline_payment_ucf,).show(),
|
||||
body: buildBody(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.offline_payment_ucf,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
|
||||
buildBody(context) {
|
||||
|
||||
return RefreshIndicator(
|
||||
color: MyTheme.app_accent_color,
|
||||
backgroundColor: Colors.white,
|
||||
onRefresh: _onPageRefresh,
|
||||
displacement: 10,
|
||||
child: CustomScrollView(
|
||||
controller: _mainScrollController,
|
||||
physics: const BouncingScrollPhysics(
|
||||
parent: AlwaysScrollableScrollPhysics()),
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Html(data: widget.details),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Divider(
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
buildProfileForm(context)
|
||||
]),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
buildProfileForm(context) {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 8.0, bottom: 8.0, left: 16.0, right: 16.0),
|
||||
child: Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.all_marked_fields_are_mandatory,
|
||||
style: TextStyle(
|
||||
color: MyTheme.grey_153,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14.0),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!
|
||||
.correctly_fill_up_the_necessary_information,
|
||||
style: TextStyle(color: MyTheme.grey_153, fontSize: 14.0),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
"${AppLocalizations.of(context)!.amount_ucf}*",
|
||||
style: TextStyle(
|
||||
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Container(
|
||||
height: 36,
|
||||
child: TextField(
|
||||
controller: _amountController,
|
||||
autofocus: false,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: "12,000 or Tweleve Thousand Only"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
"${AppLocalizations.of(context)!.name_ucf}*",
|
||||
style: TextStyle(
|
||||
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Container(
|
||||
height: 36,
|
||||
child: TextField(
|
||||
controller: _nameController,
|
||||
autofocus: false,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: "John Doe"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
"${AppLocalizations.of(context)!.transaction_id_ucf}*",
|
||||
style: TextStyle(
|
||||
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Container(
|
||||
height: 36,
|
||||
child: TextField(
|
||||
controller: _trxIdController,
|
||||
autofocus: false,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: "BNI-4654321354"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4.0),
|
||||
child: Text(
|
||||
"${AppLocalizations.of(context)!.photo_permission_ucf}* (${AppLocalizations.of(context)!.only_image_file_allowed})",
|
||||
style: TextStyle(
|
||||
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Container(
|
||||
width: 180,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
border:
|
||||
Border.all(color: MyTheme.textfield_grey, width: 1),
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8.0))),
|
||||
child: Buttons(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
//height: 50,
|
||||
color: MyTheme.medium_grey,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8.0))),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.photo_proof_ucf,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
onPressed: () {
|
||||
onPickPhoto(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
_photo_path != ""
|
||||
? Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child:
|
||||
Text(AppLocalizations.of(context)!.selected_ucf),
|
||||
)
|
||||
: Container()
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
child: Container(
|
||||
width: 120,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
border:
|
||||
Border.all(color: MyTheme.textfield_grey, width: 1),
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8.0))),
|
||||
child: Buttons(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
//height: 50,
|
||||
color: MyTheme.app_accent_color,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(8.0))),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.submit_ucf,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
onPressed: () {
|
||||
onPressSubmit();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
loading() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
loadingcontext = context;
|
||||
return AlertDialog(
|
||||
content: Row(
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("${AppLocalizations.of(context)!.please_wait_ucf}"),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
152
desarrollo2/source_code/lib/screens/payments/paypal_screen.dart
Normal file
152
desarrollo2/source_code/lib/screens/payments/paypal_screen.dart
Normal file
@@ -0,0 +1,152 @@
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaypalScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
PaypalScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_PaypalScreenState createState() => _PaypalScreenState();
|
||||
}
|
||||
|
||||
class _PaypalScreenState extends State<PaypalScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String? _initial_url = "";
|
||||
bool _initial_url_fetched = false;
|
||||
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
//print(page.toString());
|
||||
|
||||
if (page.contains("/paypal/payment/done")) {
|
||||
getData();
|
||||
} else if (page.contains("/paypal/payment/cancel")) {
|
||||
ToastComponent.showDialog("Payment cancelled",
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
// on cart payment need proper order id
|
||||
getSetInitialUrl();
|
||||
|
||||
}
|
||||
|
||||
|
||||
getSetInitialUrl() async {
|
||||
var paypalUrlResponse = await PaymentRepository().getPaypalUrlResponse(
|
||||
widget.payment_type, _combined_order_id,widget.package_id ,widget.amount);
|
||||
|
||||
if (paypalUrlResponse.result == false) {
|
||||
ToastComponent.showDialog(paypalUrlResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
_initial_url = paypalUrlResponse.url;
|
||||
_initial_url_fetched = true;
|
||||
|
||||
_webViewController.loadRequest(Uri.parse(_initial_url!));
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(data.toString());
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
buildBody() {
|
||||
if (_initial_url_fetched == false) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context)!.fetching_paypal_url),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: WebViewWidget(
|
||||
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_paypal,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import 'package:active_ecommerce_seller_app/app_config.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaystackScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
PaystackScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_PaystackScreenState createState() => _PaystackScreenState();
|
||||
}
|
||||
|
||||
class _PaystackScreenState extends State<PaystackScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String initial_url ="";
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
initial_url =
|
||||
"${AppConfig.BASE_URL}/paystack/init?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
|
||||
getData();
|
||||
},
|
||||
),
|
||||
)
|
||||
..loadRequest(Uri.parse(initial_url));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
print('called.........');
|
||||
String? payment_details = '';
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(responseJSON.toString());
|
||||
if (responseJSON["result"] == false) {
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
Navigator.pop(context);
|
||||
} else if (responseJSON["result"] == true) {
|
||||
print("a");
|
||||
payment_details = responseJSON['payment_details'];
|
||||
onPaymentSuccess(payment_details);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onPaymentSuccess(payment_details) async{
|
||||
print("b");
|
||||
|
||||
var paystackPaymentSuccessResponse = await PaymentRepository().getPaystackPaymentSuccessResponse(widget.payment_type, widget.amount,_combined_order_id, payment_details);
|
||||
|
||||
ToastComponent.showDialog(paystackPaymentSuccessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
buildBody() {
|
||||
|
||||
//print("init url");
|
||||
//print(initial_url);
|
||||
|
||||
return SizedBox.expand(
|
||||
child: Container(
|
||||
child: WebViewWidget(
|
||||
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_paystack,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
135
desarrollo2/source_code/lib/screens/payments/paytm_screen.dart
Normal file
135
desarrollo2/source_code/lib/screens/payments/paytm_screen.dart
Normal file
@@ -0,0 +1,135 @@
|
||||
import 'package:active_ecommerce_seller_app/app_config.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/profile_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class PaytmScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
PaytmScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_PaytmScreenState createState() => _PaytmScreenState();
|
||||
}
|
||||
|
||||
class _PaytmScreenState extends State<PaytmScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String initial_url ="";
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
initial_url =
|
||||
"${AppConfig.BASE_URL}/paytm/payment/pay?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
//print(page.toString());
|
||||
|
||||
if (page.contains("/paytm/payment/callback")) {
|
||||
getData();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
..loadRequest(Uri.parse(initial_url));
|
||||
checkPhoneAvailability().then((val) {
|
||||
});
|
||||
}
|
||||
|
||||
checkPhoneAvailability() async {
|
||||
var phoneEmailAvailabilityResponse =
|
||||
await ProfileRepository().getPhoneEmailAvailabilityResponse();
|
||||
print(phoneEmailAvailabilityResponse.toString());
|
||||
if (phoneEmailAvailabilityResponse.phone_available == false) {
|
||||
ToastComponent.showDialog(
|
||||
phoneEmailAvailabilityResponse.phone_available_message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(data.toString());
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
buildBody() {
|
||||
print(initial_url);
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: WebViewWidget(
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_paytm,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
import 'package:active_ecommerce_seller_app/app_config.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class RazorpayScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
RazorpayScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_RazorpayScreenState createState() => _RazorpayScreenState();
|
||||
}
|
||||
|
||||
class _RazorpayScreenState extends State<RazorpayScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String initial_url ="";
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
initial_url =
|
||||
"${AppConfig.BASE_URL}/razorpay/pay-with-razorpay?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
|
||||
getData();
|
||||
},
|
||||
),
|
||||
)
|
||||
..loadRequest(Uri.parse(initial_url));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
print('called.........');
|
||||
String? payment_details = '';
|
||||
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(responseJSON.toString());
|
||||
if (responseJSON["result"] == false) {
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
Navigator.pop(context);
|
||||
} else if (responseJSON["result"] == true) {
|
||||
print("a");
|
||||
payment_details = responseJSON['payment_details'];
|
||||
onPaymentSuccess(payment_details);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onPaymentSuccess(payment_details) async {
|
||||
var razorpayPaymentSuccessResponse = await PaymentRepository()
|
||||
.getRazorpayPaymentSuccessResponse(widget.payment_type, widget.amount,
|
||||
_combined_order_id, payment_details);
|
||||
|
||||
ToastComponent.showDialog(razorpayPaymentSuccessResponse.message!,
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
buildBody() {
|
||||
|
||||
print("init url");
|
||||
print(initial_url);
|
||||
|
||||
return SizedBox.expand(
|
||||
child: Container(
|
||||
child: WebViewWidget(
|
||||
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_razorpay,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class SslCommerzScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String package_id;
|
||||
|
||||
SslCommerzScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",
|
||||
this.package_id="0"
|
||||
})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_SslCommerzScreenState createState() => _SslCommerzScreenState();
|
||||
|
||||
}
|
||||
|
||||
class _SslCommerzScreenState extends State<SslCommerzScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
|
||||
String? _initial_url = "";
|
||||
bool _initial_url_fetched = false;
|
||||
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
//print(page.toString());
|
||||
|
||||
if (page.contains("/sslcommerz/success")) {
|
||||
getData();
|
||||
} else if (page.contains("/sslcommerz/cancel") || page.contains("/sslcommerz/fail")) {
|
||||
ToastComponent.showDialog("Payment cancelled or failed",
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
;
|
||||
super.initState();
|
||||
|
||||
getSetInitialUrl();
|
||||
|
||||
}
|
||||
|
||||
getSetInitialUrl() async {
|
||||
var sslcommerzUrlResponse = await PaymentRepository().getSslcommerzBeginResponse(
|
||||
widget.payment_type, _combined_order_id,widget.package_id, widget.amount);
|
||||
|
||||
if (sslcommerzUrlResponse.result == false) {
|
||||
ToastComponent.showDialog(sslcommerzUrlResponse.message!,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
|
||||
_initial_url = sslcommerzUrlResponse.url;
|
||||
_initial_url_fetched = true;
|
||||
_webViewController.loadRequest(Uri.parse(_initial_url!));
|
||||
|
||||
setState(() {});
|
||||
|
||||
//print(_initial_url);
|
||||
//print(_initial_url_fetched);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(data.toString());
|
||||
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
buildBody() {
|
||||
/* String initial_url =
|
||||
"${AppConfig.BASE_URL}/sslcommerz/begin?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${user_id.$}";*/
|
||||
|
||||
//print("init url");
|
||||
//print(initial_url);
|
||||
|
||||
|
||||
if (_initial_url_fetched == false) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context)!.fetching_sslcommerz_url),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: WebViewWidget(
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_sslcommerz ,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
154
desarrollo2/source_code/lib/screens/payments/stripe_screen.dart
Normal file
154
desarrollo2/source_code/lib/screens/payments/stripe_screen.dart
Normal file
@@ -0,0 +1,154 @@
|
||||
import 'package:active_ecommerce_seller_app/app_config.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class StripeScreen extends StatefulWidget {
|
||||
double amount;
|
||||
String payment_type;
|
||||
String? payment_method_key;
|
||||
String? package_id;
|
||||
|
||||
StripeScreen(
|
||||
{Key? key,
|
||||
this.amount = 0.00,
|
||||
this.payment_type = "",
|
||||
this.payment_method_key = "",this.package_id})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_StripeScreenState createState() => _StripeScreenState();
|
||||
}
|
||||
|
||||
class _StripeScreenState extends State<StripeScreen> {
|
||||
int _combined_order_id = 0;
|
||||
bool _order_init = false;
|
||||
String initial_url ="";
|
||||
late WebViewController _webViewController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
initial_url =
|
||||
"${AppConfig.BASE_URL}/stripe?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
|
||||
|
||||
_webViewController = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onPageFinished: (page) {
|
||||
//print(page.toString());
|
||||
|
||||
if (page.contains("/stripe/success")) {
|
||||
getData();
|
||||
} else if (page.contains("/stripe/cancel")) {
|
||||
ToastComponent.showDialog(
|
||||
AppLocalizations.of(context)!.payment_cancelled_ucf,
|
||||
|
||||
gravity: Toast.center,
|
||||
duration: Toast.lengthLong);
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
),
|
||||
)
|
||||
..loadRequest(Uri.parse(initial_url));
|
||||
}
|
||||
|
||||
// createOrder() async {
|
||||
// var orderCreateResponse = await PaymentRepository()
|
||||
// .getOrderCreateResponse(widget.payment_method_key);
|
||||
//
|
||||
// if (orderCreateResponse.result == false) {
|
||||
// ToastComponent.showDialog(orderCreateResponse.message, context,
|
||||
// gravity: Toast.center, duration: Toast.lengthLong);
|
||||
// Navigator.of(context).pop();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// _combined_order_id = orderCreateResponse.combined_order_id;
|
||||
// _order_init = true;
|
||||
// setState(() {});
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: buildAppBar(context),
|
||||
body: buildBody(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void getData() {
|
||||
_webViewController
|
||||
.runJavaScriptReturningResult("document.body.innerText")
|
||||
.then((data) {
|
||||
var responseJSON = jsonDecode(data as String);
|
||||
if(responseJSON.runtimeType ==String ){
|
||||
responseJSON = jsonDecode(responseJSON);
|
||||
}
|
||||
//print(data.toString());
|
||||
ToastComponent.showDialog(responseJSON["message"],
|
||||
duration: Toast.lengthLong, gravity: Toast.center);
|
||||
Navigator.pop(context);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
buildBody() {
|
||||
|
||||
//print("init url");
|
||||
//print(initial_url);
|
||||
|
||||
if (_order_init == false &&
|
||||
_combined_order_id == 0 &&
|
||||
widget.payment_type == "cart_payment") {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(AppLocalizations.of(context)!.date_ucf),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: WebViewWidget(
|
||||
controller: _webViewController,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppBar buildAppBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
centerTitle: true,
|
||||
leading: Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context)!.pay_with_stripe,
|
||||
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
|
||||
),
|
||||
elevation: 0.0,
|
||||
titleSpacing: 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user