Suraj-Tiwari / react-native-payumoney

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

TypeError:Cannot read property 'makePayment' of undefined #2

Closed krunalFlexiLoans closed 6 years ago

krunalFlexiLoans commented 6 years ago

Hi,

Getting error on PayuMoney.pay() method. Please help

i-suraj commented 6 years ago

Am too getting this error, it automatically goes inside catch block and gives error

{Success:false}

DV31 commented 6 years ago

facing the same issue will u please give some solution @Suraj-Tiwari .

Suraj-Tiwari commented 6 years ago

Make sure to check your hash.

data = {
            amount: (Double),
            txid: (String),
            productId: (String),
            name: (String),
            email: (String)
            phone: (String) (Wrong mobile number will cause error.),
            id: (String),
            key: (String),
            surl: (String),
            furl: (String),
            sandbox: (Boolean),
            hash: (String)
        }

and this data too, check logs for transferred value or post log while making payment issue

Suraj-Tiwari commented 6 years ago

@DV31 @suraj-epsumlabs @krunalFlexiLoans I did a small workaround and i faced this issue when i tried to use package without running

react-native link react-native-payumoney

after that everything worked fine

try this code after linking

let options = {
    amount: 10.0,
    txid: "123123123" ,
    productId: "test",
    name: "Name",
    email: "test@gmail.com",
    phone: "8826343434",
    id: "393463",
    key: "LLKwG0",
    surl: "https://www.payumoney.com/mobileapp/payumoney/success.php",
    furl: "https://www.payumoney.com/mobileapp/payumoney/failure.php",
    sandbox: true,
    hash: "d829abecdaf9f2835787b3f56d1c7565721ca2501e6414438e61948dab435f102fc93213008cdfa3474691cadcc2dabdde64cd58c128dd2afcf3b389d617919c"
};
PayuMoney.pay(options).then((d) => {
    console.log(d); // WIll get a Success response with verification hash
}).catch(e => {
    console.log(e); //In case of failture
});

PHP code

<?php
echo makeHash("LLKwG0","123123123","10.0","test","Name","test@gmail.com");

function makeHash($key, $txnid, $amount, $productinfo, $firstname, $email){
    $salt = "qauKbEAJ";
    $payhash_str = $key . '|' . checkNull($txnid) . '|' . checkNull($amount) . '|' . checkNull($productinfo) . '|' . checkNull($firstname) . '|' . checkNull($email) . '|||||||||||' . $salt;
    $hash = strtolower(hash('sha512', $payhash_str));
    return $hash;
}

function checkNull($value)
{
    if ($value == null) {
        return '';
    } else {
        return $value;
    }
}

?>

Confirm If issue is resolved

DV31 commented 6 years ago

Thank you @Suraj-Tiwari now its working fine.

rrakesh100 commented 6 years ago
screen shot 2018-08-12 at 11 58 46 pm screen shot 2018-08-12 at 11 59 10 pm

Facing the same issue. Uploaded my source code and the output. Pls help

rrakesh100 commented 6 years ago
screen shot 2018-08-13 at 12 31 27 am
Suraj-Tiwari commented 6 years ago

@rrakesh100 have you tried react-native link react-native-payumoney after installing from npm?

rrakesh100 commented 6 years ago

@Suraj-Tiwari - Hi Suraj . Yes I did try

Suraj-Tiwari commented 6 years ago

Please post the MainActivity.java code here

rrakesh100 commented 6 years ago

import android.app.Application;

import com.facebook.react.ReactApplication; import superinfotech.suraj.reactnativepayumoney.PayumoneyPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader;

import java.util.Arrays; import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; }

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new PayumoneyPackage()
  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }

@Override public void onCreate() { super.onCreate(); SoLoader.init(this, / native exopackage / false); } }

rrakesh100 commented 6 years ago

import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {

/**

Suraj-Tiwari commented 6 years ago

have you seen this issue https://github.com/Suraj-Tiwari/react-native-payumoney/issues/3

Suraj-Tiwari commented 6 years ago
resolved issue by adding
compile project(':react-native-payumoney')
in app/build.gradle
Suraj-Tiwari commented 6 years ago

https://github.com/Suraj-Tiwari/react-native-payumoney/blob/d905ca5695321140470e015df7e802efc9b49319/example/android/app/build.gradle#L140

like this

and this https://github.com/Suraj-Tiwari/react-native-payumoney/blob/d905ca5695321140470e015df7e802efc9b49319/example/android/settings.gradle#L2

and also did you reinstall the app after linking? without reinstalling it wont work. react-native run-android

rrakesh100 commented 6 years ago
screen shot 2018-08-13 at 9 54 07 pm
rrakesh100 commented 6 years ago
screen shot 2018-08-13 at 9 46 42 pm
Suraj-Tiwari commented 6 years ago

Reinstalled the app after linking?

rrakesh100 commented 6 years ago

i did ran react-native run-android...but to test in my emulator i am running react-native-scripts start. it doesnt work

Suraj-Tiwari commented 6 years ago

No you have to reinstall for emulator too react-native start and react-native run-android both are different things

rrakesh100 commented 6 years ago

I was using expo...so I generated APK to see. I still get the same issue

rrakesh100 commented 6 years ago

I was using expo...so I generated APK to see. I still get the same issue

Suraj-Tiwari commented 6 years ago

Sorry this library isn't for expo this is a native module, expo doesn't support native module

rrakesh100 commented 6 years ago

Thanks @Suraj-Tiwari I ejected the app from expo and it works !! Do you plan to add support for iOS as well

Suraj-Tiwari commented 6 years ago

@rrakesh100 I'm currently working on this React-native-ads-facebook as there is no librrary that exist for facebook ads (old one doesn't follow facebook guidelines even fb ads sdk provided by expo doesn't follow complete guidelines). So i'm working on it as for now.

Suraj-Tiwari commented 6 years ago

But Hope i'll work on it in future

rrakesh100 commented 6 years ago

Hi Suraj,

Just wanted to check if you will support on iOS too to make this project complete. Unfortunately I am new to native app development so cannot contribute, else I would have loved to contribute.

Thank you

mkssankar1 commented 5 years ago

@Suraj-Tiwari I try to install react-native-payumoney package, but not get successful. Build returns below error always. Please give suggestion for this. org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

esoftel commented 5 years ago

AILURE: Build failed with an exception.

BUILD FAILED in 5s Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html

Command failed: ./gradlew installDebug

Error: Command failed: ./gradlew installDebug at checkExecSyncError (child_process.js:601:13) at Object.execFileSync (child_process.js:621:13) at runOnAllDevices (/home/raj/AnsAppRevWithAPI/AnsAppWithAPI/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19) at buildAndRun (/home/raj/AnsAppRevWithAPI/AnsAppWithAPI/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12) at isPackagerRunning.then.result (/home/raj/AnsAppRevWithAPI/AnsAppWithAPI/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12) at at process._tickCallback (internal/process/next_tick.js:188:7)

Suraj-Tiwari commented 5 years ago

Match gradle version with your app gradle version. That will resolve the issue.

esoftel commented 5 years ago

Hi Suraj,

My app getting crash while calling PayuMoney.pay(options). Please help me on this.

esoftel commented 5 years ago

Getting below error make release apk please help me on this.

Task :react-native-payumoney:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 30s 122 actionable tasks: 22 executed, 100 up-to-date

esoftel commented 5 years ago

Hi Suraj,

While i'm trying to process payment getting some error occured. Please suggest

Suraj-Tiwari commented 5 years ago

Issue seems to be related to gradle in production build, payment failed could be occurring due to hash, or invalid params. keep a look on amount that cause trouble during hash calculation

esoftel commented 5 years ago

This payumoney packge gradle classpath 'com.android.tools.build:gradle:1.3.1' and my app gradle classpath 'com.android.tools.build:gradle:3.3.1'

On Tue, 16 Apr 2019 at 22:05, Suraj Tiwari notifications@github.com wrote:

Issue seems to be related to gradle in production build, payment failed could be occurring due to hash, or invalid params. keep a look on amount that cause trouble during hash calculation

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Suraj-Tiwari/react-native-payumoney/issues/2#issuecomment-483737297, or mute the thread https://github.com/notifications/unsubscribe-auth/At7FVNJsTVRm2xua9LP0PxIXnLg6ABp-ks5vhfvdgaJpZM4VQQbd .

esoftel commented 5 years ago

This is my code

async payment(){ let auth = await AsyncStorage.getItem('Auth'); let parsedAuth = JSON.parse(auth); let amount = 1; let txid = new Date().getTime()+""; let productId = "product101"; let name = "Manju"; let email = "manjuv4477@gmail.com"; let phone = "9643057375"; let surl = "https://www.payumoney.com/mobileapp/payumoney/success.php"; //can be diffrennt for Succes let furl = "https://www.payumoney.com/mobileapp/payumoney/failure.php"; //can be diffrennt for Failed let id = "XXXXX"; //Your Merchant ID here let key = "XXXXX"; //Your Key Here let sandbox = false; //Make sure to set false on production or you will get error fetch('http://api.ansfashionhub.in/payment/generateHash/', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization':parsedAuth.token, }, body: JSON.stringify({ amount: 1, productInfo: productId, firstName: name, email: email }), }) .then((response) => {return response.json()}) .then((hash) => { let options = { amount: amount, txid: hash.txnID, productId: productId, name: name, email: email, phone: phone, id: hash.marchantID, key: hash.key, surl: surl, furl: furl, sandbox: sandbox, hash: hash.hash_key }; PayuMoney.pay(options).then((d) => { alert(d) console.log(d); return d.json() }) .then((r)=>{ alert(r) }) .catch(e => { console.log(e) }); }).catch(e => { alert(e) });

}

On Tue, 16 Apr 2019 at 22:20, Ace Engineers esoftel.com@gmail.com wrote:

This payumoney packge gradle classpath 'com.android.tools.build:gradle:1.3.1' and my app gradle classpath 'com.android.tools.build:gradle:3.3.1'

On Tue, 16 Apr 2019 at 22:05, Suraj Tiwari notifications@github.com wrote:

Issue seems to be related to gradle in production build, payment failed could be occurring due to hash, or invalid params. keep a look on amount that cause trouble during hash calculation

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Suraj-Tiwari/react-native-payumoney/issues/2#issuecomment-483737297, or mute the thread https://github.com/notifications/unsubscribe-auth/At7FVNJsTVRm2xua9LP0PxIXnLg6ABp-ks5vhfvdgaJpZM4VQQbd .

esoftel commented 5 years ago

Payu sdk which is using in your npm package

com.payumoney.sdkui:plug-n-play:1.0.0'

On Tue, 16 Apr 2019 at 22:21, Ace Engineers esoftel.com@gmail.com wrote:

This is my code

async payment(){ let auth = await AsyncStorage.getItem('Auth'); let parsedAuth = JSON.parse(auth); let amount = 1; let txid = new Date().getTime()+""; let productId = "product101"; let name = "Manju"; let email = "manjuv4477@gmail.com"; let phone = "9643057375"; let surl = "https://www.payumoney.com/mobileapp/payumoney/success.php"; //can be diffrennt for Succes let furl = "https://www.payumoney.com/mobileapp/payumoney/failure.php"; //can be diffrennt for Failed let id = "XXXXX"; //Your Merchant ID here let key = "XXXXX"; //Your Key Here let sandbox = false; //Make sure to set false on production or you will get error fetch('http://api.ansfashionhub.in/payment/generateHash/', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization':parsedAuth.token, }, body: JSON.stringify({ amount: 1, productInfo: productId, firstName: name, email: email }), }) .then((response) => {return response.json()}) .then((hash) => { let options = { amount: amount, txid: hash.txnID, productId: productId, name: name, email: email, phone: phone, id: hash.marchantID, key: hash.key, surl: surl, furl: furl, sandbox: sandbox, hash: hash.hash_key }; PayuMoney.pay(options).then((d) => { alert(d) console.log(d); return d.json() }) .then((r)=>{ alert(r) }) .catch(e => { console.log(e) }); }).catch(e => { alert(e) });

}

On Tue, 16 Apr 2019 at 22:20, Ace Engineers esoftel.com@gmail.com wrote:

This payumoney packge gradle classpath 'com.android.tools.build:gradle:1.3.1' and my app gradle classpath 'com.android.tools.build:gradle:3.3.1'

On Tue, 16 Apr 2019 at 22:05, Suraj Tiwari notifications@github.com wrote:

Issue seems to be related to gradle in production build, payment failed could be occurring due to hash, or invalid params. keep a look on amount that cause trouble during hash calculation

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Suraj-Tiwari/react-native-payumoney/issues/2#issuecomment-483737297, or mute the thread https://github.com/notifications/unsubscribe-auth/At7FVNJsTVRm2xua9LP0PxIXnLg6ABp-ks5vhfvdgaJpZM4VQQbd .

Suraj-Tiwari commented 5 years ago

they might have updated the sdk version,

rajnikantv94 commented 5 years ago

can i use latest sdk which is com.payumoney.sdkui:plug-n-play:1.5.0'. please suggest

rajnikantv94 commented 5 years ago

Hi Suraj,

Getting below error while using payu plug and play 1.5.0

Execution failed for task ':app:processDebugResources'.

Android resource linking failed /home/pytech/.gradle/caches/transforms-1/files-1.1/plug-n-play-1.5.0.aar/adcf9b8a0d486522a6f5ff76ce3538a4/res/layout/fragment_validate_wallet.xml:8: AAPT: error: resource string/verified_by_visa_image (aka com.ansapp:string/verified_by_visa_image) not found.

/home/pytech/.gradle/caches/transforms-1/files-1.1/plug-n-play-1.5.0.aar/adcf9b8a0d486522a6f5ff76ce3538a4/res/layout/fragment_validate_wallet.xml:73: AAPT: error: resource string/enter_the_otp_password (aka com.ansapp:string/enter_the_otp_password) not found.

/home/pytech/.gradle/caches/transforms-1/files-1.1/plug-n-play-1.5.0.aar/adcf9b8a0d486522a6f5ff76ce3538a4/res/layout/fragment_validate_wallet.xml:89: AAPT: error: resource string/otp_is_send_to_mobile_number (aka com.ansapp:string/otp_is_send_to_mobile_number) not found.

/home/pytech/.gradle/caches/transforms-1/files-1.1/plug-n-play-1.5.0.aar/adcf9b8a0d486522a6f5ff76ce3538a4/res/layout/fragment_validate_wallet.xml:103: AAPT: error: resource string/resend_otp (aka com.ansapp:string/resend_otp) not found.

error: failed linking file resources.

14012920 commented 5 years ago

Hello Suraj,

I am using react-native-payumoney in My app It is getting crash while calling PayuMoney.pay(options). Please help me on this.

srichallamalla935 commented 5 years ago

@DV31 @suraj-epsumlabs @krunalFlexiLoans I did a small workaround and i faced this issue when i tried to use package without running

react-native link react-native-payumoney

after that everything worked fine

try this code after linking

let options = {
    amount: 10.0,
    txid: "123123123" ,
    productId: "test",
    name: "Name",
    email: "test@gmail.com",
    phone: "8826343434",
    id: "393463",
    key: "LLKwG0",
    surl: "https://www.payumoney.com/mobileapp/payumoney/success.php",
    furl: "https://www.payumoney.com/mobileapp/payumoney/failure.php",
    sandbox: true,
    hash: "d829abecdaf9f2835787b3f56d1c7565721ca2501e6414438e61948dab435f102fc93213008cdfa3474691cadcc2dabdde64cd58c128dd2afcf3b389d617919c"
};
PayuMoney.pay(options).then((d) => {
    console.log(d); // WIll get a Success response with verification hash
}).catch(e => {
    console.log(e); //In case of failture
});

PHP code

<?php
echo makeHash("LLKwG0","123123123","10.0","test","Name","test@gmail.com");

function makeHash($key, $txnid, $amount, $productinfo, $firstname, $email){
    $salt = "qauKbEAJ";
    $payhash_str = $key . '|' . checkNull($txnid) . '|' . checkNull($amount) . '|' . checkNull($productinfo) . '|' . checkNull($firstname) . '|' . checkNull($email) . '|||||||||||' . $salt;
    $hash = strtolower(hash('sha512', $payhash_str));
    return $hash;
}

function checkNull($value)
{
    if ($value == null) {
        return '';
    } else {
        return $value;
    }
}

?>

Confirm If issue is resolved

It is working fine. But this is not working when changing the amount

Lakshmi-Narasimha commented 4 years ago

How to generate hash using node js express js

cybermaskssoftware commented 4 years ago

how i pass Rs:10 into double in react native because if i pass "10.0" || 10.0 ||10.00 got an error , the error is java.lang.Double cannot be cast to java.lang.String, how do i resolve this issue

And This is my code try { this.setState({amount : 300}); let myHeaders = new Headers(); myHeaders.append();

        let urlencoded = JSON.stringify({
            "txnid": new Date().getTime(),
            "amount": amount,
            "productinfo": "Consulting",
            "firstname": this.state.name,
            "email": this.state.email,
            "phone": this.state.phone
        });

        console.log("---------urlencoded--------", urlencoded);
        fetch("http://192.168.1.102/coreapi/payu-hash.php", {
            method: 'POST',
            headers: {"Content-Type": "application/x-www-form-urlencoded"},
            body: urlencoded,
        })
            .then(response => response.text())
            .then(result => {
                console.log("---------hash--------", result);
                let convertData = JSON.parse(result);
                //  console.log("---------convertData--------", convertData.hash);
                /** let options = {
                    amount: this.state.amount.toFixed(2),
                    txid: new Date().getTime(),
                    productId: "Consulting",
                    name: this.state.name,
                    email: this.state.email,
                    phone: this.state.phone,
                    id: this.state.PayU_MID,
                    key: this.state.PayU_Key,
                    surl: "https://www.payumoney.com/mobileapp/payumoney/success.php",
                    furl: "https://www.payumoney.com/mobileapp/payumoney/failure.php",
                    sandbox: true,
                    hash: convertData.hash
                };*/
                let options = {
                    amount: 10.0,
                    txid: "123123123" ,
                    productId: "test",
                    name: "Name",
                    email: "test@gmail.com",
                    phone: "8826343434",
                    id: "393463",
                    key: "LLKwG0",
                    surl: "https://www.payumoney.com/mobileapp/payumoney/success.php",
                    furl: "https://www.payumoney.com/mobileapp/payumoney/failure.php",
                    sandbox: true,
                    hash:  convertData.hash
                };
                PayuMoney.pay(options).then((d) => {
                    console.log(d); // WIll get a Success response with verification hash
                }).catch(e => {
                    console.log(e); //In case of failture
                });
            })
            .catch(error => console.log('error-------', error));
    }catch (e) {
        console.log('error---try----', e)
    }
cybermaskssoftware commented 4 years ago

java.lang.NoSuchMethodError: No virtual method setAmount(D)Lcom/payumoney/core/PayUmoneySdkInitializer$PaymentParam$Builder; in class Lcom/payumoney/core/PayUmoneySdkInitializer$PaymentParam$Builder; or its super classes (declaration of 'com.payumoney.core.PayUmoneySdkInitializer$PaymentParam$Builder' appears in /data/app/com.paymenttest-2/base.apk:classes2.dex) at superinfotech.suraj.reactnativepayumoney.PayActivity.makePayment(PayActivity.java:73)

Suraj-Tiwari commented 4 years ago

@cybermaskssoftware use latest release #38