Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 3x 3x 28x 1x 4x 1x 22x 9x 13x 3x 2x 11x 2x 9x 3x 15x 1x 14x | import { TranslationData } from '@bigcommerce/checkout-sdk'; import { includes } from 'lodash'; export default function mapSubmitOrderErrorMessage( error: any, translate: (key: string, data?: TranslationData) => string, shouldLocalise: boolean ): string { switch (error.type) { case 'payment_cancelled': return translate('payment.payment_cancelled'); case 'payment_method_invalid': return translate('payment.payment_method_disabled_error'); case 'cart_changed': return translate('shipping.cart_change_error'); default: if (includes([ 'order_could_not_be_finalized_error', 'provider_fatal_error', 'payment_invalid', 'provider_error', 'provider_widget_error', 'user_payment_error', ], error.body && error.body.type)) { return translate('payment.payment_method_error', { message: error.message }); } if (shouldLocalise && error.body && error.body.errors && error.body.errors.length) { const messages = error.body.errors.map((err: { code: any }) => translate(`payment.errors.${err.code}`)); return messages.join(' '); } if (error.message) { return error.message; } return error.type === 'unrecoverable' ? translate('common.unavailable_error') : translate('payment.place_order_error'); } } export function mapSubmitOrderErrorTitle( error: any, translate: (key: string, data?: TranslationData) => string ): string { if (error.type === 'unrecoverable') { return translate('common.unavailable_heading'); } return translate('common.error_heading'); } |