feat: add paypal donation to modals and certificates

This commit is contained in:
Mrugesh Mohapatra
2020-03-19 18:48:58 +05:30
committed by mrugesh
parent c30f0dbf0d
commit 585527d145
9 changed files with 35 additions and 60 deletions

View File

@ -97,7 +97,7 @@ export function createDonationObj(body) {
const { const {
resource: { resource: {
id, id,
start_time, status_update_time,
subscriber: { email_address } = { subscriber: { email_address } = {
email_address: null email_address: null
} }
@ -111,7 +111,7 @@ export function createDonationObj(body) {
provider: 'paypal', provider: 'paypal',
subscriptionId: id, subscriptionId: id,
customerId: email_address, customerId: email_address,
startDate: new Date(start_time).toISOString() startDate: new Date(status_update_time).toISOString()
}; };
return donation; return donation;
} }

View File

@ -211,7 +211,7 @@ class ShowCertification extends Component {
<Grid className='donation-section'> <Grid className='donation-section'>
{!isDonationSubmitted && ( {!isDonationSubmitted && (
<Row> <Row>
<Col sm={10} smOffset={1} xs={12}> <Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}>
<p> <p>
Only you can see this message. Congratulations on earning this Only you can see this message. Congratulations on earning this
certification. Its no easy task. Running freeCodeCamp isnt certification. Its no easy task. Running freeCodeCamp isnt

View File

@ -40,10 +40,6 @@ function DonateCompletion({ processing, reset, success, error = null }) {
Your donations will support free technology education for people Your donations will support free technology education for people
all over the world. all over the world.
</p> </p>
<p>
You can update your supporter status at any time from your
settings page.
</p>
</div> </div>
)} )}
{error && <p>{error}</p>} {error && <p>{error}</p>}

View File

@ -78,7 +78,6 @@ class DonateForm extends Component {
this.getDonationButtonLabel = this.getDonationButtonLabel.bind(this); this.getDonationButtonLabel = this.getDonationButtonLabel.bind(this);
this.handleSelectAmount = this.handleSelectAmount.bind(this); this.handleSelectAmount = this.handleSelectAmount.bind(this);
this.handleSelectDuration = this.handleSelectDuration.bind(this); this.handleSelectDuration = this.handleSelectDuration.bind(this);
this.handleSelectPaymentType = this.handleSelectPaymentType.bind(this);
this.hideAmountOptionsCB = this.hideAmountOptionsCB.bind(this); this.hideAmountOptionsCB = this.hideAmountOptionsCB.bind(this);
} }
@ -120,12 +119,6 @@ class DonateForm extends Component {
this.setState({ donationAmount }); this.setState({ donationAmount });
} }
handleSelectPaymentType(e) {
this.setState({
paymentType: e.currentTarget.value
});
}
renderAmountButtons(duration) { renderAmountButtons(duration) {
return this.amounts[duration].map(amount => ( return this.amounts[duration].map(amount => (
<ToggleButton <ToggleButton
@ -193,10 +186,9 @@ class DonateForm extends Component {
renderDonationOptions() { renderDonationOptions() {
const { stripe, handleProcessing } = this.props; const { stripe, handleProcessing } = this.props;
const { donationAmount, donationDuration, paymentType } = this.state; const { donationAmount, donationDuration } = this.state;
return ( return (
<div> <div>
{paymentType === 'Card' ? (
<StripeProvider stripe={stripe}> <StripeProvider stripe={stripe}>
<Elements> <Elements>
<DonateFormChildViewForHOC <DonateFormChildViewForHOC
@ -209,12 +201,7 @@ class DonateForm extends Component {
/> />
</Elements> </Elements>
</StripeProvider> </StripeProvider>
) : ( <Spacer size={2} />
<p>
PayPal is currently unavailable. Please use a Credit/Debit card
instead.
</p>
)}
</div> </div>
); );
} }

View File

@ -90,12 +90,7 @@ function DonateModal({
}); });
} }
const donationText = ( const donationText = <b>Become an annual supporter of our nonprofit.</b>;
<b>
Become a $5 / month supporter and help us create even more learning
resources for you and your family.
</b>
);
const blockDonationText = ( const blockDonationText = (
<div className='block-modal-text'> <div className='block-modal-text'>
<div className='donation-icon-container'> <div className='donation-icon-container'>
@ -105,6 +100,7 @@ function DonateModal({
{!closeLabel && ( {!closeLabel && (
<Col sm={10} smOffset={1} xs={12}> <Col sm={10} smOffset={1} xs={12}>
<b>Nicely done. You just completed {blockNameify(block)}. </b> <b>Nicely done. You just completed {blockNameify(block)}. </b>
<br />
{donationText} {donationText}
</Col> </Col>
)} )}

View File

@ -130,17 +130,18 @@ class MinimalDonateForm extends Component {
return ( return (
<Row> <Row>
<Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}> <Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}>
<Spacer />
<b>Confirm your donation of $60 / year with PayPal:</b>
<Spacer />
<PaypalButton <PaypalButton
handleProcessing={handleProcessing} handleProcessing={handleProcessing}
onDonationStateChange={this.onDonationStateChange} onDonationStateChange={this.onDonationStateChange}
/> />
</Col> </Col>
<Col sm={10} smOffset={1} xs={12}> <Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}>
<Spacer /> <Spacer />
<b>Or donate with a credit card:</b> <b>Or donate with a credit card:</b>
<Spacer /> <Spacer />
</Col>
<Col lg={8} lgOffset={2} sm={10} smOffset={1} xs={12}>
<StripeProvider stripe={stripe}> <StripeProvider stripe={stripe}>
<Elements> <Elements>
<DonateFormChildViewForHOC <DonateFormChildViewForHOC
@ -148,7 +149,7 @@ class MinimalDonateForm extends Component {
donationAmount={donationAmount} donationAmount={donationAmount}
donationDuration={donationDuration} donationDuration={donationDuration}
getDonationButtonLabel={() => getDonationButtonLabel={() =>
`Confirm your donation of $5 / month` `Confirm your donation of $60 / year`
} }
handleProcessing={handleProcessing} handleProcessing={handleProcessing}
/> />

View File

@ -12,7 +12,6 @@ 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,
@ -132,14 +131,6 @@ 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

@ -181,6 +181,12 @@ export const shouldRequestDonationSelector = state => {
const isDonating = isDonatingSelector(state); const isDonating = isDonatingSelector(state);
const canRequestBlockDonation = canRequestBlockDonationSelector(state); const canRequestBlockDonation = canRequestBlockDonationSelector(state);
const debugModal = localStorage.getItem('DEBUG_DONATE_MODAL', false);
console.log(debugModal);
if (debugModal === 'yes-please') {
return true;
}
// don't request donation if already donating // don't request donation if already donating
if (isDonating) return false; if (isDonating) return false;

View File

@ -8,24 +8,22 @@ const durationsConfig = {
onetime: 'one-time' onetime: 'one-time'
}; };
const amountsConfig = { const amountsConfig = {
year: [100000, 25000, 3500], year: [100000, 25000, 6000],
month: [5000, 3500, 500], month: [5000, 3500, 500],
onetime: [100000, 25000, 3500] onetime: [100000, 25000, 3500]
}; };
const defaultAmount = { const defaultAmount = {
year: 25000, year: 6000,
month: 3500, month: 3500,
onetime: 25000 onetime: 25000
}; };
const defaultStateConfig = { const defaultStateConfig = {
donationAmount: defaultAmount['month'], donationAmount: defaultAmount['month'],
donationDuration: 'month', donationDuration: 'month'
paymentType: 'Card'
}; };
const modalDefaultStateConfig = { const modalDefaultStateConfig = {
donationAmount: 500, donationAmount: 6000,
donationDuration: 'month', donationDuration: 'year'
paymentType: 'Card'
}; };
// Configuration for server side // Configuration for server side