Suraj-Tiwari / react-native-payumoney

React Native Payumoney (Android/IOS)
MIT License
18 stars 9 forks source link

Get an event when the user manually cancels the transaction by pressing the back button before entering the card details #42

Closed maheshshrigod closed 3 years ago

Moumit commented 4 years ago

Any reason closed the with out any comment or suggestion? Can you please reopen this one

girish54321 commented 4 years ago

Yep we need this :-)

Suraj-Tiwari commented 4 years ago

i'll try to push it by tomorrow

HarishJangra commented 4 years ago

Hey @Suraj-Tiwari did you find any solution to this problem? There is currently no way to get cancelled by user. Please help

codemonster91 commented 4 years ago

Payumoney(payData).then((data) => {

    console.log(data)
}).catch((e) => {
    console.log('error', e)
}) 

Always return 0

shrutiraoniit25 commented 3 years ago

I tried your example code @Suraj-Tiwari but even if I am getting data in the console its not setting payment status in payumoney and I not able to manually transact out from the payumoney

Suraj-Tiwari commented 3 years ago

It's a callback system, so if you're getting in console log payment screen has been closed. The only known issue is if User manually force closed the payment screen, it won't return any proper callback.

shrutiraoniit25 commented 3 years ago

so what do you suggest me to do return back

shrutiraoniit25 commented 3 years ago

This is my code here .... @Suraj-Tiwari

import React, {Fragment,useState,useEffect} from 'react'; import {SafeAreaView, Text,View, StyleSheet, TouchableOpacity} from 'react-native'; import CustomHeader from '../CustomHeader'; import PayuMoney from 'react-native-payumoney'; import AsyncStorage from '@react-native-community/async-storage'; import {Button } from 'react-native-paper'; import { useNavigation } from '@react-navigation/native'; import * as RootNavigation from '../RootNavigation';

const HashScreen = ({ navigation,route,props}) => { // const navigation = useNavigation(); const passing = 'passing'; const [username , setUsername] = useState(''); const [name ,setName] = useState(''); const [currentplan , setCurrentPlan] = useState(''); const [prvbalance , setPrvBalance] = useState(''); const [trigger , setTrigger] = useState(''); const [paymentStatus, setPaymentStatus] = useState('');

useEffect(() => {
    pay()
}, [])

  const pay = async () => {
    AsyncStorage.getItem(passing).then((value) =>{
        if(value !== null){

          }
        else{
            console.log('value is null')
        }

      }).done();
    setPaymentStatus('');
    const payData = {
        amount: '10.0',
        txnId: '12345678',
        productName: 'product_info',
        firstName: 'firstname',
        email: 'xyz@gmail.com',
        phone: '1234567890',
        merchantId: '789',
        key: 'qwert',
        successUrl: 'https://www.payumoney.com/success.php',
        failedUrl: 'https://www.payumoney.com/faliure.php',
        isDebug: false,
        hash:
            'my own hash',
       }
       PayuMoney(payData).then((data) => {
        // Payment Success
        setPaymentStatus('Success')
       // alert(data)
        console.log(data)
    }).catch((e) => {
        setPaymentStatus('Failed')
        // Payment Failed
        console.log(e)
    })

    popup(paymentStatus);

  }

const popup = (paymentStatus) => {
     if(paymentStatus === 'success'){
       navigation.pop();
   }
   else{
      navigation.pop();
  }

}

  return true;
    //   <View>
    //       <CustomHeader navigation={navigation} />
    //         <View>
    //             <Text>
    //                 You're payment had been failed please try again 
    //             </Text>
    //             <Text>Payment Status : {paymentStatus}</Text>
    //         </View>
    //   </View>
    // <Fragment>
    //     <View
    //         style={{
    //             flex: 1,
    //             alignItems: 'center',
    //             justifyContent: 'center',
    //             height: 200,
    //         }}
    //     >
    //         <Button
    //             onPress={() => pay()}
    //             title='Pay me :P'
    //         />
    //         <Text>{paymentStatus}</Text>
    //     </View>
    // </Fragment>

}

export default HashScreen;

Suraj-Tiwari commented 3 years ago

From release 1.0.2 (#55 ) you'll get status code along with errors, 1 = success -1 = gateway failure 0 = User cancelled

Suraj-Tiwari commented 3 years ago

@shrutiraoniit25 check the example again, doesn't faced any issue like this in my testing. still i've updated gateway sdk to latest version. If you're still facing email me at surajtiwari020@gmail.com