fix(donate): allow unauthenticated donations for year-end

This commit is contained in:
Mrugesh Mohapatra
2019-12-18 04:15:55 +05:30
committed by mrugesh
parent fc25c281e4
commit 663f726c4e
4 changed files with 112 additions and 7 deletions

View File

@@ -29,7 +29,8 @@ const propTypes = {
stripe: PropTypes.shape({
createToken: PropTypes.func.isRequired
}),
theme: PropTypes.string
theme: PropTypes.string,
yearEndGift: PropTypes.bool
};
const initialState = {
donationState: {
@@ -117,6 +118,7 @@ class DonateFormChildViewForHOC extends Component {
postDonation(token) {
const { donationAmount: amount, donationDuration: duration } = this.state;
const { yearEndGift } = this.props;
this.setState(state => ({
...state,
donationState: {
@@ -134,7 +136,7 @@ class DonateFormChildViewForHOC extends Component {
this.props.showCloseBtn();
}
return postChargeStripe({
return postChargeStripe(yearEndGift, {
token,
amount,
duration

View File

@@ -141,6 +141,7 @@ class YearEndDonationForm extends Component {
donationAmount={donationAmount}
donationDuration={donationDuration}
getDonationButtonLabel={this.getDonationButtonLabel}
yearEndGift={true}
/>
</Elements>
</StripeProvider>

View File

@@ -50,8 +50,10 @@ export function getArticleById(shortId) {
}
/** POST **/
export function postChargeStripe(body) {
return post(`/donate/charge-stripe`, body);
export function postChargeStripe(yearEndGift, body) {
return yearEndGift
? postUnauthenticated('/donate/charge-stripe-year-end', body)
: post('/donate/charge-stripe', body);
}
export function postCreateHmacHash(body) {