react-coinbase-commerce
react-coinbase-commerce copied to clipboard
`onChargeSuccess` not firing callback
After a crypto payment is successful and the Continue
button is pressed, the callback function is not firing. We just started noticing this issue a few days ago.
<CoinbaseCommerceButton
chargeId={coinbaseChargeId}
styled={true}
onChargeSuccess={onChargeSuccess}
onChargeFailure={onChargeFailure}
/>
const onChargeSuccess = () => {
// not firing
console.log('on success')
history.push(`/wallet?deposit_success=true`)
}
same problem
Was this ever fixed? Getting the same issue.
Same here, we have webhook integrated, but still need this event fired which will help better UX.
Not the best solution but until it gets fixed here I was able to intercept the charge_confirmed
event using the following:
const handleCoinbaseMessage = (message) => {
if (message.data && message.data.buttonId && message.data.event === 'charge_confirmed') {
// Do whatever you need to here
}
};
useEffect(() => {
window.addEventListener('message', handleCoinbaseMessage);
return () => window.removeEventListener('message', handleCoinbaseMessage);
}, []);
You may want to keep track of the buttonId
to ensure they match and also check message.origin
similar to the isValidMessage(...)
function in iFrame.js
of this library.
Still not firing callbacks :(