Created
February 24, 2024 12:09
-
-
Save ponnamkarthik/539ab9325ced6be4a4fdd9a5a5550014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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