Skip to content

Issue while making payment to upi id in react native #63

@saurabhc-ecsion

Description

@saurabhc-ecsion

please correct me if I am wrong,

I am trying to integrate this library to make payment using upi in react native app, after integration it giving error
Error initiating payment: [TypeError: Cannot read property 'intializePayment' of null]

And also I am getting confused, is this also work from iOS device when user try to make payment from iOS devices.

please let me know, what to do next for payment integration

sharing you sample code (if you can fix):

import React from 'react';
import { View, Button, Alert } from 'react-native';
import UpiPayment from 'react-native-upi-payment';

const App = () => {
  const initiatePayment = async () => {
    try {
      if (UpiPayment) {
        const response = await UpiPayment.initializePayment(
          {
            vpa: 'saurabh.iosdevlpr@okhdfcbank',
            payeeName: 'Saurabh Chaudhari',
            amount: '1',
            transactionRef: 'Testing Transaction',
            transactionNote: 'Test payment',
          },
          (data) => {
            if (data && data.Status === 'SUCCESS') {
              Alert.alert('Payment Successful', 'Payment was successful.');
            } else {
              Alert.alert('Payment Failed', 'Payment was not successful.');
            }
          },
          (error) => {
            console.error('Error initiating payment:', error);
            Alert.alert('Payment Error', 'An error occurred while processing payment.');
          }
        );
      } else {
        Alert.alert('Payment Error', 'UPI Payment module is not available.');
      }
    } catch (error) {
      console.error('Error initiating payment:', error);
      Alert.alert('Payment Error', 'An error occurred while processing payment.');
    }
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Button title="Initiate Payment" onPress={initiatePayment} />
    </View>
  );
};

export default App;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions