Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webview screen freezes loading gif while initiating payment #12

Open
aabhik-coder opened this issue Aug 7, 2024 · 0 comments
Open

Webview screen freezes loading gif while initiating payment #12

aabhik-coder opened this issue Aug 7, 2024 · 0 comments

Comments

@aabhik-coder
Copy link

Describe the bug
After initiating payment the webview launch then, the khalti loading start and stuck(freezes) .

To Reproduce
import 'dart:developer';

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

void main() {
runApp(
const MaterialApp(
home: KhaltiSDKDemo(),
),
);
}

class KhaltiSDKDemo extends StatefulWidget {
const KhaltiSDKDemo({super.key});

@OverRide
State createState() => _KhaltiSDKDemoState();
}

class _KhaltiSDKDemoState extends State {
late final Future<Khalti?> khalti;

String pidx =
'PIDX';

PaymentResult? paymentResult;

@OverRide
void initState() {
super.initState();
final payConfig = KhaltiPayConfig(
publicKey:
'testID"
pidx: pidx,
environment: Environment.test,
);

khalti = Khalti.init(
  enableDebugging: true,
  payConfig: payConfig,
  onPaymentResult: (paymentResult, khalti) {
    log(paymentResult.toString());
    setState(() {
      this.paymentResult = paymentResult;
    });
    khalti.close(context);
  },
  onMessage: (
    khalti, {
    description,
    statusCode,
    event,
    needsPaymentConfirmation,
  }) async {
    log(
      'Description: $description, Status Code: $statusCode, Event: $event, NeedsPaymentConfirmation: $needsPaymentConfirmation',
    );
    khalti.close(context);
  },
  onReturn: () => log('Successfully redirected to return_url.'),
);

}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: FutureBuilder(
future: khalti,
initialData: null,
builder: (context, snapshot) {
final khaltiSnapshot = snapshot.data;
if (khaltiSnapshot == null) {
return const CircularProgressIndicator.adaptive();
}
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 120),
const Text(
'Rs. 22',
style: TextStyle(fontSize: 25),
),
const Text('1 day fee'),
OutlinedButton(
onPressed: () => khaltiSnapshot.open(context),
child: const Text('Pay with Khalti'),
),
const SizedBox(height: 120),
paymentResult == null
? Text(
'pidx: $pidx',
style: const TextStyle(fontSize: 15),
)
: Column(
children: [
Text(
'pidx: ${paymentResult!.payload?.pidx}',
),
Text('Status: ${paymentResult!.payload?.status}'),
Text(
'Amount Paid: ${paymentResult!.payload?.totalAmount}',
),
Text(
'Transaction ID: ${paymentResult!.payload?.transactionId}',
),
],
),
const SizedBox(height: 120),
const Text(
'This is a demo application developed by some merchant.',
style: TextStyle(fontSize: 12),
)
],
);
},
),
),
);
}
}

Expected behavior
Initiate payment by launching webview and ask for khalti Id .

Device Information (please complete the following information):

  • Device: Android
  • API Level : 30

Screenshots
https://github.com/user-attachments/assets/574f9139-bb2c-4148-9f8f-eff1c767ae43

**Additional Context **
When i view call stack in vscode it's keep flashing 2-3 call back while the app is in webview .

@aabhik-coder aabhik-coder changed the title Payment Screen Freezes on loading screen on webview Webview screen freezes loading gif while initiating payment Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant