Skip to content

feat: added web redirect#2087

Open
RohitKushvaha01 wants to merge 10 commits intoAcode-Foundation:ajit/fix-fetch-auth-configfrom
RohitKushvaha01:ajit/fix-fetch-auth-config
Open

feat: added web redirect#2087
RohitKushvaha01 wants to merge 10 commits intoAcode-Foundation:ajit/fix-fetch-auth-configfrom
RohitKushvaha01:ajit/fix-fetch-auth-config

Conversation

@RohitKushvaha01
Copy link
Copy Markdown
Member

@RohitKushvaha01 RohitKushvaha01 commented May 6, 2026

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[config.js loaded] --> B[IAP_AVAILABLE = true]
    B --> C[system.getInstaller called]
    C --> D{Callback result}
    D -- success --> E{installer == com.android.vending AND typeof iap != undefined?}
    E -- Yes --> F[IAP_AVAILABLE = true]
    E -- No --> G[IAP_AVAILABLE = false]
    D -- error --> H[IAP_AVAILABLE = true]
    F --> I[User taps Buy]
    G --> I
    H --> I
    I --> J{config.IAP_AVAILABLE?}
    J -- Yes --> K[Native IAP flow: iap.getProducts]
    J -- No --> L[auth.getLoggedInUser]
    L --> M{User logged in?}
    M -- No --> N[Open login page in CustomTabs]
    M -- Yes --> O[Open plugin purchase page in CustomTabs]

Loading

@RohitKushvaha01 RohitKushvaha01 marked this pull request as draft May 6, 2026 13:50
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR adds a web-redirect fallback for paid plugin purchases on non-Play-Store builds: when config.IAP_AVAILABLE is false, users are sent to the website to log in and purchase instead of hitting the native IAP flow. It also replaces the previous synchronous typeof iap check with an async system.getInstaller call to more reliably detect the installation source.

  • config.js: IAP_AVAILABLE now defaults to true and is corrected via system.getInstaller; the success callback correctly guards with typeof iap !== \"undefined\" && installer === \"com.android.vending\", but the error callback sets it to true unconditionally.
  • plugin.view.js / extensions/index.js: New openPluginWebsite helper checks login state via auth.getLoggedInUser(), then opens a CustomTabs session to either the login or plugin-purchase page.
  • System.java / plugin.js: New native getInstaller action exposed via the Cordova bridge using getInstallSourceInfo (API 30+) with a getInstallerPackageName fallback.

Confidence Score: 4/5

The web-redirect logic is sound, but the error branch in the installer callback can leave a non-IAP build in a broken state.

The getInstaller error callback always writes true to IAP_AVAILABLE without checking typeof iap. On a sideloaded build where iap is undefined, a native exception from PackageManager would permanently route users into the IAP code path, crashing on iap.getProducts. The fix is a one-liner; everything else in the PR looks correct.

src/lib/config.js — specifically the error callback of system.getInstaller

Important Files Changed

Filename Overview
src/lib/config.js Replaces synchronous typeof iap check with an async system.getInstaller callback; error branch unconditionally sets IAP_AVAILABLE = true even when iap is undefined, crashing the install flow on non-IAP builds that hit a native error.
src/pages/plugin/plugin.view.js Adds openPluginWebsite function and a new IAP-unavailable branch in Buttons that redirects unpurchased paid plugins to the web; id is correctly spread from parent props.
src/sidebarApps/extensions/index.js Adds web-redirect branch when IAP is unavailable and plugin is unowned; gates the existing IAP product lookup on config.IAP_AVAILABLE, preventing iap calls on non-IAP builds for the owned case.
src/plugins/system/android/com/foxdebug/system/System.java Adds getInstaller action using getInstallSourceInfo (API 30+) with getInstallerPackageName fallback; null result is safely passed to JS and handled by the callback.
src/plugins/system/www/plugin.js Exposes getInstaller as a new JS bridge method; straightforward cordova.exec wrapper.
src/pages/plugin/plugin.js Imports auth; no functional logic changes beyond existing buy() guard noted in prior threads.
package.json Reorders plugin declarations; no functional change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[config.js loaded] --> B[IAP_AVAILABLE = true]
    B --> C[system.getInstaller called]
    C --> D{Callback result}
    D -- success --> E{installer == com.android.vending AND typeof iap != undefined?}
    E -- Yes --> F[IAP_AVAILABLE = true]
    E -- No --> G[IAP_AVAILABLE = false]
    D -- error --> H[IAP_AVAILABLE = true]
    F --> I[User taps Buy]
    G --> I
    H --> I
    I --> J{config.IAP_AVAILABLE?}
    J -- Yes --> K[Native IAP flow: iap.getProducts]
    J -- No --> L[auth.getLoggedInUser]
    L --> M{User logged in?}
    M -- No --> N[Open login page in CustomTabs]
    M -- Yes --> O[Open plugin purchase page in CustomTabs]
Loading

Reviews (5): Last reviewed commit: "fix: undefined error" | Re-trigger Greptile

Comment thread src/pages/plugin/plugin.view.js
Comment thread src/sidebarApps/extensions/index.js
Comment thread src/pages/plugin/plugin.js Outdated
Comment thread src/pages/plugin/plugin.view.js
Comment thread src/pages/plugins/item.js Outdated
@bajrangCoder bajrangCoder self-assigned this May 7, 2026
@RohitKushvaha01
Copy link
Copy Markdown
Member Author

@greptileai

@RohitKushvaha01 RohitKushvaha01 marked this pull request as ready for review May 8, 2026 05:08
@RohitKushvaha01
Copy link
Copy Markdown
Member Author

@greptileai

Comment thread src/sidebarApps/extensions/index.js Outdated
Comment thread src/lib/config.js
@RohitKushvaha01
Copy link
Copy Markdown
Member Author

@greptileai

Comment thread src/lib/config.js
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants