Skip to content

Commit

Permalink
fix(failed-order): show proper error flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoB committed Apr 16, 2021
1 parent 116b03d commit a3f4c46
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,6 @@ export default ({
AuthUrlCheck,
data.paymentId
)
if (order.state === 'FAILED') {
yield put(
actions.form.stopSubmit('brokerageTx', {
_error: 'Bank authroization failed, please try again.'
})
)
yield put(
actions.components.brokerage.setDWStep({
dwStep: BankDWStepType.ENTER_AMOUNT
})
)
}
if (
order.extraAttributes &&
'authorisationUrl' in order.extraAttributes &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,3 @@ export const FETCH_LIMITS_SUCCESS = '@EVENT.FETCH_LIMITS_SUCCESS'

export const UPDATE_SDD_TRANSACTION_FINISHED =
'@EVENT.UPDATE_SDD_TRANSACTION_FINISHED'

export const UPDATE_SB_ORDER = '@EVENT.UPDATE_SB_ORDER'
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,3 @@ export const fetchLimitsSuccess = (
export const updateSddTransactionFinished = () => ({
type: AT.UPDATE_SDD_TRANSACTION_FINISHED
})

export const updateSbOrder = (order: SBOrderType) => ({
type: AT.UPDATE_SB_ORDER,
payload: {
order
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,6 @@ export function simpleBuyReducer(
sddTransactionFinished: true
}
}
case AT.UPDATE_SB_ORDER: {
return {
...state,
order: action.payload.order
}
}
case AT.SET_FIAT_CURRENCY:
return {
...state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ export default ({
api.getSBOrder,
orderId
)

if (order.attributes?.authorisationUrl || order.state === 'FAILED') {
return order
} else {
Expand All @@ -454,8 +453,7 @@ export default ({
const confirmSBOrder = function * (
payload: ReturnType<typeof A.confirmSBOrder>
) {
const { paymentMethodId } = payload
let { order } = payload
const { order, paymentMethodId } = payload
try {
if (!order) throw new Error(NO_ORDER_EXISTS)
yield put(actions.form.startSubmit('sbCheckoutConfirm'))
Expand Down Expand Up @@ -508,22 +506,8 @@ export default ({
OrderConfirmCheck,
confirmedOrder.id
)
yield put(A.updateSbOrder(order))
}
order = S.getSBOrder(yield select()) as SBOrderType
yield put(actions.form.stopSubmit('sbCheckoutConfirm'))
// If payment method is invalid, backend will send back
// A failed trade in ~30 seconds rather than having
// payment method faill at a later step
if (order.state === 'FAILED') {
yield put(A.setStep({ step: 'CHECKOUT_CONFIRM', order }))
yield put(actions.form.startSubmit('sbCheckoutConfirm'))
return yield put(
actions.form.stopSubmit('sbCheckoutConfirm', {
_error: 'Order failed. Please try again.'
})
)
}
if (order.paymentType === 'BANK_TRANSFER') {
yield put(A.setStep({ step: 'ORDER_SUMMARY', order: confirmedOrder }))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,6 @@ interface FetchLimitsSuccess {
type: typeof AT.FETCH_LIMITS_SUCCESS
}

interface UpdateSbOrder {
payload: {
order: SBOrderType
}
type: typeof AT.UPDATE_SB_ORDER
}
interface UpdateSddTransactionFinished {
type: typeof AT.UPDATE_SDD_TRANSACTION_FINISHED
}
Expand Down Expand Up @@ -561,4 +555,3 @@ export type SimpleBuyActionTypes =
| UpdatePaymentLoadingAction
| UpdatePaymentSuccessAction
| UpdateSddTransactionFinished
| UpdateSbOrder

0 comments on commit a3f4c46

Please sign in to comment.