我无法在 Flutter web 中集成 Razorpay 支付网关,你能帮我解决这个问题吗

I am not able to Razorpay payment getway intigretion in Flutter web, could you help me in this

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          body: Container(
            child: Column(
              children: [
                SizedBox(
                  height: 50,
                ),
                Image.network(
                  'https://images.unsplash.com/photo-1611186871348-b1ce696e52c9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8YXBwbGUlMjBsYXB0b3B8ZW58MHx8MHx8&w=1000&q=80',
                  height: 250,
                  width: 350,
                ),
                SizedBox(
                  height: 20,
                ),
                Text('macbook pro'),
                SizedBox(
                  height: 20,
                ),
                Text('description'),
                SizedBox(
                  height: 20,
                ),
                Text('rs200000'),
                SizedBox(
                  height: 20,
                ),
                ElevatedButton(onPressed: () {}, child: Text('buy now'))
              ],
            ),
          ),
        ));
  }
}

假设这是项目,那么当我们点击 buynow 按钮时,razorpay 弹出窗口应该会在网站中打开

**你们能帮帮我吗,因为我认为 razorpay 没有为 Flutter web 提供任何插件**

pubspec.yaml 文件中添加此包 razorpay_web: ^1.1.0

然后复制完整代码并粘贴到 main.dart 和 运行 中,然后就可以使用了..

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:razorpay_web/razorpay_web.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          body: Container(
            child: Column(
              children: [
                SizedBox(
                  height: 50,
                ),
                Image.network(
                  'https://images.unsplash.com/photo-1611186871348-b1ce696e52c9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8YXBwbGUlMjBsYXB0b3B8ZW58MHx8MHx8&w=1000&q=80',
                  height: 250,
                  width: 350,
                ),
                SizedBox(
                  height: 20,
                ),
                Text('macbook pro'),
                SizedBox(
                  height: 20,
                ),
                Text('description'),
                SizedBox(
                  height: 20,
                ),
                Text('rs200000'),
                SizedBox(
                  height: 20,
                ),
                Builder(
                  builder: (context) => Center(
                    child: RaisedButton(
                      color: Colors.blue,
                      child: Text("Buy Now"),
                      onPressed: () => Navigator.push(
                        context,
                        MaterialPageRoute(builder: (context) => Payments()),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}

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

  @override
  _PaymentsState createState() => _PaymentsState();
}

class _PaymentsState extends State<Payments> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: RazorpayWeb(
          rzpKey: "rzp_test_DNaSxot4oJHykG", // Enter Your Razorpay Key Here
          options: RzpOptions(
            amount: 1000,
            name: "Razorpay",
            description: "Test Payment",
            image: "https://i.imgur.com/3g7nmJC.png",
            prefill: const PrefillData(
              name: "Razorpay",
              email: "rzp@gmail.com",
              contact: "9876543210",
            ),
            colorhex: "#FF0000",
          ),
          onPaymentSuccess: (String paymentId) {
            print("Payment Success");
            log(paymentId);
          },
          onPaymentError: (String error) {
            print("Payment Error");
          },
        ),
      ),
    );
  }
}

如果付款成功,onPaymentSuccess 函数将包含来自 razorpay 的 payment_id。