-
Notifications
You must be signed in to change notification settings - Fork 58
Consolidate merchant details before and after onboarding (5311) #3674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 7 commits
976ab69
bda5742
fd1d0e3
ccadf52
4b91065
2f5dbf6
81750fc
cf82350
317400f
887c3ca
60eb84b
9a53273
b310999
174506b
1c7f893
106b6ec
53f9cf2
e328c5f
7398a32
1662ba2
cd3d1af
13a0de3
13dce9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,263 @@ | ||||||||||||||||||||||||||
| # Merchant Onboarding Flow | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| The onboarding flow is a multi-step wizard that guides merchants through setting up their PayPal integration. The flow is dynamic and adapts based on merchant preferences, store configuration, and country-specific capabilities determined by configuration flags. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ## Core Architecture | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### Configuration Flags Value Determination | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| The onboarding configuration flags are determined during the `OnboardingProfile` instantiation in the dependency injection container. Each flag represents a specific capability or business rule that affects the onboarding flow. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **File:** `modules/ppcp-settings/services.php` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ```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(/* ...flags... */); | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #### Flag Value Sources | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`can_use_casual_selling`** - Personal account support | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| - **Source:** `settings.casual-selling.eligible` service (`services.php`) | ||||||||||||||||||||||||||
| - **Logic:** Checks if store's country is in supported countries list | ||||||||||||||||||||||||||
| - **Countries:** Countries including US, CA, AU, GB, EU countries, etc. (`services.php`) | ||||||||||||||||||||||||||
| - **Determination:** `in_array($country, $eligible_countries, true)` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`can_use_vaulting`** - Saved payment methods capability | ||||||||||||||||||||||||||
| - **Source:** `save-payment-methods.eligible` service from SavePaymentMethods module | ||||||||||||||||||||||||||
| - **File:** `modules/ppcp-save-payment-methods/services.php` | ||||||||||||||||||||||||||
| - **Logic:** `SavePaymentMethodsApplies::for_country() && SavePaymentMethodsApplies::for_merchant()` | ||||||||||||||||||||||||||
| - **Countries:** Countries including major markets (AU, AT, BE, CA, DE, FR, etc.) | ||||||||||||||||||||||||||
| - **Merchant Check:** PayPal account must support vaulting capabilities | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`can_use_card_payments`** - Credit card processing via PayPal | ||||||||||||||||||||||||||
| - **Source:** `card-fields.eligible` service from CardFields module | ||||||||||||||||||||||||||
| - **File:** `modules/ppcp-card-fields/services.php` | ||||||||||||||||||||||||||
| - **Logic:** `CardFieldsApplies::for_country() && CardFieldsApplies::for_merchant()` | ||||||||||||||||||||||||||
| - **Countries:** Countries with credit card processing support | ||||||||||||||||||||||||||
| - **Merchant Check:** PayPal account must have ACDC (Advanced Credit and Debit Cards) capability | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`can_use_subscriptions`** - WooCommerce Subscriptions integration | ||||||||||||||||||||||||||
| - **Source:** `wc-subscriptions.helper` service availability check | ||||||||||||||||||||||||||
| - **Logic:** Checks if WooCommerce Subscriptions plugin is active | ||||||||||||||||||||||||||
| - **Determination:** `$container->get('wc-subscriptions.helper')->plugin_is_active()` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`should_skip_payment_methods`** - Skip payment methods selection screen | ||||||||||||||||||||||||||
| - **Source:** Direct class existence check | ||||||||||||||||||||||||||
| - **Logic:** `class_exists('\WC_Payments')` | ||||||||||||||||||||||||||
| - **Purpose:** Skip payment methods screen when WooCommerce Payments plugin is active (avoid conflicts) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`can_use_fastlane`** - Fastlane/AXO checkout capability | ||||||||||||||||||||||||||
| - **Source:** `axo.eligible` service from AXO module | ||||||||||||||||||||||||||
| - **Dependencies:** Requires ACDC capability and specific country/merchant eligibility | ||||||||||||||||||||||||||
| - **Purpose:** Determines if Advanced Checkout Options (one-click checkout) can be offered | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **`can_use_pay_later`** - Pay Later messaging availability | ||||||||||||||||||||||||||
| - **Source:** `button.helper.messages-apply` service from Button module | ||||||||||||||||||||||||||
| - **File:** `modules/ppcp-button/services.php` (MessagesApply class) | ||||||||||||||||||||||||||
| - **Logic:** `MessagesApply::for_country()` - checks country against PayPal's Pay Later supported regions | ||||||||||||||||||||||||||
| - **Countries:** Pay Later messaging supported in US, AU, DE, FR, GB, IT, ES and other select markets | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #### Country-Based Eligibility Services | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Multiple modules implement country-based eligibility patterns: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ```php | ||||||||||||||||||||||||||
| // Common pattern across modules | ||||||||||||||||||||||||||
| 'module.helpers.applies' => function(ContainerInterface $container): ModuleApplies { | ||||||||||||||||||||||||||
| return new ModuleApplies( | ||||||||||||||||||||||||||
| $container->get('module.supported-countries'), // Country whitelist | ||||||||||||||||||||||||||
| $container->get('api.shop.country') // Current store country | ||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Eligibility check | ||||||||||||||||||||||||||
| 'module.eligible' => function(ContainerInterface $container): bool { | ||||||||||||||||||||||||||
| $applies = $container->get('module.helpers.applies'); | ||||||||||||||||||||||||||
| return $applies->for_country() && $applies->for_merchant(); | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #### Casual Selling Country List | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| The casual selling feature (personal PayPal accounts) supported countries are defined in: `modules/ppcp-settings/services.php` | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### API Endpoint: `wc/v3/wc_paypal/onboarding` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| The central REST API endpoint manages all onboarding state and configuration: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| **File:** `modules/ppcp-settings/src/Endpoint/OnboardingRestEndpoint.php` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #### Endpoints: | ||||||||||||||||||||||||||
| - **GET** `/wp-json/wc/v3/wc_paypal/onboarding` - Retrieves current onboarding state and flags | ||||||||||||||||||||||||||
| - **POST** `/wp-json/wc/v3/wc_paypal/onboarding` - Updates onboarding progress and settings | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #### Key Data Structures: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ```php | ||||||||||||||||||||||||||
| // Onboarding state fields (OnboardingProfile) | ||||||||||||||||||||||||||
| 'completed' => bool // Onboarding process completion status | ||||||||||||||||||||||||||
| 'step' => int // Current step index (0-based) | ||||||||||||||||||||||||||
| 'is_casual_seller' => bool // Personal vs business account selection | ||||||||||||||||||||||||||
| '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 | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| 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, | |
| ); | |
| } |
Outdated
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.phpwoocommerce-paypal-payments/modules/ppcp-settings/services.php
Lines 85 to 104 in 2355409