> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-881012b3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Methods

> Check the payment methods available for the Flutter plugin.

<div style={{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.35rem 0.9rem",border:"1px solid rgba(128,128,128,0.28)",borderRadius:"0.5rem",padding:"0.45rem 0.75rem",margin:"0 0 1.25rem",fontSize:"0.875rem"}}>
  <span style={{fontWeight:600}}>Available in</span>
  <span>🇮🇳 India</span>
</div>

Documented below are the methods for the Flutter plugin.

## Interface Methods

### getPaymentMethods

Use this method for fetching the payment methods:

```javascript Get Payment Methods theme={null}
onPressed: () {
   final paymentMethods = await _razorpay.getPaymentMethods();
}
```

### getAppsWhichSupportUpi

Use this method for fetching those apps on the customer's phone which support UPI payments:

```javascript Get Apps which support UPI theme={null}
onPressed: () {
   final supportedUpiApps = _razorpay.getAppsWhichSupportUpi();
}
```

### getCardNetwork

Use this method to get the card network. This function expects the card number as a parameter and returns the card network. For example, VISA, Mastercard, RuPay and so on:

```javascript Get Card Network theme={null}
onPressed: () {
   final cardNetwork = _razorpay.getCardsNetwork("<card-number>");
}
```

### isValidCardNumber

Use this method to validate the card number. This function returns a boolean value that determines the card is valid or invalid:

```javascript Is Valid Card Number theme={null}
onPressed: () {
   final isValidCard = await _razorpay.isValidCardNumber('<card-number>');
}
```

### getBankLogoUrl

You must use bank code as the method parameter returned in the `getPaymentMethod()` to fetch the bank logo URL.

```javascript Get Bank Logo URL theme={null}
onPressed: () {
final bankLogoUrl = _razorpay.getBankLogoUrl("<bank-code>");
}
```

### changeApiKey

Use this method for changing the API keys:

```javascript Change API Key theme={null}
onPressed: () {
   _razorpay.changeApiKey(‘api-key’);
}
```

### getCardNetworkLength

Use this method for fetching the card network length:

```javascript Get Card Network Length theme={null}
onPressed: () {
   final length = await _razorpay.getCardNetworkLenght('VISA');
}
```

### getSubscriptionAmount

Use this method for fetching the subscription amount using the `subscription_id`:

```javascript Get Subscription Amount theme={null}
onPressed: () {
   final subAmount = await _razorpay.getSubscriptionAmount('sub_8tkmbhhROdiVSc');
}
```

### getWalletLogoUrl

Use this method for fetching the wallet logo URL:

```javascript Get Wallet Logo URL theme={null}
onPressed: () {
   final walletLogo = await _razorpay.getWalletLogoUrl('paytm');
}
```

### Submit

Use this method for submitting the payment details:

```javascript Submit Payment Details theme={null}
onPressed: () {
   var options = {
           'key': key,
           'amount': 100,
           'currency': 'INR',
           'email': '<email>',
           'contact': '<phone>',
           'method': 'netbanking',
           'bank': 'hdfc'
       };
   _razorpay.submit(options);
}
```

## Listening to Events

Events are triggered from the SDK for handling success or error on payments, Register for these events in the initState() method in their flutter apps as given below:

```javascript Listening to Events theme={null}
@override
void initState() {
  _razorpay = Razorpay();
  _razorpay.initilizeSDK(key);
  _razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
  _razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
}

void _handlePaymentSuccess(Map<dynamic, dynamic> response) {
  print('Payment Success Response : $response');
}

void _handlePaymentError(Map<dynamic, dynamic> response) {
  print('Payment Error Response : $response');
}
```

## Error Codes

The error codes have been exposed as integers by the `Razorpay` class. The error code is available as the code field of the `PaymentFailureResponse` instance passed to the callback.

| Error Code         | Description                                                            |
| ------------------ | ---------------------------------------------------------------------- |
| NETWORK\_ERROR     | There was a network error. For example, loss of internet connectivity. |
| INVALID\_OPTIONS   | An issue with options passed in `Razorpay.open`.                       |
| PAYMENT\_CANCELLED | User cancelled the payment.                                            |
| TLS\_ERROR         | Device does not support TLS v1.1 or TLS v1.2.                          |
| UNKNOWN\_ERROR     | An unknown error occurred.                                             |
