Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Created February 24, 2024 12:09
Show Gist options
  • Save ponnamkarthik/539ab9325ced6be4a4fdd9a5a5550014 to your computer and use it in GitHub Desktop.
Save ponnamkarthik/539ab9325ced6be4a4fdd9a5a5550014 to your computer and use it in GitHub Desktop.
// Import Razory Pay Dependencies
import 'package:razorpay_flutter/razorpay_flutter.dart';
// Create a Razorpay instance
Razorpay razorpay = Razorpay();
@override
void initState() {
super.initState();
// Attach Listeners for Payment Events
razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, paymentSuccessHandler);
razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, paymentErrorHandler);
razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, externalWalletHandler);
}
void paymentSuccessHandler(PaymentSuccessResponse response) {
print('Payment Successful: ${response.paymentId}');
}
void paymentErrorHandler(PaymentFailureResponse response) {
print('Payment Error: ${response.code} - ${response.message}');
}
void externalWalletHandler(ExternalWalletResponse response) {
print('External Wallet: ${response.walletName}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment