Shurjopay Payment Gateway Working in Emulator but not Working in build Apk in flutter

Here is my implemented code. I am trying to implement a payment gateway in Flutter. I used the Shurjopay plugin to do that. It is working in the Android emulator but when I am building the app and installing it on my device it is not working showing Payment unsuccessful. Can anyone help me to identify the problem?
here is the package link: https://pub.dev/packages/shurjopay

void main() {
      initializeShurjopay(environment: "sandbox");
      runApp(const MyApp());
    }  
    onPressed: () async {
                          ShurjoPay shurjoPay = ShurjoPay();
        
                          ShurjopayConfigs shurjopayConfigs = ShurjopayConfigs(
                            prefix: "sp",
                            userName: "sp_sandbox",
                            password: "pyyk97hu&6u6",
                            clientIP: "127.0.0.1",
                          );
        
                          ShurjopayResponseModel shurjopayResponseModel =
                              ShurjopayResponseModel();
                          ShurjopayVerificationModel shurjopayVerificationModel =
                              ShurjopayVerificationModel();
        
                          ShurjopayRequestModel shurjopayRequestModel =
                              ShurjopayRequestModel(
                            configs: shurjopayConfigs,
                            currency: "BDT",
                            amount: double.parse(amountFieldController.text),
                            orderID: "sp1ab2c3d7",
                            discountAmount: 0,
                            discountPercentage: 0,
                            customerName: nameFieldController.text,
                            customerPhoneNumber: "01711486915",
                            customerAddress: "customer address",
                            customerCity: "customer city",
                            customerPostcode: "1212",
                            // Live: https://www.engine.shurjopayment.com/return_url
                            returnURL:
                                "https://www.sandbox.shurjopayment.com/return_url",
                            // Live: https://www.engine.shurjopayment.com/cancel_url
                            cancelURL:
                                "https://www.sandbox.shurjopayment.com/cancel_url",
                          );
                          shurjopayResponseModel = await shurjoPay.makePayment(
                            context: context,
                            shurjopayRequestModel: shurjopayRequestModel,
                          );
                          if (shurjopayResponseModel.status == true) {
                            try {
                              shurjopayVerificationModel =
                                  await shurjoPay.verifyPayment(
                                orderID: shurjopayResponseModel.shurjopayOrderID!,
                              );
                              String? spMessage = shurjopayVerificationModel.spMessage;
                              ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                                content: Text(spMessage ?? ""),
                              ));
                              print(shurjopayVerificationModel.spCode);
                              print(shurjopayVerificationModel.spMessage);
                              if (shurjopayVerificationModel.spCode == "1000") {
                                // ignore: use_build_context_synchronously
                                ScaffoldMessenger.of(context).showSnackBar(
                                    const SnackBar(
                                        content: Text('Payment Successfull')));
                                // ignore: use_build_context_synchronously
                                Navigator.push(context, MaterialPageRoute(
                                  builder: (context) {
                                    return const MainScreen();
                                  },
                                ));
                              }
                            } catch (error) {
                              print(error.toString());
                              ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                                content: Text(error.toString()),
                              ));
                            }
                          } else {
                            ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
                              content: Text('Payment Failed'),
                            ));
                            //shurjopayResponseModel.status
                            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                              content: Text(shurjopayResponseModel.status.toString()),
                            ));
                          }
                          nameFieldController.clear();
                          amountFieldController.clear();
                          phoneFieldController.clear();
                        }

Leave a Comment