簡體   English   中英

Flutterwave_standard flutter 依賴項。 我無法進行活卡支付

[英]Flutterwave_standard flutter dependancy. I can't make live card payment

我嘗試使用Flutterwave_standard flutter 的依賴項向我的flutterwave帳戶付款。 我在isTestMode設置為true時使用測試卡進行的交易是成功的,但是在我將bool值更改為false並將我的publicKey為我的實時儀表板 PublicKey 之后,我收到失敗消息,指出“在測試模式中只允許測試卡”。 請問我需要幫助嗎?

請參閱下面的代碼:

import 'package:flutter/material.dart';
import 'package:flutterwave_standard/flutterwave.dart';

import 'apikey.dart';
import 'constants.dart';

void main() {
  runApp(
    const MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'PayApp',
      home: Home(),
    ),
  );
}

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: handlePayment,
          child: const Text('Go to PayPage'),
        ),
      ),
    );
  }

  void handlePayment() async {
    // assign values to flutterwaveStyle object's properties
    final style = FlutterwaveStyle(
      buttonColor: Util.myPrimaryColor,
      buttonTextStyle:
          const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
      appBarText: 'Proceed to Flutterwave',
      appBarColor: Util.myPrimaryColor,
      appBarIcon: const Icon(Icons.card_travel),
      appBarTitleTextStyle:
          const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
      mainBackgroundColor: Colors.white,
      mainTextStyle: const TextStyle(color: Colors.black45),
      dialogBackgroundColor: Colors.white,
      dialogCancelTextStyle:
          const TextStyle(color: Colors.black54, fontWeight: FontWeight.bold),
      dialogContinueTextStyle:
          const TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
      buttonText: 'Go to CheckOut',
    );

    //assign values to customer object
    final customer = Customer(
      name: 'Paschal',
      phoneNumber: '***********',
      email: '***************',
    );

    //assign values to flutterwave object
    final flutterwave = Flutterwave(
      context: context,
      // publicKey: ApiKey.testPublicKey,
      publicKey: ApiKey.livePublicKey,
      txRef: Util.txtRefKeys,
      // amount: Util.testAmount300,
      amount: Util.liveAmount5,
      customer: customer,
      paymentOptions: 'card',
      // customization: Customization(title: Util.customizationTitleTest),
      customization: Customization(title: Util.customizationTitleLive),
      // isTestMode: Util.yesItsTestMode,
      // isTestMode: Util.noItsNotTestMode,
      isTestMode: false,
      currency: Util.nairaAsCurrency,
      redirectUrl: 'https://www.google.com',
      meta: {
        'payment for:': '\n\tmobile app development',
        'PhoneNumber:': '************',
        'email:': '**************',
      },
      style: style,
    );

    //call Flutterwave's ChargeResponse method
    final ChargeResponse response = await flutterwave.charge();
    if (response.success != null) {
      debugPrint(response.status);
      return showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: const Text(
              'Success',
              textAlign: TextAlign.center,
            ),
            content: const SizedBox(
              height: 100,
              width: 50,
              child: Text('Dear customer,\nYour transaction was successful.'),
            ),
            actions: [
              ElevatedButton(
                onPressed: () {
                  return Navigator.pop(context);
                },
                child: const Text('Close'),
              ),
            ],
          );
        },
      );
    } else {
      debugPrint(response.status);
      return showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: const Text(
              'Failed',
              textAlign: TextAlign.center,
            ),
            content: const SizedBox(
              height: 100,
              width: 50,
              child: Text(
                  'Dear customer,\nSorry your transaction was not successful.'),
            ),
            actions: [
              ElevatedButton(
                onPressed: () {
                  return Navigator.pop(context);
                },
                child: const Text('Close'),
              ),
            ],
          );
        },
      );
    }
  }
}

在此處輸入圖像描述

如果用於測試或實時,您是否檢查過公鑰?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM