Skip to content

Conversation

Dinamiko
Copy link
Collaborator

@Dinamiko Dinamiko commented Sep 18, 2025

This PR consolidates Merchant details before and after onboarding, including deprecating/removing duplicated logic.

It also adds two new documents explaining how merchant onboarding and post-onboarding works.
Post onboarding document also explains how vaulting (save payment methods) availability is currently implemented.

Copy link

github-actions bot commented Sep 18, 2025

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 v3.1.2-pr3674-18375899725-gd79983c (built from this PR)

Login credentials:

  • Username: admin
  • Password: password

Plugin Details:

  • Version: 3.1.2-pr3674-18375899725-gd79983c
  • Commit: d79983c
  • Artifact: woocommerce-paypal-payments-3.1.2-pr3674-18375899725-gd79983c

💡 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 d79983c • Last updated: 2025-10-09T12:19:11.942Z

Copy link
Collaborator

@stracker-phil stracker-phil Sep 18, 2025

Choose a reason for hiding this comment

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

Should we integrate those checks into the MerchantDetails class for a more consistent API?

https://github.com/woocommerce/woocommerce-paypal-payments/blob/060a86f5c9693872328e4fbb9f58718e8456d091/modules/ppcp-wc-gateway/src/Helper/MerchantDetails.php

Generally, the utility would be better placed in the wc-gateway module, instead of the settings module

$can_use_subscriptions = $container->has('wc-subscriptions.helper') && $container->get('wc-subscriptions.helper')->plugin_is_active();
$should_skip_payment_methods = class_exists('\WC_Payments');
$can_use_fastlane = $container->get('axo.eligible');
$can_use_pay_later = $container->get('button.helper.messages-apply');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Is it useful to repeat the full service code here? Looks like a lot of maintenance to keep this doc in-sync with the code + does not add a huge benefit to the documentation.

A permalink would be sufficient IMO (which is usually rendered as embed in GH)
File: modules/ppcp-settings/services.php

'settings.data.onboarding' => static function ( ContainerInterface $container ): OnboardingProfile {
$can_use_casual_selling = $container->get( 'settings.casual-selling.eligible' );
$can_use_vaulting = $container->has( 'save-payment-methods.eligible' ) && $container->get( 'save-payment-methods.eligible' );
$can_use_card_payments = $container->has( 'card-fields.eligible' ) && $container->get( 'card-fields.eligible' );
$can_use_subscriptions = $container->has( 'wc-subscriptions.helper' ) && $container->get( 'wc-subscriptions.helper' )
->plugin_is_active();
$should_skip_payment_methods = class_exists( '\WC_Payments' );
$can_use_fastlane = $container->get( 'axo.eligible' );
$can_use_pay_later = $container->get( 'button.helper.messages-apply' );
return new OnboardingProfile(
$can_use_casual_selling,
$can_use_vaulting,
$can_use_card_payments,
$can_use_subscriptions,
$should_skip_payment_methods,
$can_use_fastlane,
$can_use_pay_later->for_country()
);
},


#### Flag Value Sources

**`can_use_casual_selling`** - Personal account support
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: To me this looks a bit like code documentation that should be present in the .php file.
Also, the service name is already visible in the code snippet above and describing the implementation logic here seems risky to get outdated as well.

I would keep this flag overview more concise, documenting the "business perspective", e.g.

  • can_use_casual_selling - Business accounts are supported in all countries; this flag indicates if the store country also supports onboarding using a personal account
  • can_use_vaulting - Whether the store's country supports vaulting - displays additional onboarding choices
  • should_skip_payment_methods - Whether the "branded only" mode is active and the onboarding wizard is reduced
  • ...

$applies = $container->get('module.helpers.applies');
return $applies->for_country() && $applies->for_merchant();
},
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: The whole "Country-Based Eligibility Services" section seems unrelated to the document topic - which should be about the "Onboarding Flow" - as it documents generic architecture instead of explaining onboarding details.

It's a nice idea to document code architecture, but let's move this to a different document. This section is confusing for new developers, especially since the code looks valid but actually displays pseudo-code (there is no service named module.helpers.applies, but specific services like applepay.helpers.apm-applies, which is not mentioned here)


#### Casual Selling Country List

The casual selling feature (personal PayPal accounts) supported countries are defined in: `modules/ppcp-settings/services.php`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Remove this, as code navigation within a single service file should be easy enough for every developer, and this description adds no value when reading the document in isolation. IMO this list/reference is also more related to a documentation about "Casual Seller vs Business Merchants"

'accept_card_payments' => bool // Whether to enable card payment methods
'products' => array // Selected product types ['virtual', 'physical', 'subscriptions']
'gateways_synced' => bool // Payment gateway sync status
'gateways_refreshed' => bool // Payment gateway refresh status
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Could we add those code comments to the actual .php file, e.g. to the OnboardingProfile and drop a link here? Those comments are very helpful, but developers usually do not see them in this MD file

protected function get_defaults(): array {
return array(
'completed' => false,
'step' => 0,
'is_casual_seller' => null,
'accept_card_payments' => null,
'products' => array(),
'setup_done' => false,
'gateways_synced' => false,
'gateways_refreshed' => false,
);
}

- Final step provides connection buttons/forms
- Connection success updates onboarding completion status
- Failed connections allow retry without losing progress

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Add a link to the authentication-flows.md document

return $this->environment->is_sandbox();
}
}
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Instead of documenting class code, IMO it would be beneficial to document the service name + the API methods (public methods) - but actually this section here is already 100% covered by the doc-block comment in the .php file and only duplicates content.

/**
* Class ConnectionState
*
* Manages the merchants' connection status details and provides inspection
* methods to describe the current state.
*
* DI service: 'settings.connection-state'
*/
class ConnectionState {

A link-list to all relevant classes would give the reader a better overview of what's involved in the post-onboarding process.

'merchantId' => '[email protected]', // Merchant's PayPal email address
'accountStatus' => 'BUSINESS_ACCOUNT', // Account type indicator
'ppcpToken' => 'VALIDATION_TOKEN' // Security token
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Thinking about the OAuth Response, I would rather add those details to the existing "authentication-flows.md" document, as it's tightly related to the authentication, and not post-onboarding

Shouldn't the "Post Onboarding" mainly describe how the merchant is initialized in the plugin, and talking about the SettingsDataManager flow?

return false;
}
}
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Merge this class with the existing MerchantDetails class, which lives in the ppcp-wc-gateway module and already provides related capability checks

$this->dcc_product_status = $dcc_product_status;
}

public function can_save_paypal_methods(): bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: I highly recommend to add doc-blocks to these methods and explain what they check. I.e. that this capability is checked using the PayPal API response


This dual-eligibility system ensures that merchants can offer the most appropriate save payment options based on their PayPal account capabilities and regional availability.

## Centralized Capability Management
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Capability detection is a central business logic of the plugin and deserves its own MD file :)

@Dinamiko Dinamiko changed the title Documentation task - Vaulting (5311) Consolidate merchant details before and after onboarding (5311) Oct 1, 2025
Copy link
Collaborator

@Narek13 Narek13 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @puntope . I left a question and a small suggestion, but overall, LGTM!

'woocommerce-paypal-payments'
),
'enabled' => $this->merchant_capabilities['pay_later'] && ! $save_paypal_and_venmo,
'enabled' => $this->merchant_capabilities['paylater'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was ! $save_paypal_and_venmo removed intentionally? Just want to make sure it’s not an accidental change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was ! $save_paypal_and_venmo removed intentionally?

yes. The reason is that this check checks if the setting is active. That setting is correctly blocking The payment method in the payment method page. But that doesn't mean we need to disable pay_later feature.

But now I check again maybe we want to...

Lets discuss tomorrow. I added it back for now.

@puntope puntope self-assigned this Oct 10, 2025
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