From Electron's `main.ts`: ``` import { BrowserWindow, ipcMain } from 'electron'; ...typescript ipcMain.on( 'close-paypal', () => { BrowserWindow.getAllWindows().forEach((win) => { // The Paypal window would fail to load contents due to security // restrictions and return an empty URL if (!win.webContents.getURL()) { win.close(); } }); } ); ``` From your content script (I'm using TypeScript): ```typescript const { ipcRenderer } = require('electron'); ... paypal.Button.render({ ... payment: () => { ipcRenderer.send('close-paypal', ''); // Other logic to trigger payment flow } ... }); ```