react-coinbase-commerce icon indicating copy to clipboard operation
react-coinbase-commerce copied to clipboard

`onChargeSuccess` not firing callback

Open hexcowboy opened this issue 3 years ago • 5 comments

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`)
  }

hexcowboy avatar Oct 21 '21 00:10 hexcowboy

same problem

ksaitor avatar Dec 03 '21 16:12 ksaitor

Was this ever fixed? Getting the same issue.

kyritzb avatar May 06 '22 23:05 kyritzb

Same here, we have webhook integrated, but still need this event fired which will help better UX.

nidzovito avatar May 07 '22 01:05 nidzovito

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.

trevordboyer avatar Nov 05 '22 18:11 trevordboyer

Still not firing callbacks :(

michaelgpt avatar Feb 07 '23 23:02 michaelgpt