adyen-web icon indicating copy to clipboard operation
adyen-web copied to clipboard

Fire event when additional action has loaded successfully

Open bitbytebit1 opened this issue 3 years ago • 3 comments

Describe the bug No event is fired when the Swish QR code is ready

To Reproduce On desktop Select Swish as a payment method Click pay A QR code is displayed

Expected behavior On desktop Select Swish as a payment method Click pay A QR code is displayed An event is fired indicating the QR code has loaded successfully

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Desktop

Additional context We would like to scroll the QR code into view, currently we are forced to wait arbitrary amount of time

bitbytebit1 avatar Apr 09 '21 08:04 bitbytebit1

Hi @bitbytebit1,

Thanks for reaching. This seems like an idea worth exploring. We will discuss internally and come back to you as soon as possible.

In the meantime, could you maybe tell us a bit more about an example use case where such event could be useful?

marcperez avatar Apr 13 '21 15:04 marcperez

Here is an example of how we are getting around this currently. If dropin.handleAction returned a promise that resolved once the QR code had finished booting up then we could simply perform any additional actions needed

onSubmit: (state, dropin) => {
  this.debug && console.log('ADYEN.onSubmit: ', state);
  if (this.ADYEN_DROPIN?.data?.paymentMethod?.type === 'applepay' && !this.ADYEN_DROPIN?.data?.paymentMethod?.applePayToken) {
    console.debug('Apple pay payment does not have token! Cancel onSubmit');
    return;
  }
  this.apiMakePayment(state.data)
    .then((response) => {
      if (response.action) {
        dropin.handleAction(response.action);
        if (response.action.paymentMethodType === 'swish' && response.action.type === 'qrCode') {
          // Here we are forced to wait an abitrary amount of time
          setTimeout(() => {
            this.elems.dropinContainer.scrollIntoView();
          }, 100);
        }
      } else {
        this.redirectToPaymentCompletePage(response);
      }
    })
}

bitbytebit1 avatar Apr 16 '21 11:04 bitbytebit1

Thanks for the example @bitbytebit1, that makes sense. We'll discuss internally and update this ticket as soon as possible.

marcperez avatar Apr 16 '21 11:04 marcperez

@bitbytebit1 - the next release of adyen-web will contain this PR: #1975 In keeping with our current policy of providing callbacks that you can add to the configuration for checkout we have added an onActionHandled callback (details in the PR)

sponglord avatar Feb 02 '23 14:02 sponglord