Skip to content

Commit

Permalink
Added paypal redirect feature triggered buy the frontastic checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
bdizha committed Jul 5, 2024
1 parent 5a61584 commit ace9528
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/payment/checkout/Checkout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,17 @@ class Checkout extends React.Component {
submitting,
orderType,
stripe,
isPaypalRedirect,
} = this.props;
const submissionDisabled = loading || isBasketProcessing;
const isBulkOrder = orderType === ORDER_TYPES.BULK_ENROLLMENT;
const isQuantityUpdating = isBasketProcessing && loaded;

if (!submissionDisabled && isPaypalRedirect) {
// auto submit to paypal since the paypal redirect flag is set in the incoming rquiest
this.handleSubmitPayPal();
}

// Stripe element config
// TODO: Move these to a better home
const options = {
Expand Down Expand Up @@ -314,6 +320,7 @@ Checkout.propTypes = {
enableStripePaymentProcessor: PropTypes.bool,
stripe: PropTypes.object, // eslint-disable-line react/forbid-prop-types
clientSecretId: PropTypes.string,
isPaypalRedirect: PropTypes.bool,
};

Checkout.defaultProps = {
Expand All @@ -327,6 +334,7 @@ Checkout.defaultProps = {
enableStripePaymentProcessor: false,
stripe: null,
clientSecretId: null,
isPaypalRedirect: false,
};

const mapStateToProps = (state) => ({
Expand Down
3 changes: 3 additions & 0 deletions src/payment/data/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ export const paymentSelector = createSelector(
&& queryParams.coupon_redeem_redirect == 1; // eslint-disable-line eqeqeq
const isPaymentRedirect = !!queryParams
&& Boolean(queryParams.payment_intent); // Only klarna has redirect_status on URL
const isPaypalRedirect = !!queryParams
&& queryParams.paypal_redirect == 1; // eslint-disable-line eqeqeq
return {
...basket,
isCouponRedeemRedirect,
isPaymentRedirect,
isPaypalRedirect,
isEmpty:
basket.loaded && !basket.redirect && (!basket.products || basket.products.length === 0),
isRedirect:
Expand Down

0 comments on commit ace9528

Please sign in to comment.