fix(client): replace Stripe with PayPal (#41924)
* feat: remove stripe payment option from client * feat: remove stripe completely * fix: remove last Stripe remnants Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -1,12 +1,4 @@
|
||||
import {
|
||||
put,
|
||||
select,
|
||||
takeEvery,
|
||||
takeLeading,
|
||||
delay,
|
||||
call,
|
||||
take
|
||||
} from 'redux-saga/effects';
|
||||
import { put, select, takeEvery, delay, call, take } from 'redux-saga/effects';
|
||||
|
||||
import {
|
||||
openDonationModal,
|
||||
@@ -16,16 +8,10 @@ import {
|
||||
recentlyClaimedBlockSelector,
|
||||
addDonationComplete,
|
||||
addDonationError,
|
||||
postChargeStripeComplete,
|
||||
postChargeStripeError,
|
||||
types as appTypes
|
||||
} from './';
|
||||
|
||||
import {
|
||||
addDonation,
|
||||
postChargeStripe,
|
||||
postCreateStripeSession
|
||||
} from '../utils/ajax';
|
||||
import { addDonation } from '../utils/ajax';
|
||||
|
||||
const defaultDonationError = `Something is not right. Please contact donors@freecodecamp.org`;
|
||||
|
||||
@@ -59,42 +45,9 @@ function* addDonationSaga({ payload }) {
|
||||
}
|
||||
}
|
||||
|
||||
function* createStripeSessionSaga({ payload: { stripe, data } }) {
|
||||
try {
|
||||
const session = yield call(postCreateStripeSession, {
|
||||
...data,
|
||||
location: window.location.href
|
||||
});
|
||||
stripe.redirectToCheckout({
|
||||
sessionId: session.data.id
|
||||
});
|
||||
} catch (error) {
|
||||
const err =
|
||||
error.response && error.response.data
|
||||
? error.response.data.message
|
||||
: defaultDonationError;
|
||||
yield put(addDonationError(err));
|
||||
}
|
||||
}
|
||||
|
||||
function* postChargeStripeSaga({ payload }) {
|
||||
try {
|
||||
yield call(postChargeStripe, payload);
|
||||
yield put(postChargeStripeComplete());
|
||||
} catch (error) {
|
||||
const err =
|
||||
error.response && error.response.data
|
||||
? error.response.data.error
|
||||
: defaultDonationError;
|
||||
yield put(postChargeStripeError(err));
|
||||
}
|
||||
}
|
||||
|
||||
export function createDonationSaga(types) {
|
||||
return [
|
||||
takeEvery(types.tryToShowDonationModal, showDonateModalSaga),
|
||||
takeEvery(types.addDonation, addDonationSaga),
|
||||
takeLeading(types.postChargeStripe, postChargeStripeSaga),
|
||||
takeLeading(types.createStripeSession, createStripeSessionSaga)
|
||||
takeEvery(types.addDonation, addDonationSaga)
|
||||
];
|
||||
}
|
||||
|
@@ -82,8 +82,6 @@ export const types = createTypes(
|
||||
'updateDonationFormState',
|
||||
...createAsyncTypes('fetchUser'),
|
||||
...createAsyncTypes('addDonation'),
|
||||
...createAsyncTypes('createStripeSession'),
|
||||
...createAsyncTypes('postChargeStripe'),
|
||||
...createAsyncTypes('fetchProfileForUser'),
|
||||
...createAsyncTypes('acceptTerms'),
|
||||
...createAsyncTypes('showCert'),
|
||||
@@ -152,14 +150,6 @@ export const addDonation = createAction(types.addDonation);
|
||||
export const addDonationComplete = createAction(types.addDonationComplete);
|
||||
export const addDonationError = createAction(types.addDonationError);
|
||||
|
||||
export const createStripeSession = createAction(types.createStripeSession);
|
||||
|
||||
export const postChargeStripe = createAction(types.postChargeStripe);
|
||||
export const postChargeStripeComplete = createAction(
|
||||
types.postChargeStripeComplete
|
||||
);
|
||||
export const postChargeStripeError = createAction(types.postChargeStripeError);
|
||||
|
||||
export const fetchProfileForUser = createAction(types.fetchProfileForUser);
|
||||
export const fetchProfileForUserComplete = createAction(
|
||||
types.fetchProfileForUserComplete
|
||||
@@ -404,10 +394,6 @@ export const reducer = handleActions(
|
||||
...state,
|
||||
donationFormState: { ...state.donationFormState, ...payload }
|
||||
}),
|
||||
[types.createStripeSession]: state => ({
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, redirecting: true }
|
||||
}),
|
||||
[types.addDonation]: state => ({
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, processing: true }
|
||||
@@ -431,29 +417,6 @@ export const reducer = handleActions(
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, error: payload }
|
||||
}),
|
||||
[types.postChargeStripe]: state => ({
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, processing: true }
|
||||
}),
|
||||
[types.postChargeStripeComplete]: state => {
|
||||
const { appUsername } = state;
|
||||
return {
|
||||
...state,
|
||||
user: {
|
||||
...state.user,
|
||||
[appUsername]: {
|
||||
...state.user[appUsername],
|
||||
isDonating: true
|
||||
}
|
||||
},
|
||||
|
||||
donationFormState: { ...defaultDonationFormState, success: true }
|
||||
};
|
||||
},
|
||||
[types.postChargeStripeError]: (state, { payload }) => ({
|
||||
...state,
|
||||
donationFormState: { ...defaultDonationFormState, error: payload }
|
||||
}),
|
||||
[types.fetchUser]: state => ({
|
||||
...state,
|
||||
userFetchState: { ...defaultFetchState }
|
||||
|
Reference in New Issue
Block a user