You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a workaround is to extract the payment logic to a child component in JavaScript instead of a typescript component, as the issue is from incorrect typings from the package.
Parent Component named PaymentPage.tsx name an be called anything
Child Component named PaymentWithPaystack.js name can be called anything
import{usePaystackPayment}from'react-paystack';constPaymentWithPaystack=({amount=0, paymentResponse })=>{constconfig={reference: (newDate()).getTime().toString(),email: "user@example.com",amount: amount,publicKey: 'pk_test_.........',};// you can call this function anythingconsthandleSuccess=(ref)=>{// Implementation for whatever you want to do with reference and after success call.// console.log(ref);paymentResponse(ref)};// you can call this function anythingconstonClose=()=>{// implementation for whatever you want to do when the Paystack dialog closed.console.log('closed')}constPaystackHookExample=()=>{constinitializePayment=usePaystackPayment(config);return(<div><buttononClick={()=>{initializePayment(handleSuccess,onClose)}}>Paystack Hooks Implementation</button></div>);};return(<div><PaystackHookExample/></div>)}exportdefaultPaymentWithPaystack
Activity
somteacodes commentedon Sep 25, 2022
a workaround is to extract the payment logic to a child component in JavaScript instead of a typescript component, as the issue is from incorrect typings from the package.
Parent Component named PaymentPage.tsx
name an be called anythingChild Component named PaymentWithPaystack.js
name can be called anythingdhatGuy commentedon Oct 12, 2022
I think reference could be either number or string
reference: number | string;kduprey commentedon Dec 3, 2022
See PR #67