Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-17170] Added retry logic when mounting Stripe elements and extended timout to 50 ms #13142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/web/src/app/billing/services/stripe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,21 @@
* Re-mounts previously created Stripe credit card [elements]{@link https://docs.stripe.com/js/elements_object/create} into the HTML elements
* specified during the {@link loadStripe} call. This is useful for when those HTML elements are removed from the DOM by Angular.
*/
mountElements() {
mountElements(i: number = 0) {
setTimeout(() => {
if (!document.querySelector(this.elementIds.cardNumber) && i < 10) {
this.logService.warning("Stripe container missing, retrying...");
this.mountElements(i + 1);
return;

Check warning on line 77 in apps/web/src/app/billing/services/stripe.service.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/billing/services/stripe.service.ts#L75-L77

Added lines #L75 - L77 were not covered by tests
}

const cardNumber = this.elements.getElement("cardNumber");
const cardExpiry = this.elements.getElement("cardExpiry");
const cardCvc = this.elements.getElement("cardCvc");
cardNumber.mount(this.elementIds.cardNumber);
cardExpiry.mount(this.elementIds.cardExpiry);
cardCvc.mount(this.elementIds.cardCvc);
});
}, 50);
}

/**
Expand Down
Loading