Skip to content

Commit

Permalink
Merge pull request #1114 from sharetribe/fix-updating-cardtoken
Browse files Browse the repository at this point in the history
Clear cardtoken before redirecting
  • Loading branch information
OtterleyW authored Jun 11, 2019
2 parents b5e8bd3 + 8973b5c commit bc94c96
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .auditrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ exports.exceptions = [
// Add exceptions to audit script:
// // Severity: low, lodash (< 4.17.5), used heavily in our CRA fork
// "https://npmjs.com/advisories/577",
// Temporarily skip warning about axios until SDK is updated
"https://npmjs.com/advisories/880",
];
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2019-XX-XX

- [fix] `stripeCardToken` didn't update when the user tried to book the same listing for a second
time. This update will clear the old cardtoken from Redux store when redirecting to
`TransactionPage`. [#1114](https://github.com/sharetribe/flex-template-web/pull/1114)
- [fix] In `LineItemProviderCommissionMaybe.js` file check that `providerCommissionLineItem` exists.
In default transaction process the `providerCommissionLineItem` can be expected to be there but if
the process is using only customer commission there will be error.
[#1112](https://github.com/sharetribe/flex-template-web/pull/1112)
- [security] Update Flex SDK version to v1.4.1. The new version updates depencencies with security issues
[#1111](https://github.com/sharetribe/flex-template-web/pull/1111)
- [security] Update Flex SDK version to v1.4.1. The new version updates depencencies with security
issues [#1111](https://github.com/sharetribe/flex-template-web/pull/1111)
- [fix] Fix a bug in showing review links. Because of the bug the second review link was not visible
in `ActivityFeed`. [#1106](https://github.com/sharetribe/flex-template-web/pull/1106)
- [fix] Emptying the priceFilter component in the searchPage caused a page breaking error.
Expand Down
5 changes: 4 additions & 1 deletion src/containers/CheckoutPage/CheckoutPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
setInitialValues,
speculateTransaction,
} from './CheckoutPage.duck';
import { createStripePaymentToken } from '../../ducks/stripe.duck.js';
import { createStripePaymentToken, clearStripePaymentToken } from '../../ducks/stripe.duck.js';
import config from '../../config';

import { storeData, storedData, clearData } from './CheckoutPageSessionHelpers';
Expand Down Expand Up @@ -152,6 +152,7 @@ export class CheckoutPageComponent extends Component {
sendOrderRequest,
sendOrderRequestAfterEnquiry,
speculatedTransaction,
onClearStripePaymentToken,
dispatch,
} = this.props;

Expand Down Expand Up @@ -190,6 +191,7 @@ export class CheckoutPageComponent extends Component {
const orderDetailsPath = pathByRouteName('OrderDetailsPage', routes, {
id: orderId.uuid,
});
onClearStripePaymentToken();
clearData(STORAGE_KEY);
history.push(orderDetailsPath);
})
Expand Down Expand Up @@ -606,6 +608,7 @@ const mapDispatchToProps = dispatch => ({
dispatch(initiateOrderAfterEnquiry(transactionId, params)),
fetchSpeculatedTransaction: params => dispatch(speculateTransaction(params)),
onCreateStripePaymentToken: params => dispatch(createStripePaymentToken(params)),
onClearStripePaymentToken: () => dispatch(clearStripePaymentToken()),
});

const CheckoutPage = compose(
Expand Down
12 changes: 12 additions & 0 deletions src/ducks/stripe.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const CREATE_PAYMENT_TOKEN_REQUEST = 'app/stripe/CREATE_PAYMENT_TOKEN_REQ
export const CREATE_PAYMENT_TOKEN_SUCCESS = 'app/stripe/CREATE_PAYMENT_TOKEN_SUCCESS';
export const CREATE_PAYMENT_TOKEN_ERROR = 'app/stripe/CREATE_PAYMENT_TOKEN_ERROR';

export const CLEAR_PAYMENT_TOKEN = 'app/stripe/CLEAR_PAYMENT_TOKEN';

// ================ Reducer ================ //

const initialState = {
Expand Down Expand Up @@ -112,6 +114,8 @@ export default function reducer(state = initialState, action = {}) {
case CREATE_PAYMENT_TOKEN_ERROR:
console.error(payload);
return { ...state, stripePaymentTokenError: payload, stripePaymentTokenInProgress: false };
case CLEAR_PAYMENT_TOKEN:
return { ...state, stripePaymentToken: null };

default:
return state;
Expand Down Expand Up @@ -184,6 +188,10 @@ export const createPaymentTokenError = payload => ({
error: true,
});

export const clearPaymentToken = () => ({
type: CLEAR_PAYMENT_TOKEN,
});

// ================ Thunks ================ //

// Util: rename address fields to match Stripe API specifications
Expand Down Expand Up @@ -515,3 +523,7 @@ export const createStripePaymentToken = params => dispatch => {
throw e;
});
};

export const clearStripePaymentToken = () => dispatch => {
dispatch(clearPaymentToken());
};

0 comments on commit bc94c96

Please sign in to comment.