makePayment method

Future<Map<String, dynamic>> makePayment(
  1. BuildContext context,
  2. int amount,
  3. bool sandbox,
  4. String storeName,
  5. String color,
  6. String logoUrl, {
  7. String? callbackUrl,
})

Implementation

Future<Map<String, dynamic>> makePayment(
  BuildContext context,
  int amount,
  bool sandbox,
  String storeName,
  String color,
  String logoUrl, {
  String? callbackUrl,
}) async {
  if (amount <= 0) {
    return {'success': false, 'error': 'Le montant doit être supérieur à 0'};
  }
  if (publicKey.isEmpty) {
    return {'success': false, 'error': 'La clé publique est requise'};
  }

  try {
    final result = await Navigator.of(context).push<Map<String, dynamic>>(
      MaterialPageRoute(
        fullscreenDialog: true,
        builder: (context) => IntramWebViewPayment(
          publicKey: publicKey,
          amount: amount,
          sandbox: sandbox,
          companyName: storeName,
          color: color,
          logoUrl: logoUrl,
          callbackUrl: callbackUrl,
          onPaymentComplete: (result) {},
        ),
      ),
    );

    return result ?? {'success': false, 'cancelled': true};
  } catch (e) {
    return {'success': false, 'error': 'Erreur lors de l\'ouverture du paiement: $e'};
  }
}