mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
♻️ Move branded-only detection to server side
This commit is contained in:
parent
9d16b19bd4
commit
807fd96183
4 changed files with 19 additions and 8 deletions
|
@ -32,7 +32,16 @@ const defaultTransient = Object.freeze( {
|
|||
wooSettings: Object.freeze( {
|
||||
storeCountry: '',
|
||||
storeCurrency: '',
|
||||
installationPath: '',
|
||||
|
||||
/**
|
||||
* The "branded-only" experience is determined on server-side, based on the installation path.
|
||||
*
|
||||
* When true, the plugin must only display "PayPal's own brand" payment options
|
||||
* i.e. no card payments or Apple Pay/Google Pay.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
ownBrandOnly: false,
|
||||
} ),
|
||||
|
||||
features: Object.freeze( {
|
||||
|
|
|
@ -43,10 +43,11 @@ export const features = ( state ) => {
|
|||
export const wooSettings = ( state ) => {
|
||||
const settings = getState( state ).wooSettings || EMPTY_OBJ;
|
||||
|
||||
// For development and testing. Remove this eventually!
|
||||
const simulateBrandedOnly = localStorage.getItem( 'simulate-branded-only' );
|
||||
|
||||
/**
|
||||
* The "branded only experience" is determined based on the installation path.
|
||||
* The "own-brand-only" experience is determined on server-side, based on the installation path.
|
||||
*
|
||||
* When true, the plugin must only display "PayPal's own brand" payment options
|
||||
* i.e. no card payments or Apple Pay/Google Pay.
|
||||
|
@ -54,9 +55,7 @@ export const wooSettings = ( state ) => {
|
|||
* @type {boolean}
|
||||
*/
|
||||
const ownBrandOnly =
|
||||
'true' === simulateBrandedOnly || // For development and testing. Remove this eventually!
|
||||
settings.installationPath === 'core-profile' ||
|
||||
settings.installationPath === 'payment-settings';
|
||||
'true' === simulateBrandedOnly || settings.ownBrandOnly;
|
||||
|
||||
return { ...settings, ownBrandOnly };
|
||||
};
|
||||
|
|
|
@ -131,7 +131,7 @@ class GeneralSettings extends AbstractDataModel {
|
|||
public function get_woo_settings() : array {
|
||||
$settings = $this->woo_settings;
|
||||
|
||||
$settings['installation_path'] = $this->get_installation_path();
|
||||
$settings['own_brand_only'] = $this->own_brand_only();
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
|
|
@ -108,12 +108,15 @@ class CommonRestEndpoint extends RestEndpoint {
|
|||
* @var array
|
||||
*/
|
||||
private array $woo_settings_map = array(
|
||||
'country' => array(
|
||||
'country' => array(
|
||||
'js_name' => 'storeCountry',
|
||||
),
|
||||
'currency' => array(
|
||||
'currency' => array(
|
||||
'js_name' => 'storeCurrency',
|
||||
),
|
||||
'own_brand_only' => array(
|
||||
'js_name' => 'ownBrandOnly',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue