TypeError:Cannot read property 'makePayment' of undefined
Closed this issue · 46 comments
Hi,
Getting error on PayuMoney.pay() method. Please help
Am too getting this error, it automatically goes inside catch block and gives error
{Success:false}
facing the same issue will u please give some solution @Suraj-Tiwari .
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
@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
Thank you @Suraj-Tiwari now its working fine.
@rrakesh100 have you tried react-native link react-native-payumoney
after installing from npm?
@Suraj-Tiwari - Hi Suraj . Yes I did try
Please post the MainActivity.java code here
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);
}
}
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
- Returns the name of the main component registered from JavaScript.
- This is used to schedule rendering of the component.
*/
@OverRide
protected String getMainComponentName() {
return "XXXX";
}
}
have you seen this issue #3
resolved issue by adding
compile project(':react-native-payumoney')
in app/build.gradle
like this
and this
and also did you reinstall the app after linking? without reinstalling it wont work. react-native run-android
Reinstalled the app after linking?
i did ran react-native run-android...but to test in my emulator i am running react-native-scripts start. it doesnt work
No you have to reinstall for emulator too
react-native start
and react-native run-android
both are different things
I was using expo...so I generated APK to see. I still get the same issue
I was using expo...so I generated APK to see. I still get the same issue
Sorry this library isn't for expo this is a native module, expo doesn't support native module
Thanks @Suraj-Tiwari I ejected the app from expo and it works !! Do you plan to add support for iOS as well
@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.
But Hope i'll work on it in future
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
@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'.
AILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring project ':react-native-payumoney'.
Could not resolve all artifacts for configuration ':react-native-payumoney:classpath'.
Could not find com.android.tools.build:gradle:3.2.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
Required by:
project :react-native-payumoney
-
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. -
Get more help at https://help.gradle.org
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)
Hi Suraj,
My app getting crash while calling PayuMoney.pay(options).
Please help me on this.
Getting below error make release apk please help me on this.
Task :react-native-payumoney:verifyReleaseResources FAILED
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':react-native-payumoney:verifyReleaseResources'.
java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
/home/raj/AnsAppRevWithAPI/AnsAppWithAPI/node_modules/react-native-payumoney/android/build/intermediates/res/merged/release/values/values.xml:3537: error: duplicate value for resource 'attr/layout_anchorGravity' with config ''.
/home/raj/AnsAppRevWithAPI/AnsAppWithAPI/node_modules/react-native-payumoney/android/build/intermediates/res/merged/release/values/values.xml:3537: error: resource previously defined here.
-
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. -
Get more help at https://help.gradle.org
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
Hi Suraj,
While i'm trying to process payment getting some error occured.
Please suggest
can i use latest sdk which is com.payumoney.sdkui:plug-n-play:1.5.0'.
please suggest
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.
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.
@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
How to generate hash using node js express js
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)
}
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)
@cybermaskssoftware use latest release #38