Skip to content

Commit ee9699e

Browse files
hariombalharadevin-ai-integration[bot]claude
authored
feat: add allow="payment" attribute to embed iframes for Apple Pay/Google Pay support (calcom#22446)
* feat: add allow="payment" attribute to embed iframes for Apple Pay support - Add default allow="payment" attribute to all embed iframes - Add test cases to verify payment attribute is set by default - Fixes Apple Pay functionality in Cal.com embeds Fixes calcom#19347 Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com> * test: add comprehensive tests for iframe attribute handling - Add test for when no config is provided - Add test for empty iframeAttrs object - Add test to verify all attributes are applied (not just id) - Ensure allow='payment' is set in all scenarios 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: restrict iframeAttrs to only allow id attribute - Changed implementation to only apply 'id' from iframeAttrs - Made allow='payment' non-configurable and always set - Updated tests to reflect new behavior - Keeps API surface low and avoids adding support for attributes unless explicitly required as a feature 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: remove duplicate test case - Removed duplicate test for no config scenario - Kept the more descriptive test case 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7813d37 commit ee9699e

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

packages/embeds/embed-core/src/embed.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,56 @@ describe("Cal", () => {
258258
expect(iframe.src).toContain("email=test%40example.com");
259259
});
260260

261+
it("should set allow='payment' attribute by default to allow Payment Apps to acccept payments", () => {
262+
const iframe = calInstance.createIframe({
263+
calLink: "john-doe/meeting",
264+
config: {},
265+
calOrigin: null,
266+
});
267+
268+
expect(iframe.getAttribute("allow")).toBe("payment");
269+
});
270+
271+
it("should set allow='payment' even when no config is provided", () => {
272+
const iframe = calInstance.createIframe({
273+
calLink: "john-doe/meeting",
274+
calOrigin: null,
275+
});
276+
277+
expect(iframe.getAttribute("allow")).toBe("payment");
278+
});
279+
280+
it("should set allow='payment' when iframeAttrs is empty", () => {
281+
const iframe = calInstance.createIframe({
282+
calLink: "john-doe/meeting",
283+
config: { iframeAttrs: {} },
284+
calOrigin: null,
285+
});
286+
287+
expect(iframe.getAttribute("allow")).toBe("payment");
288+
});
289+
290+
it("should only apply id from iframeAttrs and ignore other attributes", () => {
291+
const iframe = calInstance.createIframe({
292+
calLink: "john-doe/meeting",
293+
config: {
294+
iframeAttrs: {
295+
id: "custom-id",
296+
"data-custom": "value",
297+
class: "custom-class",
298+
},
299+
},
300+
calOrigin: null,
301+
});
302+
303+
expect(iframe.getAttribute("id")).toBe("custom-id");
304+
// Other attributes should not be applied
305+
expect(iframe.getAttribute("data-custom")).toBeNull();
306+
expect(iframe.getAttribute("class")).toBe("cal-embed");
307+
// Allow attribute should always be set
308+
expect(iframe.getAttribute("allow")).toBe("payment");
309+
});
310+
261311
it("should respect forwardQueryParams setting to disable sending page query params but still send the ones in the config", () => {
262312
mockSearchParams("?param1=value");
263313

packages/embeds/embed-core/src/embed.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ export class Cal {
334334
iframe.setAttribute("id", iframeAttrs.id);
335335
}
336336

337+
iframe.setAttribute("allow", "payment");
338+
337339
const searchParams = this.buildFilteredQueryParams(queryParamsFromConfig);
338340

339341
// cal.com has rewrite issues on Safari that sometimes cause 404 for assets.

0 commit comments

Comments
 (0)