callNowPaymentsService method
Implementation
Future callNowPaymentsService(BuildContext context) async {
NowPaymentsService.initialize(
apiKey: "Q3HG6S0-SPKMAPY-JSENY6Z-VS6T68E", // Live or Sandbox key
isTestMode: true,
);
await Navigator.push(
context,
MaterialPageRoute(
builder: (_) => NowPaymentsCheckoutScreen(
priceAmount: 150,
priceCurrency: "USD",
payCurrency: "USDTTRC20",
orderId: null, // null lets NOWPayments auto-generate one
orderDescription: "Test order for NOWPayments",
onSuccess: (status) {
Navigator.pop(context);
IncodesListener().showToast(msg: "Payment confirmed: ${status.paymentId}");
debugPrint("=== NOWPayments Success ===");
debugPrint("Payment ID: ${status.paymentId}");
debugPrint("Status: ${status.paymentStatus}");
debugPrint("============================");
},
onTerminalFailure: (status) {
Navigator.pop(context);
IncodesListener().showToast(msg: "Payment ${status.paymentStatus}: ${status.paymentId}");
debugPrint("=== NOWPayments Terminal Failure ===");
debugPrint("Payment ID: ${status.paymentId}");
debugPrint("Status: ${status.paymentStatus}");
debugPrint("=====================================");
},
),
),
);
}