Suraj-Tiwari / react-native-payumoney

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

String Cannot be cast to Double #37

Closed cybermaskssoftware closed 4 years ago

cybermaskssoftware commented 4 years ago

when i push options into PayuMoney.pay go this error , please tell me how do i resolve this , i am stuck here, last two weeks , i try many of ways 1) convert amount into string 2) convert amount into amount.toFixed(2) nothing happen if i try as a string it shows "java.lang.String cannot be cast to java.lang.Double" if i use amount as amount.toFixed(2) "java.lang.Doubecannot be cast to java.lang.String" What i used here fro react native

let amount = 99.9; let txid = new Date().getTime()+""; let productId = "product101"; let name = "asdf"; let email = "hello@world.com"; let phone = "1231231231"; let surl = "https://www.example.com/payu-validate.php"; //can be diffrennt for Succes let furl = "https://www.example.com/payu-validate.php"; //can be diffrennt for Failed let id = this.state.PayU_MID; //Your Merchant ID here let key = this.state.PayU_Key; //Your Key Here let sandbox = true; //Make sure to set false on production or you will get error fetch('http://192.168.1.102/coreapi/payu-hash.php', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ key: key, txnid: txid, amount: amount.toString(), productinfo: productId, firstname: name, email: email, phone: this.state.phone }), }) .then((response) => response.text()) .then((hash) => { let options = ''; let hashs = JSON.parse(hash); try { options = { amount: amount.toString(), txid: txid, productId: productId, name: name, email: email, phone: phone, id: id.toString(), key: key, surl: surl, furl: furl, sandbox: sandbox, hash: hashs.hash };

                    console.log(options);
                    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 (e) {
                    console.log(e);
                }
            })

please check above code , hope your replay as soon as possible

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)