integrate Paylike into react
vtsiris opened this issue · 0 comments
Hi everyone,
I am trying to integrate paylike into React and it seems that I am unable to to do it properly.
What I have done so far is to import the paylike script into my index.html file
<script src="https://sdk.paylike.io/10.js"></script>
and then, show the popup, when the users clicks the pay button.
` const pay = useCallback(() => {
const script = document.createElement('script');
script.text = `Paylike({key: 'a-random-key'})
paylike.pay(
{
test: true,
amount: {currency: 'DKK', exponent: 2, value: ${transaction.Amount}},
custom: {orderId: ${transaction.Number}, orderUID:'${transaction.UID}'},
},
(err, result) => {
if (err) return console.log(err)
console.log('result: ', result)
}
)`;
document.body.appendChild(script);
}, [transaction.Amount, transactionInformation.Number, transactionInformation.UID]); `
However the problem with this implementation is that multiple popups are being rendered and I am not able to handle the state/actions of the popup.
Is there any chance to create the Paylike object/popup outside the script?
Thanks in advance.
Vagelis