just1and0 / React-Native-Paystack-WebView

💸💳The package allows you accept payment using paystack and guess what, it doesn't require linking! just install and begin to use 🚀
https://paystack.com
MIT License
156 stars 101 forks source link

Pay Now Button Component not displaying in Front End #78

Closed mosesegboh closed 3 years ago

mosesegboh commented 3 years ago

Hello, installed the library, but I cannot find the "Pay Now" button when I load the component on my app as displayed in the tutorial. Who can help. Is there anything extra I need to do? Regards.

just1and0 commented 3 years ago

Hello 👋🏾

pay now button was taken out of V4, I’d advice referring to the docs on the use of Ref to initiate payment with pay now button here

mosesegboh commented 3 years ago

Hello Tobi, Thanks for your prompt response. I had already tried using the second approach with useRef, However I get an error with the line of code displayed below: "const paystackWebViewRef = useRef();" Can't seem to figure out a way around it. any suggestions why that is? I have attached a screenshot of my code with the error message below: Kindly assist if you can. image

just1and0 commented 3 years ago

Hello what version are you using ?

mosesegboh commented 3 years ago

I am using "react-native-paystack-webview": "^4.0.3",

mosesegboh commented 3 years ago

I also get the error, "Paystack props is not defined" when I pass in "null as a parameter for the useRef code I highlighted above "as displayed in the image below; image

just1and0 commented 3 years ago

that's a wrong usage, you're not meant to set null with that ref. make sure your code look very similar to this

import React, {useRef} from 'react';
import type { Node } from 'react';
import {
  SafeAreaView, 
  Text, 
  TouchableOpacity
} from 'react-native';

import { Paystack, paystackProps } from 'react-native-paystack-webview'

const App: () => Node = () => {

  const paystackWebViewRef = useRef<paystackProps.PayStackRef>(); 

  console.log(paystackWebViewRef)

  return (
    <SafeAreaView>
      <Paystack
        paystackKey={'your-pk-here'}
        onCancel={() => { }}
        onSuccess={() => { }}
        billingEmail={'your-email-here'}
        billingName={'your-billing-name-here'}
        amount={'700.90'} 
        ref={paystackWebViewRef}
        // autoStart={true}
      />

      <TouchableOpacity onPress={() => paystackWebViewRef.current.startTransaction()}>
        <Text>Pay Now</Text>
      </TouchableOpacity>
    </SafeAreaView>
  );
};

export default App;
mosesegboh commented 3 years ago

Hello, Thanks for the response. I tried it as you have stated in the code, however, I am still getting the same error on that same line of code. I even went as far as disabling javascript validation in my vscode but the code won't compile due to that error. Below is a screenshot of my code with the error message image

just1and0 commented 3 years ago

I have tried to replicate this issue but it still works fine for me. Can we hop on a call this morning to see what the issue is, google meet.

Ps: I won’t be available anything after 12:00pm

mosesegboh commented 3 years ago

Hello Tobi, Kindly give me time and a link and will definitely be available

just1and0 commented 3 years ago

What’s your email ?

mosesegboh commented 3 years ago

mosesegboh@gmail.com

just1and0 commented 3 years ago

Just sent an invite, we can do 8:30

mosesegboh commented 3 years ago

ok noted

mosesegboh commented 3 years ago

Hi Tobi, I am in

mosesegboh commented 3 years ago

Hi Tobi, I have sent you an invite on github. Looking forward to hearing from you soon. Thanks once again. Regards.