Skip to content

Core SDK loading & PayPal buttons via v6 Web SDK (5780)#4526

Merged
danieldudzic merged 18 commits into
dev/PCP-5777-update-v-5-js-sdk-integration-to-v-6-web-sdkfrom
dev/PCP-5780-core-sdk-loading-pay-pal-buttons
Jul 21, 2026
Merged

Core SDK loading & PayPal buttons via v6 Web SDK (5780)#4526
danieldudzic merged 18 commits into
dev/PCP-5777-update-v-5-js-sdk-integration-to-v-6-web-sdkfrom
dev/PCP-5780-core-sdk-loading-pay-pal-buttons

Conversation

@danieldudzic

Copy link
Copy Markdown
Collaborator

Note: This PR is against the v6 SDK epic branch: dev/PCP-5777-update-v-5-js-sdk-integration-to-v-6-web-sdk and not dev/develop

Description

Core v6 Web SDK frontend: createInstance() with a server-fetched client token, explicit eligibility via findEligibleMethods() (currency/country/amount), one-time payment sessions and Web Component buttons for PayPal/Venmo/Pay Later across product, cart, checkout, and classic mini-cart.

  • Server side is 100% shared with v5. v6 calls the existing ppc-* endpoints through one JS adapter and reuses existing services/helpers (SettingsStatus, styling DTOs, Context, SingleProductActionHandler, ErrorHandler). Only change outside the module: one do_action in CreateOrderEndpoint (stores the session order for non-checkout contexts; v5 unchanged).
  • Completion flow matches classic v5 continuation: approve, redirect to checkout, Place Order processes the session order.

Migration methodology (v5 and v6 side by side): during the epic, every payment surface is owned by exactly one stack. A single function (SdkV6Manager::should_load_on_current_page()) decides per page whether v6 loads. On those pages the v5 smart buttons are suppressed, since both SDKs claim window.paypal. Everywhere else (block cart/checkout, pay-now, wallets, messaging) v5 keeps running untouched. This keeps the site and the QA/e2e suites fully functional after every story lands: each subsequent ticket simply widens what v6 owns instead of adding per-surface toggles or shims. The handoff is migration-phase scaffolding only, marked for removal at release (see extensions.php). The end state is a whole-flow flag flip: v5 or v6, never a per-page mix.

Screenshots

Before After
v5 v62

Missing on the v6 side by design: messaging, wallets - included in separate tickets

Steps to Test

Setup: flag on via PCP_SDK_V6_ENABLED=1 (or filter woocommerce.feature-flags.woocommerce_paypal_payments.sdk_v6_enabled set to true), sandbox-connected store, npm run build.

  1. Product page: gold PayPal/Venmo/Pay Later Web Components render in #ppc-button-ppcp-gateway-v6. Network shows web-sdk/v6/core plus one ppc-sdk-v6-client-token POST, and no paypal.com/sdk/js. No [PPCP SDK v6] console errors.
  2. Purchase: click PayPal, approve as sandbox buyer, get redirected to checkout, click Place Order. Verify the order in wp-admin (Processing, PayPal txn ID, stock reduced).
  3. Shipping in popup: from cart, change the address to another US state. update-customer (non-empty state) and ppc-update-shipping fire, popup totals update.
  4. Settings: shape/color changes in Styling apply; disabling a the script there.
  5. Coexistence / flag off: block cart/checkout still show v5 e off, no v6 anywhere (identical to dev/develop).
  6. Suites: npm run unit-tests, npm run test:unit-js, npm cp-blocks/checkout-handler JS failures are unrelated; they fail on
    dev/develop too).

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

🔗 Test this pull request with WordPress Playground

What's included:

  • ✅ WordPress (latest)
  • ✅ WooCommerce (latest)
  • ✅ PayPal Payments plugin v4.1.1-pr4526-29766602071-g2446251 (built from this PR)

Login credentials:

  • Username: admin
  • Password: password

Plugin Details:

  • Version: 4.1.1-pr4526-29766602071-g2446251
  • Commit: 17f8fac
  • Artifact: woocommerce-paypal-payments-4.1.1-pr4526-29766602071-g2446251

💡 The demo environment resets each time you refresh. Perfect for testing!

🔄 This link updates automatically with each new commit to the PR.

⚠️ This URL is valid for 30 days from when this comment was last updated.


🤖 Auto-generated for commit 17f8fac • Last updated: 2026-07-20T18:13:30.845Z

Comment thread modules/ppcp-button/src/Endpoint/CreateOrderEndpoint.php Outdated
Comment thread modules/ppcp-sdk-v6/src/Assets/SdkV6Manager.php Outdated
Comment thread modules/ppcp-sdk-v6/src/Assets/SdkV6Manager.php Outdated
Comment thread modules/ppcp-sdk-v6/src/Assets/SdkV6Manager.php Outdated
Comment thread modules/ppcp-sdk-v6/src/SdkV6Module.php Outdated
Comment thread modules/ppcp-sdk-v6/resources/js/sessions/shippingHandler.js Outdated
Comment thread modules/ppcp-sdk-v6/resources/js/boot.js Outdated

@stracker-phil stracker-phil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge; all comments are nits/suggestions

@Narek13 Narek13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice PR, thank you! It looks great to me. I’ve also added a couple of small suggestions on top of what @stracker-phil already mentioned, but I think we’re good to go. Thanks again! 🙂

Comment thread modules/ppcp-sdk-v6/src/Assets/SdkV6Manager.php Outdated
Comment thread modules/ppcp-sdk-v6/src/Helper/ButtonStyleMapper.php Outdated
Comment thread modules/ppcp-sdk-v6/src/SdkV6Module.php Outdated
@danieldudzic
danieldudzic merged commit 4e96b7f into dev/PCP-5777-update-v-5-js-sdk-integration-to-v-6-web-sdk Jul 21, 2026
13 checks passed
@danieldudzic
danieldudzic deleted the dev/PCP-5780-core-sdk-loading-pay-pal-buttons branch July 21, 2026 16:01
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.

4 participants