Skip to content

feat: Implement shoppable ads, RoktStripePaymentExtension#83

Merged
rmi22186 merged 7 commits into
shoppable-adsfrom
feat/shoppable-ads
Apr 20, 2026
Merged

feat: Implement shoppable ads, RoktStripePaymentExtension#83
rmi22186 merged 7 commits into
shoppable-adsfrom
feat/shoppable-ads

Conversation

@rmi22186

@rmi22186 rmi22186 commented Apr 17, 2026

Copy link
Copy Markdown
Member

Summary

Upgrades the iOS mParticle Apple SDK and Rokt kit from v8 to v9, adds Shoppable Ads support, and fixes a pre-existing CI
failure.

SDK v9 upgrade

  • mParticle-Apple-SDK: 8.37.1~> 9.0, mParticle-Rokt: 8.3.0~> 9.0
  • iOS deployment target: 12.016.0 (v9 requires 15.6+)
  • Migrated CDVMParticle.m to v9 module imports (mParticle_Apple_SDK, mParticle_Apple_SDK_ObjC, RoktContracts) and
    RoktConfigBuilder pattern
  • Set Cordova wrapper SDK type via pluginInitialize
  • Fixed Android target-dir in plugin.xml

Shoppable Ads

  • JS API: mparticle.Rokt.selectShoppableAds(identifier, attributes, config) and
    mparticle.Rokt.purchaseFinalized(placementId, catalogItemId, success)
  • iOS: Native methods calling MPRokt.selectShoppableAds and MPRokt.purchaseFinalized
  • Android: purchaseFinalized implemented; selectShoppableAds logs a warning (not yet supported, matching RN SDK)

New kit: Kits/RoktStripePayment

  • @mparticle/cordova-rokt-stripe-payment-kit — adds RoktStripePaymentExtension pod for Apple Pay via Stripe
  • Named per payment provider to allow future kits for other providers (e.g. Braintree, PayPal) without bundling unused
    dependencies

Example app updates

  • Added "Select Shoppable Ads" and "Purchase Finalized" buttons
  • RoktPaymentSetup.swift bridging class for registering the Stripe payment extension from ObjC
  • AppDelegate registers payment extension after SDK init
  • Refactored hook with copyFile helper, extracted Ruby into configure_xcode_swift.rb, consistent error handling

CI fix

  • Bumped Android unit test JDK from 11 to 17 (pre-existing failure — android-core class files compiled with Java 17 are
    incompatible with Java 11)

Key implementation note

The Rokt Widget SDK v9 requires RoktConfig to be nil when no meaningful config values are set — passing a
default-built config causes placements to silently return empty. buildRoktConfigFromDict: mirrors the React Native SDK's
approach of returning nil for empty configs. Also handles NSNull from the Cordova bridge for optional parameters.

Test plan

  • iOS: selectPlacements overlay renders
  • iOS: selectShoppableAds overlay renders
  • iOS: Config passthrough verified (colorMode, cacheConfig)
  • Android: Unit tests pass locally with JDK 17

rmi22186 and others added 4 commits April 17, 2026 16:24
JS API:
- mparticle.Rokt.selectShoppableAds(identifier, attributes, config)
- mparticle.Rokt.purchaseFinalized(placementId, catalogItemId, success)

iOS:
- Add selectShoppableAds and purchaseFinalized native methods
- Handle NSNull from Cordova bridge in buildRoktConfigFromDict

Android:
- Add selectShoppableAds (logs warning, not yet supported - matches RN)
- Add purchaseFinalized

Example app:
- Add shoppable ads and purchase finalized buttons
- Add RoktPaymentSetup.swift bridging class for payment extension
- Update hook to add RoktStripePaymentExtension pod and configure
  Xcode project for Swift interop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Import Swift bridging header for RoktPaymentSetup
- Register RoktStripePaymentExtension after SDK init

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…hrough

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Create Kits/RoktShoppableAds with RoktStripePaymentExtension pod
- Add kit to example app config.xml
- Remove Podfile manipulation from hook (kit handles it)
- Extract inline Ruby into configure_xcode_swift.rb
- Refactor hook with copyFile helper and consistent error handling

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rmi22186
rmi22186 requested a review from a team as a code owner April 17, 2026 21:05
@cursor

cursor Bot commented Apr 17, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Adds new cross-platform JS→native plugin actions and iOS build/tooling changes (Swift bridging, new pod/kit) that could affect integration and runtime behavior. Android support is partial, so callers may encounter platform-specific limitations if not guarded.

Overview
Adds Rokt Shoppable Ads support to the Cordova SDK by exposing new JS APIs mparticle.Rokt.selectShoppableAds() and mparticle.Rokt.purchaseFinalized() and wiring them through to native implementations.

On iOS, the plugin now builds a RoktConfig that can be nil when empty (including handling NSNull), and adds native calls for selectShoppableAds/purchaseFinalized. On Android, purchaseFinalized is implemented while selectShoppableAds is explicitly stubbed with a warning.

Introduces a new iOS-only Cordova kit @mparticle/cordova-rokt-stripe-payment-kit that pulls in the RoktStripePaymentExtension pod, and updates the example app + docs to show installing the kit, registering the Swift-only payment extension via an ObjC bridge, and invoking the new Shoppable Ads flows (including a hook/Ruby script to add Swift + bridging header to the Xcode project).

Reviewed by Cursor Bugbot for commit 5384b57. Bugbot is set up for automated code reviews on this repo. Configure here.

@rmi22186 rmi22186 changed the title Feat/shoppable ads feat: Implement shoppable ads, RoktStripePaymentExtension Apr 17, 2026
- Add Rokt kit installation
- Add selectPlacements usage with optional config
- Add Shoppable Ads setup (kit, payment extension, selectShoppableAds)
- Document both Swift and ObjC payment extension registration
- Reference both example apps
- Update SDK version reference from 8.5.2 to 9.0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rmi22186
rmi22186 force-pushed the feat/shoppable-ads branch from 5c98a47 to ef0d954 Compare April 20, 2026 14:19
rmi22186 and others added 2 commits April 20, 2026 10:28
Rename to be payment-provider-specific, allowing future kits for other
providers (e.g. Braintree, PayPal) without bundling unused dependencies.

- Kits/RoktShoppableAds → Kits/RoktStripePayment
- @mparticle/cordova-rokt-shoppable-ads-kit → @mparticle/cordova-rokt-stripe-payment-kit
- Update example config.xml, hook comment, and README

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Swift example will be added separately on the swift-example-app branch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rmi22186
rmi22186 merged commit b8095e9 into shoppable-ads Apr 20, 2026
10 of 11 checks passed
@rmi22186
rmi22186 deleted the feat/shoppable-ads branch April 20, 2026 17:17
jamesnrokt added a commit that referenced this pull request Jun 10, 2026
…ement events (#84)

* feat: upgrade mParticle Apple SDK and Rokt kit to v9

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: Implement shoppable ads, RoktStripePaymentExtension (#83)

* feat: align Shoppable Ads with mParticle 9.2 + unified RoktPaymentExtension (#93)

* chore: bump native deps to mParticle-Apple-SDK 9.2 / android-core 5.79.0

Aligns the Cordova plugin's pinned native versions with what the
sibling RN and Flutter wrappers shipped at the same release line:

- iOS `mParticle-Apple-SDK`     ~> 9.0    → ~> 9.2
- iOS `mParticle-Rokt`          ~> 9.0    → ~> 9.2
- Android `android-core`        5.71.0    → 5.79.0
- Android `android-rokt-kit`    5.71.0    → 5.79.0
- README Podfile note bumped to 9.2.0 or later

Apple SDK 9.2 widens the MPRokt surface (registerPaymentExtension:,
handleURLCallback:, setSessionId:/getSessionId, expanded RoktEvent
hierarchy) and stops the partner from having to thread stripeKey
through Cordova JS — the Rokt kit now reads stripePublishableKey
from kit configuration in the mParticle dashboard.

Follow-up commits in this branch bridge the new methods and rename
the Stripe-named payment kit to the unified RoktPaymentExtension.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor: rename Rokt Stripe payment kit to unified RoktPaymentExtension

`RoktStripePaymentExtension 0.1.x` was the Stripe-only iOS Rokt
payment extension. Upstream Rokt has since unified its providers
into a single `RoktPaymentExtension` package (`~> 2.0`) that
internally routes to Stripe for Apple Pay / card / Afterpay /
Clearpay / PayPal — partner code no longer needs to pick a provider
at integration time.

- `Kits/RoktStripePayment/`  →  `Kits/RoktPaymentExtension/`
- npm + Cordova id `@mparticle/cordova-rokt-stripe-payment-kit`
  → `@mparticle/cordova-rokt-payment-extension`
- pod `RoktStripePaymentExtension ~> 0.1`  →  `RoktPaymentExtension ~> 2.0`
- `example/config.xml` plugin reference updated to the new id / path
- `example/platform_overrides/ios/RoktPaymentSetup.swift` imports
  the unified module and constructs `RoktPaymentExtension(applePayMerchantId:)`
  instead of `RoktStripePaymentExtension(applePayMerchantId:)`.
- AppDelegate comment + copy-hook comment updated.

The Swift helper still calls `MParticle.sharedInstance().rokt.register(_:)`
(which is the Swift form of `[[MParticle sharedInstance].rokt
registerPaymentExtension:]`). The Rokt kit on mParticle Apple SDK 9.2
pulls `stripePublishableKey` from kit configuration in the mParticle
dashboard and forwards it to Rokt at registration time, so the host
app only needs to provide the Apple Pay merchant identifier.

README still references the old Stripe-named symbols — fixed in the
docs commit later in this branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat: bridge setSessionId / getSessionId / handleURLCallback on Rokt

mParticle Apple SDK 9.2 widened MPRokt with three pass-through
APIs that the Cordova bridge can now forward:

- `setSessionId:` / `-getSessionId` — let JS share a session id with
  a WebView leg of the same flow, matching the standalone Rokt SDK
  and the React Native wrapper.
- `handleURLCallback:` — receive deep-link return URLs from
  redirect-based Rokt payment methods (AfterPay, PayPal) and ask the
  registered payment extension(s) to claim them. Returns BOOL so the
  host can fall back to its own URL routing on no-claim.

`registerPaymentExtension:` is intentionally NOT exposed in JS.
The concrete extension class has a Swift failable initializer that
isn't `@objc`-exported, so partners need a Swift bridge file in
their app target anyway; once they have it, registering from
AppDelegate is one line. A JS API would only add plumbing without
removing the native setup, encourage per-call registration footguns,
and diverge from how the RN and Flutter wrappers handle it.

- iOS: real selectors against `[[MParticle sharedInstance].rokt …]`.
- Android: `setSessionId` and `getSessionId` are real calls
  (`MParticle.getInstance().Rokt().setSessionId / .getSessionId`);
  `handleURLCallback` is a logged no-op matching the RN/Flutter
  pattern until the Android SDK ships the same API.
- JS: `setSessionId` is fire-and-forget, `getSessionId` and
  `handleURLCallback` accept a completion that receives the
  session-id string and a BOOL `handled`, respectively.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: align README + CHANGELOG with 9.2 / unified payment-extension flow

README's Shoppable Ads section was wired up against the old Stripe-named
plugin (`@mparticle/cordova-rokt-stripe-payment-kit`,
`RoktStripePaymentExtension`). Rewrite it for the unified
`@mparticle/cordova-rokt-payment-extension` kit and quote the
Swift bridge example partners need in their app target.

- Step 1: install the unified payment-extension kit instead of the
  Stripe-named one.
- Step 2: full Swift bridge snippet (RoktPaymentSetup.swift) plus the
  AppDelegate call. Notes that the Rokt kit on mParticle Apple SDK
  9.2 reads `stripePublishableKey` from the mParticle dashboard, so
  partners no longer need to ship a Stripe key from JS.
- New step 4 covers `handleURLCallback` for redirect-based payments
  (AfterPay, PayPal).
- New step 5 covers `setSessionId` / `getSessionId` for WebView
  session continuity.
- CHANGELOG `[Unreleased]` documents the three native bumps, the
  Stripe → unified rename, and the three new bridged JS methods.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: wire example app for Shoppable Ads testing

Register the unified Rokt payment extension in the example AppDelegate,
randomize the selectShoppableAds confirmation ref / email per tap so
Rokt's dedup doesn't suppress repeat requests during local testing, and
disable the response cache. Adds patched mParticle 9.2 podspecs that
bump the RoktContracts requirement to ~> 1.0 so the example resolves
cleanly against current Rokt-Widget.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: address review feedback and fix red example CI on Shoppable Ads 9.2

- Sync example/package-lock.json with package.json so `npm ci` passes
  (was missing @mparticle/cordova-rokt-payment-extension → EUSAGE, failing
  both example build jobs before any build ran).
- Remove orphaned patched-podspecs (pinned 9.0.1, violating the plugin's
  ~> 9.2 constraint). Published mParticle-Apple-SDK 9.2.0 already declares
  RoktContracts (~> 2.0), so a clean pod install resolves to RoktContracts
  2.0.2 / RoktPaymentExtension 2.0.3 with no overrides. Verified end-to-end:
  example builds on cordova-ios 7.1.1, Rokt kit 9.2.0 inits, payment
  extension registers, selectShoppableAds renders.
- Remove the 'Strip before commit' globalEvents diagnostic from the example
  AppDelegate.
- Use file: prefix for the cordova-rokt-payment-extension dev dependency.
- Bump android-core / android-rokt-kit to 5.79.1 (latest stable 5.x).

Addresses all three Cursor Bugbot comments on #93.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: James Newman <james.newman@rokt.com>

* feat: bridge Rokt placement events (onEvent) to JS (#94)

Add mparticle.Rokt.events(identifier, onEvent) — a standalone subscriber
mirroring the native events API shape (not folded into selectPlacements) —
plus mparticle.Rokt.EventType constants.

iOS (CDVMParticle.m): roktEvents: forwards to MPRokt events:onEvent:;
dictionaryFromRoktEvent: serializes every RoktEvent subclass from
RoktContracts 2.0.2 to a dict and streams via CDVPluginResult with
setKeepCallback:YES for multi-shot delivery.

Android (MParticleCordovaPlugin.java): roktEvents subscribes to the
events(identifier) Flow via onEach/launchIn, serializes each event to JSON,
and streams with keepCallback. Each placement's collection scope is tracked
in a map keyed by identifier: re-subscribing the same identifier cancels the
prior scope instead of stacking a second collector, and onDestroy cancels
every active scope so collectors stop running and never deliver through a
callbackContext bound to a destroyed WebView.

README + example: Placement Events section and a Subscribe to Events button.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: address Bugbot review comments on shoppable-ads

- Android selectShoppableAds/purchaseFinalized now accept a callbackContext and
  send a PluginResult, so the JS promises resolve instead of dangling (#3).
- purchaseFinalized is a no-op + warning on Android, matching selectShoppableAds
  (unsupported) and handleURLCallback — avoids calling the Rokt SDK with no
  active shoppable session (#2).
- Quote iosPath/script path in the platform-add hook so project roots containing
  spaces don't break `cordova platform add ios` (#1).
- Make configure_xcode_swift.rb idempotent: reuse an existing RoktPaymentSetup.swift
  reference and skip re-adding it, so re-runs don't create duplicate compile sources (#5).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: set iOS wrapper SDK version and cover RoktPaymentExtension in release flow (#95)

The release workflow only ever versioned/published the plugin and Rokt kit,
leaving two gaps:

- CDVMParticle.m reported an empty wrapper version to mParticle
  (_setWrapperSdk_internal version:@""). Seed it with the current version and
  add a release-workflow step that bumps it alongside plugin.xml, so it tracks
  every release instead of going stale.
- Kits/RoktPaymentExtension (new this release) was not managed by the release
  flow at all, so it had drifted to 3.0.0 and would never be version-bumped or
  published. Add version-bump + plugin.xml + dry-run-publish steps mirroring the
  Rokt kit, align it to 3.0.1, and list the extra files in the release PR body.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: James Newman <james.newman@rokt.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.

2 participants