fix(PayPal): update config pickup from env (#38423)
Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
This commit is contained in:
@ -5,9 +5,12 @@ import PropTypes from 'prop-types';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { PayPalButton } from 'react-paypal-button-v2';
|
import { PayPalButton } from 'react-paypal-button-v2';
|
||||||
import { paypalClientId } from '../../../config/env.json';
|
import { paypalClientId, deploymentEnv } from '../../../config/env.json';
|
||||||
import { verifySubscriptionPaypal } from '../../utils/ajax';
|
import { verifySubscriptionPaypal } from '../../utils/ajax';
|
||||||
import { paypalConfigurator } from '../../../../config/donation-settings';
|
import {
|
||||||
|
paypalConfigurator,
|
||||||
|
paypalConfigTypes
|
||||||
|
} from '../../../../config/donation-settings';
|
||||||
import { signInLoadingSelector, userSelector } from '../../redux';
|
import { signInLoadingSelector, userSelector } from '../../redux';
|
||||||
|
|
||||||
export class PaypalButton extends Component {
|
export class PaypalButton extends Component {
|
||||||
@ -23,7 +26,8 @@ export class PaypalButton extends Component {
|
|||||||
|
|
||||||
const configurationObj = paypalConfigurator(
|
const configurationObj = paypalConfigurator(
|
||||||
donationAmount,
|
donationAmount,
|
||||||
donationDuration
|
donationDuration,
|
||||||
|
paypalConfigTypes[deploymentEnv || 'staging']
|
||||||
);
|
);
|
||||||
if (state === configurationObj) {
|
if (state === configurationObj) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
const path = require('path');
|
|
||||||
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
|
|
||||||
|
|
||||||
// Configuration for client side
|
// Configuration for client side
|
||||||
const durationsConfig = {
|
const durationsConfig = {
|
||||||
year: 'yearly',
|
year: 'yearly',
|
||||||
@ -48,10 +45,10 @@ const paypalConfigTypes = {
|
|||||||
planId: 'P-1L11422374370240ULZKX3PA'
|
planId: 'P-1L11422374370240ULZKX3PA'
|
||||||
},
|
},
|
||||||
'3500': {
|
'3500': {
|
||||||
planId: 'P-1L11422374370240ULZKX3PA'
|
planId: 'P-81U00703FF076883HLZ2PWMI'
|
||||||
},
|
},
|
||||||
'25000': {
|
'25000': {
|
||||||
planId: 'P-1L11422374370240ULZKX3PA'
|
planId: 'P-7M045671FN915794KLZ2PW6I'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
year: {
|
year: {
|
||||||
@ -92,12 +89,7 @@ const paypalConfigTypes = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const paypalConfig =
|
const paypalConfigurator = (donationAmount, donationDuration, paypalConfig) => {
|
||||||
process.env.DEPLOYMENT_ENV && process.env.DEPLOYMENT_ENV === 'live'
|
|
||||||
? paypalConfigTypes['live']
|
|
||||||
: paypalConfigTypes['staging'];
|
|
||||||
|
|
||||||
const paypalConfigurator = (donationAmount, donationDuration) => {
|
|
||||||
if (donationDuration === 'onetime') {
|
if (donationDuration === 'onetime') {
|
||||||
return { amount: donationAmount, duration: donationDuration };
|
return { amount: donationAmount, duration: donationDuration };
|
||||||
}
|
}
|
||||||
@ -117,6 +109,6 @@ module.exports = {
|
|||||||
donationOneTimeConfig,
|
donationOneTimeConfig,
|
||||||
donationSubscriptionConfig,
|
donationSubscriptionConfig,
|
||||||
modalDefaultStateConfig,
|
modalDefaultStateConfig,
|
||||||
paypalConfig,
|
paypalConfigTypes,
|
||||||
paypalConfigurator
|
paypalConfigurator
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,8 @@ const {
|
|||||||
SERVICEBOT_ID: servicebotId,
|
SERVICEBOT_ID: servicebotId,
|
||||||
ALGOLIA_APP_ID: algoliaAppId,
|
ALGOLIA_APP_ID: algoliaAppId,
|
||||||
ALGOLIA_API_KEY: algoliaAPIKey,
|
ALGOLIA_API_KEY: algoliaAPIKey,
|
||||||
PAYPAL_CLIENT_ID: paypalClientId
|
PAYPAL_CLIENT_ID: paypalClientId,
|
||||||
|
DEPLOYMENT_ENV: deploymentEnv
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
const locations = {
|
const locations = {
|
||||||
@ -35,6 +36,7 @@ const locations = {
|
|||||||
|
|
||||||
module.exports = Object.assign(locations, {
|
module.exports = Object.assign(locations, {
|
||||||
locale,
|
locale,
|
||||||
|
deploymentEnv,
|
||||||
stripePublicKey:
|
stripePublicKey:
|
||||||
!stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard'
|
!stripePublicKey || stripePublicKey === 'pk_from_stripe_dashboard'
|
||||||
? null
|
? null
|
||||||
|
Reference in New Issue
Block a user