如何解决 PayU Money 不支持空安全错误

huangapple go评论108阅读模式
英文:

how to solve payu money don't support null safety error

问题

Sure, here's the translated portion of your code:

>错误:由于以下依赖项不支持空安全,因此无法运行声音空安全:

 - package:payu_money_flutter

有关解决方案,请参阅https://dart.dev/go/unsound-null-safety

>未处理的异常:
不支持的Null安全模式NonNullableByDefaultCompiledMode.Invalid,为空。

version: 1.0.0+1
configurations:

  • name: "Flutter"
    request: "launch"
    type: "dart"
    program: "lib/fill_detail.dart"
    args: ["--sound-null-safety"]

environment:
sdk: '>=2.19.5 <3.0.0'

dependencies:
flutter:
sdk: flutter
payu_checkoutpro_flutter: ^1.0.2
payu_money_flutter: ^0.0.3



```dart
@override
  void initState() {
    super.initState();
    fetchCountries();
    fetchPlans();
    setupPayment();
  }
String txnToken = &quot;your_transaction_token&quot;;
  String orderId = &quot;your_order_id&quot;;
  double amount1 = 10.0;

  // Function for setting up the payment details
  PayuMoneyFlutter payuMoneyFlutter = PayuMoneyFlutter();
  setupPayment() async {
    bool response = await payuMoneyFlutter.setupPaymentKeys(
      merchantKey: &quot;nxpvv9VZ&quot;,
      merchantID: &quot;3oFxUMtWG2&quot;,
      isProduction: true,
      activityTitle: &quot;Payumoney&quot;,
      disableExitConfirmation: false,
    );

    print(&quot;response --&gt; $response&quot;);
  }

  void handlePaymentResponse(Map&lt;String, dynamic&gt; paymentResponse) {
    String responseCode = paymentResponse[&#39;responseCode&#39;];
    String status = paymentResponse[&#39;status&#39;];
    String message = paymentResponse[&#39;message&#39;];
    String transactionId = paymentResponse[&#39;transactionId&#39;];

    if (responseCode == &quot;01&quot; &amp;&amp; status == &quot;success&quot;) {
      // Payment successful
      print(&quot;Payment successful. Transaction ID: $transactionId&quot;);
    } else if (responseCode == &quot;141&quot; &amp;&amp; status == &quot;userCancelled&quot;) {
      // Payment cancelled by user
      print(&quot;Payment cancelled by user&quot;);
    } else {
      // Payment failed
      print(&quot;Payment failed. Response Code: $responseCode. Message: $message&quot;);
    }
  }

  @override
  void dispose() {
    super.dispose();
    setupPayment();
  }

我想永久解决这段代码中的空安全错误。

英文:

>Error: Cannot run with sound null safety, because the following dependencies don't support null safety:

  • package:payu_money_flutter

For solutions, see https://dart.dev/go/unsound-null-safety

>Unhandled exception:
Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.

version: 1.0.0+1
configurations:
  - name: &quot;Flutter&quot;
    request: &quot;launch&quot;
    type: &quot;dart&quot;
    program: &quot;lib/fill_detail.dart&quot;
    args: [&quot;--sound-null-safety&quot;]

environment:
  sdk: &#39;&gt;=2.19.5 &lt;3.0.0&#39;

dependencies:
  flutter:
    sdk: flutter
payu_checkoutpro_flutter: ^1.0.2
  payu_money_flutter: ^0.0.3

@override
  void initState() {
    super.initState();
    fetchCountries();
    fetchPlans();
    setupPayment();
  }
String txnToken = &quot;your_transaction_token&quot;;
  String orderId = &quot;your_order_id&quot;;
  double amount1 = 10.0;

  // Function for setting up the payment details
  PayuMoneyFlutter payuMoneyFlutter = PayuMoneyFlutter();
  setupPayment() async {
    bool response = await payuMoneyFlutter.setupPaymentKeys(
      merchantKey: &quot;nxpvv9VZ&quot;,
      merchantID: &quot;3oFxUMtWG2&quot;,
      isProduction: true,
      activityTitle: &quot;Payumoney&quot;,
      disableExitConfirmation: false,
    );

    print(&quot;response --&gt; $response&quot;);
  }

  void handlePaymentResponse(Map&lt;String, dynamic&gt; paymentResponse) {
    String responseCode = paymentResponse[&#39;responseCode&#39;];
    String status = paymentResponse[&#39;status&#39;];
    String message = paymentResponse[&#39;message&#39;];
    String transactionId = paymentResponse[&#39;transactionId&#39;];

    if (responseCode == &quot;01&quot; &amp;&amp; status == &quot;success&quot;) {
      // Payment successful
      print(&quot;Payment successful. Transaction ID: $transactionId&quot;);
    } else if (responseCode == &quot;141&quot; &amp;&amp; status == &quot;userCancelled&quot;) {
      // Payment cancelled by user
      print(&quot;Payment cancelled by user&quot;);
    } else {
      // Payment failed
      print(&quot;Payment failed. Response Code: $responseCode. Message: $message&quot;);
    }
  }

  @override
  void dispose() {
    super.dispose();
    setupPayment();
  }

I want permanently solve null sound safety error in this code.

答案1

得分: 0

你不能解决这个问题,因为这不是你的问题。你想要使用的软件包是一个已经有2年没有更新的预发布项目。

对于付款来说,使用一个不再维护的预发布项目是相当风险的。

你可以使用旧版本的Flutter,它可以接受那么老的软件包。或者你可以拿这个软件包,复制它并自己更新它以支持空安全。或者你可以使用一个实际上正在为Flutter维护软件包的支付提供商。

他们似乎有一个官方软件包,所以这可能是你前进的方式。

英文:

You cannot solve this problem, because it's not your problem. The package you want to use is a pre-release project that wasn't updated for 2 years now.

Using a pre-release project that isn't maintained anymore for payment is... risky at best.

You can either use an old version of Flutter that will accept packages that old. Or you can take that package, fork it and update it to null-safety yourself. Of you could use a payment provider, that is actually actively maintaining a package for Flutter.

They seem to have an official package, so that might be your way forward.

huangapple
  • 本文由 发表于 2023年5月10日 14:03:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215313.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定