feat: Phase 1 — remove Stripe, switch to e-Transfer

- Drop stripe_payment + stripe_sdk deps; delete stripe pay pages/widgets
- New ETransferPay widget: shows payment@wisetronic.com + R#<orderId> remark
- goPayment stripe/native branches now route to e-Transfer
- pay_now widgets: strip saved-cards section & dead nativePay logic
- my_cards pages rewritten as e-Transfer info (route kept)
- models/utils/constants cleaned of stripe; env constraint -> Dart 3

See UPGRADE_NOTES.md. (Null-safety migration is Phase 3; deps upgrade Phase 2.)
This commit is contained in:
2026-07-24 02:47:13 +08:00
parent f8a90ad305
commit 7ffcc848d0
17 changed files with 371 additions and 1548 deletions

View File

@@ -0,0 +1,206 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../constants.dart';
import '../../generated/l10n.dart';
import '../../models/order.dart';
import '../../routes.dart';
import '../../store/actions.dart';
import '../../store/store.dart';
/// e-Transfer 支付页(替代原 Stripe 收款)。
/// 向顾客展示 e-Transfer 邮箱,并提醒在备注里写 R#<receiptId> 以便自动处理订单。
class ETransferPay extends StatelessWidget {
final Order order;
const ETransferPay({required this.order});
String get _remark =>
'${Constants.ETRANSFER_REMARK_PREFIX}${order.id}';
Future<void> _copy(BuildContext context, String text, String label) async {
await Clipboard.setData(ClipboardData(text: text));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('$label copied')),
);
}
@override
Widget build(BuildContext context) {
store.dispatch(UpdateContext(context));
final isWide = MediaQuery.of(context).size.width > 700;
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios),
onPressed: () => Navigator.of(context).pop(),
),
title: const Text('e-Transfer Payment'),
),
body: Center(
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: isWide ? 640 : double.infinity,
),
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 金额
Container(
padding: const EdgeInsets.symmetric(
vertical: 24, horizontal: 16),
decoration: BoxDecoration(
color: Colors.lightBlueAccent.withOpacity(0.12),
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
S.of(context).payment_amount,
style: const TextStyle(
fontSize: 15, color: Colors.black54),
),
Text(
'\$${order.totalPrice.toStringAsFixed(2)}',
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(height: 24),
const Text(
'Please complete your payment via Interac e-Transfer:',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
const SizedBox(height: 16),
// 邮箱
_CopyRow(
icon: Icons.alternate_email,
title: 'Send e-Transfer to',
value: Constants.ETRANSFER_EMAIL,
onCopy: () => _copy(
context, Constants.ETRANSFER_EMAIL, 'Email'),
),
const SizedBox(height: 16),
// 备注
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0xFFFFF8E1),
border: Border.all(color: Colors.orangeAccent),
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(
children: [
Icon(Icons.priority_high, color: Colors.orange),
SizedBox(width: 8),
Text(
'Important — message / remark',
style: TextStyle(fontWeight: FontWeight.bold),
),
],
),
const SizedBox(height: 8),
const Text(
'In the e-Transfer message (remark) field, please include '
'the following code so we can match and process your order '
'automatically:',
),
const SizedBox(height: 12),
_CopyRow(
icon: Icons.receipt_long,
title: 'Order code',
value: _remark,
emphasize: true,
onCopy: () =>
_copy(context, _remark, 'Order code'),
),
],
),
),
const SizedBox(height: 24),
FilledButton.icon(
icon: const Icon(Icons.check_circle_outline),
label: const Text("I've sent the payment"),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
),
onPressed: () {
Routes.router.navigateTo(context, '/orderdetail/${order.id}',
replace: true);
},
),
],
),
),
),
),
);
}
}
class _CopyRow extends StatelessWidget {
final IconData icon;
final String title;
final String value;
final VoidCallback onCopy;
final bool emphasize;
const _CopyRow({
required this.icon,
required this.title,
required this.value,
required this.onCopy,
this.emphasize = false,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
border: Border.all(color: Colors.black12),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
Icon(icon, color: Colors.lightBlueAccent),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
style: const TextStyle(
fontSize: 12, color: Colors.black54)),
Text(
value,
style: TextStyle(
fontSize: emphasize ? 20 : 16,
fontWeight:
emphasize ? FontWeight.bold : FontWeight.w600,
letterSpacing: emphasize ? 1.0 : 0,
),
),
],
),
),
IconButton(
icon: const Icon(Icons.copy, color: Colors.black54),
onPressed: onCopy,
),
],
),
);
}
}

View File

@@ -1,158 +0,0 @@
import 'package:flutter/material.dart';
import 'package:stripe_payment/stripe_payment.dart';
import '../../constants.dart';
import '../../events/eventbus.dart';
import '../../events/events.dart';
import '../../models/order.dart';
import '../../models/payment_platform.dart';
import '../../models/stripe_payment_method.dart';
import '../../routes.dart';
import '../../store/actions.dart';
import '../../store/store.dart';
import '../../utils/utils.dart';
class StripePay extends StatefulWidget {
final Key key;
final Order order;
final PaymentPlatform paymentPlatform;
final StripePaymentMethod stripePaymentMethod;
const StripePay(this.order, this.paymentPlatform, {this.key, this.stripePaymentMethod});
@override
State<StatefulWidget> createState() {
return StripePayState();
}
}
class StripePayState extends State<StripePay> {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
bool isSubmitting;
@override
Widget build(BuildContext context) {
store.dispatch(UpdateContext(context));
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (widget.stripePaymentMethod != null) {
_paymentWithPaymentMethod(context);
} else {
_paymentRequestWithCardForm(context);
}
});
return Scaffold(
key: _scaffoldKey,
body: Center(
child: Icon(
Icons.credit_card,
size: 40.0,
color: Colors.black26,
),
),
);
}
@override
void initState() {
super.initState();
isSubmitting = false;
StripePayment.setOptions(
StripeOptions(publishableKey: widget.paymentPlatform.publishableKey,
merchantId: widget.paymentPlatform.merchantId,
androidPayMode: 'test')
);
}
_paymentWithPaymentMethod(BuildContext context) async {
Utils.stripePaymentIntent(widget.order, widget.stripePaymentMethod.customerId,
widget.stripePaymentMethod.paymentMethodId,
widget.stripePaymentMethod.paymentMethodType, (response){
if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) {
StripePayment.confirmPaymentIntent(
PaymentIntent(
clientSecret: response.data[Constants.STRIPE_CLIENT_SECRET],
paymentMethodId: response.data['payment_method'],
),
).then((paymentIntentResult) {
if (paymentIntentResult.status == Constants.STRIPE_STATUS_SUCCEDED) {
Utils.stripeChargedSuccess(widget.order,
widget.stripePaymentMethod.paymentMethodId,
paymentIntentResult.paymentIntentId,
(response) {
eventBus.fire(OnOrderUpdated());
Routes.router.navigateTo(context, '/orderdetail/${widget
.order.id}', replace: true);
},
(showErrorDialog)
);
} else {
showErrorDialog(Exception('Unknown error'));
}
}).catchError(showErrorDialog);
}
}, (showErrorDialog));
isSubmitting = true;
Utils.showSubmitDialog(context);
}
_paymentRequestWithCardForm(BuildContext context) async {
StripePayment.paymentRequestWithCardForm(
CardFormPaymentRequest()
).then((paymentMethod) {
Utils.stripePaymentIntent(widget.order, null, paymentMethod.id, paymentMethod.type, (response){
if (response.data['status'] == Constants.STRIPE_STATUS_REQUIRES_CONFIRMATION) {
StripePayment.confirmPaymentIntent(
PaymentIntent(
clientSecret: response.data[Constants.STRIPE_CLIENT_SECRET],
paymentMethodId: response.data['payment_method'],
),
).then((paymentIntentResult) {
if (paymentIntentResult.status == Constants.STRIPE_STATUS_SUCCEDED) {
Utils.stripeChargedSuccess(widget.order,
paymentMethod.id,
paymentIntentResult.paymentIntentId,
(response) {
eventBus.fire(OnOrderUpdated());
Routes.router.navigateTo(context, '/orderdetail/${widget
.order.id}', replace: true);
},
(showErrorDialog)
);
} else {
showErrorDialog(Exception('Unknown error'));
}
}).catchError(showErrorDialog);
}
}, (showErrorDialog),
cardBrand: paymentMethod.card.brand,
cardCountry: paymentMethod.card.country,
cardExpMonth: paymentMethod.card.expMonth,
cardExpYear: paymentMethod.card.expYear,
cardFunding: paymentMethod.card.funding,
cardLast4: paymentMethod.card.last4,
);
}).catchError(showErrorDialog);
isSubmitting = true;
Utils.showSubmitDialog(context);
}
void showErrorDialog(dynamic error) {
if (isSubmitting) {
Navigator.of(context).pop();
isSubmitting = false;
}
Utils.showMessageDialog(context, error, onOk: () {
Navigator.of(context).pop();
Navigator.of(context).pop();
});
}
}