fix(client): fixup PayPal intergration

This commit is contained in:
Mrugesh Mohapatra
2020-03-17 21:16:08 +05:30
committed by mrugesh
parent 4ee032d664
commit c30f0dbf0d
4 changed files with 37 additions and 7 deletions

View File

@ -14,8 +14,11 @@ import { stripePublicKey } from '../../../../config/env.json';
import { stripeScriptLoader } from '../../utils/scriptLoaders'; import { stripeScriptLoader } from '../../utils/scriptLoaders';
import DonateFormChildViewForHOC from './DonateFormChildViewForHOC'; import DonateFormChildViewForHOC from './DonateFormChildViewForHOC';
import DonateCompletion from './DonateCompletion'; import DonateCompletion from './DonateCompletion';
import PaypalButton from './PaypalButton';
import { userSelector } from '../../redux'; import { userSelector } from '../../redux';
import { Spacer } from '../../components/helpers';
import './Donation.css'; import './Donation.css';
const propTypes = { const propTypes = {
@ -126,7 +129,18 @@ class MinimalDonateForm extends Component {
return ( return (
<Row> <Row>
<Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}>
<PaypalButton
handleProcessing={handleProcessing}
onDonationStateChange={this.onDonationStateChange}
/>
</Col>
<Col sm={10} smOffset={1} xs={12}> <Col sm={10} smOffset={1} xs={12}>
<Spacer />
<b>Or donate with a credit card:</b>
<Spacer />
</Col>
<Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}>
<StripeProvider stripe={stripe}> <StripeProvider stripe={stripe}>
<Elements> <Elements>
<DonateFormChildViewForHOC <DonateFormChildViewForHOC

View File

@ -16,13 +16,13 @@ export class PaypalButton extends Component {
constructor(...props) { constructor(...props) {
super(...props); super(...props);
this.state = { this.state = {
planId: durationPlans.month['500'].planId planId: durationPlans.year['6000'].planId
}; };
this.handleApproval = this.handleApproval.bind(this); this.handleApproval = this.handleApproval.bind(this);
} }
handleApproval = data => { handleApproval = data => {
this.props.handleProcessing('month', 500, 'Paypal payment submission'); this.props.handleProcessing('year', 6000, 'Paypal payment submission');
this.props.onDonationStateChange(false, true, ''); this.props.onDonationStateChange(false, true, '');
verifySubscriptionPaypal(data) verifySubscriptionPaypal(data)
.then(response => { .then(response => {

View File

@ -12,6 +12,7 @@ import DonateForm from '../components/Donation/DonateForm';
import DonateText from '../components/Donation/DonateText'; import DonateText from '../components/Donation/DonateText';
import { signInLoadingSelector, userSelector, executeGA } from '../redux'; import { signInLoadingSelector, userSelector, executeGA } from '../redux';
import { stripeScriptLoader } from '../utils/scriptLoaders'; import { stripeScriptLoader } from '../utils/scriptLoaders';
import { PaypalButton } from '../components/Donation/PaypalButton';
const propTypes = { const propTypes = {
executeGA: PropTypes.func, executeGA: PropTypes.func,
@ -131,6 +132,14 @@ export class DonatePage extends Component {
handleProcessing={this.handleProcessing} handleProcessing={this.handleProcessing}
stripe={stripe} stripe={stripe}
/> />
<Spacer size={2} />
<Row>
<Col sm={10} smOffset={1} xs={12}>
<b>Or donate with:</b>
<Spacer />
<PaypalButton />
</Col>
</Row>
</Col> </Col>
<Col md={6}> <Col md={6}>
<DonateText /> <DonateText />

View File

@ -1,4 +1,5 @@
require('dotenv').config(); const path = require('path');
require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
// Configuration for client side // Configuration for client side
const durationsConfig = { const durationsConfig = {
@ -56,14 +57,20 @@ const paypalConfigTypes = {
durationPlans: { durationPlans: {
month: { month: {
'500': { '500': {
planId: 'P-146249205C631091BLZKRHGA' planId: 'P-37N14480BW163382FLZYPVMA'
}
},
year: {
'6000': {
planId: 'P-0UY77185EM3077131LZYP6VY'
} }
} }
} }
} }
}; };
const paypalConfig = process.env.DEPLOYMENT_ENV const paypalConfig =
process.env.DEPLOYMENT_ENV && process.env.DEPLOYMENT_ENV === 'live'
? paypalConfigTypes['live'] ? paypalConfigTypes['live']
: paypalConfigTypes['staging']; : paypalConfigTypes['staging'];