react-paystack
react-paystack copied to clipboard
Im getting an error thats says: Uncaught TypeError: n.split is not a function
I'm new to using react-paystack, while practicing what was shown in the example, I always get this error in my console: Uncaught TypeError: n.split is not a function, and the payment was not successful.
This happened when I tried the three examples.
import React from "react";
import { PaystackConsumer } from "react-paystack";
const config = {
reference: new Date().getTime().toString(),
email: "[email protected]",
amount: 500 * 100,
publicKey: "pk_live_cf929a519a7eba12b9a87da11d8a76d790a1b884",
};
const reference = "Success";
const handleSuccess = (reference) => {
reference and after success call.
console.log(reference);
};
const handleClose = () => {
console.log("closed");
};
function App() {
const componentProps = {
...config,
text: "Paystack Button Implementation",
onSuccess: (reference) => handleSuccess(reference),
onClose: handleClose,
};
return (
<div className="App">
<PaystackConsumer {...componentProps}>
{({ initializePayment }) => (
<button onClick={() => initializePayment(handleSuccess, handleClose)}>
Paystack Consumer Implementation
</button>
)}
</PaystackConsumer>
</div>
);
}
export default App;