Scheduling infrastructure for absolutely everyone.
feat: add allow="payment" attribute to embed iframes for Apple Pay/Google Pay support (#22446)
Hariom Balharaee9699e2676f
diff --git a/packages/embeds/embed-core/src/embed.test.ts b/packages/embeds/embed-core/src/embed.test.tsindex 80d43b29d2c..fd2a78484ed 100644--- a/packages/embeds/embed-core/src/embed.test.ts+++ b/packages/embeds/embed-core/src/embed.test.ts@@ -258,6 +258,56 @@ describe("Cal", () => {expect(iframe.src).toContain("email=test%40example.com");});+ it("should set allow='payment' attribute by default to allow Payment Apps to acccept payments", () => {+ const iframe = calInstance.createIframe({+ calLink: "john-doe/meeting",+ config: {},+ calOrigin: null,+ });++ expect(iframe.getAttribute("allow")).toBe("payment");+ });++ it("should set allow='payment' even when no config is provided", () => {+ const iframe = calInstance.createIframe({+ calLink: "john-doe/meeting",+ calOrigin: null,+ });++ expect(iframe.getAttribute("allow")).toBe("payment");+ });++ it("should set allow='payment' when iframeAttrs is empty", () => {+ const iframe = calInstance.createIframe({+ calLink: "john-doe/meeting",+ config: { iframeAttrs: {} },+ calOrigin: null,+ });++ expect(iframe.getAttribute("allow")).toBe("payment");+ });++ it("should only apply id from iframeAttrs and ignore other attributes", () => {+ const iframe = calInstance.createIframe({+ calLink: "john-doe/meeting",+ config: {+ iframeAttrs: {+ id: "custom-id",+ "data-custom": "value",+ class: "custom-class",+ },+ },+ calOrigin: null,+ });++ expect(iframe.getAttribute("id")).toBe("custom-id");+ // Other attributes should not be applied+ expect(iframe.getAttribute("data-custom")).toBeNull();+ expect(iframe.getAttribute("class")).toBe("cal-embed");+ // Allow attribute should always be set+ expect(iframe.getAttribute("allow")).toBe("payment");+ });+it("should respect forwardQueryParams setting to disable sending page query params but still send the ones in the config", () => {mockSearchParams("?param1=value");diff --git a/packages/embeds/embed-core/src/embed.ts b/packages/embeds/embed-core/src/embed.tsindex 88e6e767894..d8056f37154 100644--- a/packages/embeds/embed-core/src/embed.ts+++ b/packages/embeds/embed-core/src/embed.ts@@ -334,6 +334,8 @@ export class Cal {iframe.setAttribute("id", iframeAttrs.id);}+ iframe.setAttribute("allow", "payment");+const searchParams = this.buildFilteredQueryParams(queryParamsFromConfig);// cal.com has rewrite issues on Safari that sometimes cause 404 for assets.