mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
♻️ Move PayPal product names to config file
Because constants are better than magic strings
This commit is contained in:
parent
748c7f4d10
commit
27f4ab442f
2 changed files with 12 additions and 5 deletions
|
@ -24,3 +24,9 @@ export const PRODUCT_TYPES = {
|
||||||
PHYSICAL: 'physical',
|
PHYSICAL: 'physical',
|
||||||
SUBSCRIPTIONS: 'subscriptions',
|
SUBSCRIPTIONS: 'subscriptions',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const PAYPAL_PRODUCTS = {
|
||||||
|
ACDC: 'PPCP',
|
||||||
|
BCDC: 'EXPRESS_CHECKOUT',
|
||||||
|
VAULTING: 'ADVANCED_VAULTING',
|
||||||
|
};
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
*/
|
*/
|
||||||
import { PRODUCT_TYPES } from './configuration';
|
|
||||||
|
import { PAYPAL_PRODUCTS, PRODUCT_TYPES } from './configuration';
|
||||||
|
|
||||||
const EMPTY_OBJ = Object.freeze( {} );
|
const EMPTY_OBJ = Object.freeze( {} );
|
||||||
|
|
||||||
|
@ -63,13 +64,13 @@ export const determineProductsAndCaps = ( state ) => {
|
||||||
* Branch 1: Credit Card Payments not available.
|
* Branch 1: Credit Card Payments not available.
|
||||||
* The store uses the Express-checkout product.
|
* The store uses the Express-checkout product.
|
||||||
*/
|
*/
|
||||||
apiModules.push( 'EXPRESS_CHECKOUT' );
|
apiModules.push( PAYPAL_PRODUCTS.BCDC );
|
||||||
} else if ( isCasualSeller ) {
|
} else if ( isCasualSeller ) {
|
||||||
/**
|
/**
|
||||||
* Branch 2: Merchant has no business.
|
* Branch 2: Merchant has no business.
|
||||||
* The store uses the Express-checkout product.
|
* The store uses the Express-checkout product.
|
||||||
*/
|
*/
|
||||||
apiModules.push( 'EXPRESS_CHECKOUT' );
|
apiModules.push( PAYPAL_PRODUCTS.BCDC );
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* Branch 3: Merchant is business, and can use CC payments.
|
* Branch 3: Merchant is business, and can use CC payments.
|
||||||
|
@ -77,7 +78,7 @@ export const determineProductsAndCaps = ( state ) => {
|
||||||
*
|
*
|
||||||
* This is the only branch that can use subscriptions.
|
* This is the only branch that can use subscriptions.
|
||||||
*/
|
*/
|
||||||
apiModules.push( 'PPCP' );
|
apiModules.push( PAYPAL_PRODUCTS.ACDC );
|
||||||
|
|
||||||
if ( products?.includes( PRODUCT_TYPES.SUBSCRIPTIONS ) ) {
|
if ( products?.includes( PRODUCT_TYPES.SUBSCRIPTIONS ) ) {
|
||||||
options.useSubscriptions = true;
|
options.useSubscriptions = true;
|
||||||
|
@ -89,7 +90,7 @@ export const determineProductsAndCaps = ( state ) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( canUseVaulting ) {
|
if ( canUseVaulting ) {
|
||||||
apiModules.push( 'ADVANCED_VAULTING' );
|
apiModules.push( PAYPAL_PRODUCTS.VAULTING );
|
||||||
}
|
}
|
||||||
|
|
||||||
return { products: apiModules, options };
|
return { products: apiModules, options };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue