Skip to content

Instantly share code, notes, and snippets.

@jookyboi
Last active March 22, 2018 18:56
Show Gist options
  • Select an option

  • Save jookyboi/9c8ac23afbc3d23b33958007d19e388a to your computer and use it in GitHub Desktop.

Select an option

Save jookyboi/9c8ac23afbc3d23b33958007d19e388a to your computer and use it in GitHub Desktop.

Revisions

  1. jookyboi revised this gist Mar 22, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    From Electron's `main.ts`:
    ```
    import { BrowserWindow, ipcMain } from 'electron';
    ...typescript
    ...
    ipcMain.on(
    'close-paypal',
    () => {
    @@ -17,7 +17,7 @@ ipcMain.on(
    ```

    From your content script (I'm using TypeScript):
    ```typescript
    ```
    const { ipcRenderer } = require('electron');
    ...
    paypal.Button.render({
  2. jookyboi revised this gist Mar 22, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,6 @@ paypal.Button.render({
    ...
    payment: () => {
    ipcRenderer.send('close-paypal', '');

    // Other logic to trigger payment flow
    }
    ...
  3. jookyboi revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ paypal.Button.render({
    payment: () => {
    ipcRenderer.send('close-paypal', '');

    ...
    // Other logic to trigger payment flow
    }
    ...
    });
  4. jookyboi revised this gist Mar 22, 2018. 1 changed file with 2 additions and 9 deletions.
    11 changes: 2 additions & 9 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -23,17 +23,10 @@ const { ipcRenderer } = require('electron');
    paypal.Button.render({
    ...
    payment: () => {
    if (Util.isDesktop()) {
    electronUtil.closePaypalWindow();
    }
    ipcRenderer.send('close-paypal', '');

    // Note that this always creates a new payment method
    return paypalCheckoutInstance.createPayment({
    flow: 'vault'
    });
    ...
    }
    ...
    });

    ipcRenderer.send('close-paypal', '');
    ```
  5. jookyboi revised this gist Mar 22, 2018. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,20 @@ From your content script (I'm using TypeScript):
    ```typescript
    const { ipcRenderer } = require('electron');
    ...
    paypal.Button.render({
    ...
    payment: () => {
    if (Util.isDesktop()) {
    electronUtil.closePaypalWindow();
    }

    // Note that this always creates a new payment method
    return paypalCheckoutInstance.createPayment({
    flow: 'vault'
    });
    }
    ...
    });

    ipcRenderer.send('close-paypal', '');
    ```
  6. jookyboi revised this gist Mar 22, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    From Electron's `main.ts`:
    ```
    import { BrowserWindow, ipcMain } from 'electron';
    ...
    ...typescript
    ipcMain.on(
    'close-paypal',
    () => {
    @@ -17,7 +17,7 @@ ipcMain.on(
    ```

    From your content script (I'm using TypeScript):
    ```
    ```typescript
    const { ipcRenderer } = require('electron');
    ...
    ipcRenderer.send('close-paypal', '');
  7. jookyboi revised this gist Mar 22, 2018. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    import { BrowserWindow, app, ipcMain } from 'electron';

    From Electron's `main.ts`:
    ```
    import { BrowserWindow, ipcMain } from 'electron';
    ...
    ipcMain.on(
    'close-paypal',
    () => {
    @@ -16,7 +16,9 @@ ipcMain.on(
    );
    ```

    From your content script:
    From your content script (I'm using TypeScript):
    ```
    const { ipcRenderer } = require('electron');
    ...
    ipcRenderer.send('close-paypal', '');
    ```
  8. jookyboi revised this gist Mar 22, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@ 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
    // The Paypal window would fail to load contents due to security
    // restrictions and return an empty URL
    if (!win.webContents.getURL()) {
    win.close();
    }
  9. jookyboi revised this gist Mar 22, 2018. No changes.
  10. jookyboi revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,5 @@ ipcMain.on(

    From your content script:
    ```
    ipcRenderer.send(channel, data);
    ipcRenderer.send('close-paypal', '');
    ```
  11. jookyboi revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,5 @@ ipcMain.on(

    From your content script:
    ```
    ipcRenderer.send(channel, data);
    ```
  12. jookyboi revised this gist Mar 22, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,9 @@ ipcMain.on(
    });
    }
    );
    ```

    From your content script:
    ```
    ```
  13. jookyboi revised this gist Mar 22, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    From Electron's `main.js` or `main.ts`:
    import { BrowserWindow, app, ipcMain } from 'electron';

    From Electron's `main.ts`:
    ```
    ipcMain.on(
    'close-paypal',
  14. jookyboi revised this gist Mar 22, 2018. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,14 @@
    From Ele
    From Electron's `main.js` or `main.ts`:
    ```
    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();
    }
    });
    }
    );
    ```
  15. jookyboi revised this gist Mar 22, 2018. 1 changed file with 1 addition and 16 deletions.
    17 changes: 1 addition & 16 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -1,16 +1 @@
    From a clone of the `paylpal-checkout` repo (https://github.com/paypal/paypal-checkout):

    `src/lib/device.js`:
    ```
    function isElectron() : boolean {
    return window && window.process && window.process.type;
    }
    ...
    export function supportsPopups(ua? : string = getUserAgent()) : boolean {
    if (isElectron()) {
    return false;
    }
    return !(isIosWebview(ua) || isAndroidWebview(ua) || isOperaMini(ua) || isFirefoxIOS(ua) || isFacebookWebView(ua) || isQQBrowser(ua));
    }
    ```
    From Ele
  16. jookyboi revised this gist Mar 22, 2018. No changes.
  17. jookyboi revised this gist Mar 22, 2018. No changes.
  18. jookyboi revised this gist Mar 22, 2018. No changes.
  19. jookyboi revised this gist Mar 22, 2018. No changes.
  20. jookyboi revised this gist Mar 22, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -6,5 +6,11 @@ function isElectron() : boolean {
    return window && window.process && window.process.type;
    }
    ...
    export function supportsPopups(ua? : string = getUserAgent()) : boolean {
    if (isElectron()) {
    return false;
    }
    return !(isIosWebview(ua) || isAndroidWebview(ua) || isOperaMini(ua) || isFirefoxIOS(ua) || isFacebookWebView(ua) || isQQBrowser(ua));
    }
    ```
  21. jookyboi revised this gist Mar 22, 2018. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,9 @@ From a clone of the `paylpal-checkout` repo (https://github.com/paypal/paypal-ch

    `src/lib/device.js`:
    ```
    function isElectron() : boolean {
    return window && window.process && window.process.type;
    }
    ...
    ```
  22. jookyboi revised this gist Mar 22, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,5 @@
    From a clone of the `paylpal-checkout` repo (https://github.com/paypal/paypal-checkout):

    `src/lib/device.js`:
    ```
    ```
  23. jookyboi revised this gist Mar 22, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,2 @@
    From a clone of the `paylpal-checkout` repo (https://github.com/paypal/paypal-checkout), open
    From a clone of the `paylpal-checkout` repo (https://github.com/paypal/paypal-checkout):

  24. jookyboi revised this gist Mar 22, 2018. No changes.
  25. jookyboi revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    In the `paylpal-checkout` repo, open
    From a clone of the `paylpal-checkout` repo (https://github.com/paypal/paypal-checkout), open
  26. jookyboi revised this gist Mar 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix.md
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    In the `payl
    In the `paylpal-checkout` repo, open
  27. jookyboi created this gist Mar 22, 2018.
    1 change: 1 addition & 0 deletions fix.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    In the `payl