diff --git a/packages/embeds/embed-core/src/embed.test.ts b/packages/embeds/embed-core/src/embed.test.ts index 80d43b29d2..fd2a78484e 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.ts index 88e6e76789..d8056f3715 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.