♻️ Move PayPal product names to config file

Because constants are better than magic strings
This commit is contained in:
Philipp Stracker 2025-03-03 15:27:53 +01:00
parent 748c7f4d10
commit 27f4ab442f
No known key found for this signature in database
2 changed files with 12 additions and 5 deletions

View file

@ -24,3 +24,9 @@ export const PRODUCT_TYPES = {
PHYSICAL: 'physical',
SUBSCRIPTIONS: 'subscriptions',
};
export const PAYPAL_PRODUCTS = {
ACDC: 'PPCP',
BCDC: 'EXPRESS_CHECKOUT',
VAULTING: 'ADVANCED_VAULTING',
};

View file

@ -6,7 +6,8 @@
*
* @file
*/
import { PRODUCT_TYPES } from './configuration';
import { PAYPAL_PRODUCTS, PRODUCT_TYPES } from './configuration';
const EMPTY_OBJ = Object.freeze( {} );
@ -63,13 +64,13 @@ export const determineProductsAndCaps = ( state ) => {
* Branch 1: Credit Card Payments not available.
* The store uses the Express-checkout product.
*/
apiModules.push( 'EXPRESS_CHECKOUT' );
apiModules.push( PAYPAL_PRODUCTS.BCDC );
} else if ( isCasualSeller ) {
/**
* Branch 2: Merchant has no business.
* The store uses the Express-checkout product.
*/
apiModules.push( 'EXPRESS_CHECKOUT' );
apiModules.push( PAYPAL_PRODUCTS.BCDC );
} else {
/**
* 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.
*/
apiModules.push( 'PPCP' );
apiModules.push( PAYPAL_PRODUCTS.ACDC );
if ( products?.includes( PRODUCT_TYPES.SUBSCRIPTIONS ) ) {
options.useSubscriptions = true;
@ -89,7 +90,7 @@ export const determineProductsAndCaps = ( state ) => {
}
if ( canUseVaulting ) {
apiModules.push( 'ADVANCED_VAULTING' );
apiModules.push( PAYPAL_PRODUCTS.VAULTING );
}
return { products: apiModules, options };