There seems to be a delay in between creating a card for a customer, and then getting the list of cards for the same customer.
In order to add a payment method to a customer, I am invoking the cardsApi.createCard function and inputting the customerId as a request parameter. The request is always successful when using the test card source_id ‘cnon:card-nonce-ok’ and returns all the required card information.
To notify my frontend that a card has been added successfully, I then invoke the cardsApi.listCards function with the same customerId to regenerate the list of customer cards (including the newly added card) and update relevant UI.
My issue is that when the listCards function is called directly after awaiting a response from the createCard function, the newly added card is not included - only the previously created cards are.
Is there any way to ensure the card has been added to the square customer before retrieving the list of customer cards? Or any means of returning a list of the customers cards from the createCard function?