mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-25 22:37:18 +10:00
Merge pull request #1098 from sharetribe/fix-charge-disabled-error
Fix charge disabled error
This commit is contained in:
commit
236115071e
4 changed files with 37 additions and 0 deletions
|
|
@ -14,6 +14,9 @@ way to update this template, but currently, we follow a pattern:
|
|||
|
||||
## Upcoming version 2019-XX-XX
|
||||
|
||||
- [fix] missing provider information (like SSN in US), might cause payment to fail on
|
||||
`CheckoutPage`. This improves related error message.
|
||||
[#10967](https://github.com/sharetribe/flex-template-web/pull/1097)
|
||||
- [fix] Menu needs to wait for mounting to calculate dimensions properly.
|
||||
[#1096](https://github.com/sharetribe/flex-template-web/pull/1096)
|
||||
- [fix] Renamed Component.example.css files to ComponentExample.css to fix bug introduced in one of
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
isTransactionInitiateListingNotFoundError,
|
||||
isTransactionInitiateMissingStripeAccountError,
|
||||
isTransactionInitiateBookingTimeNotAvailableError,
|
||||
isTransactionChargeDisabledError,
|
||||
isTransactionZeroPaymentError,
|
||||
transactionInitiateOrderStripeErrors,
|
||||
} from '../../util/errors';
|
||||
|
|
@ -304,6 +305,7 @@ export class CheckoutPageComponent extends Component {
|
|||
);
|
||||
|
||||
const isAmountTooLowError = isTransactionInitiateAmountTooLowError(initiateOrderError);
|
||||
const isChargeDisabledError = isTransactionChargeDisabledError(initiateOrderError);
|
||||
const isBookingTimeNotAvailableError = isTransactionInitiateBookingTimeNotAvailableError(
|
||||
initiateOrderError
|
||||
);
|
||||
|
|
@ -323,6 +325,12 @@ export class CheckoutPageComponent extends Component {
|
|||
<FormattedMessage id="CheckoutPage.bookingTimeNotAvailableMessage" />
|
||||
</p>
|
||||
);
|
||||
} else if (!listingNotFound && isChargeDisabledError) {
|
||||
initiateOrderErrorMessage = (
|
||||
<p className={css.orderError}>
|
||||
<FormattedMessage id="CheckoutPage.chargeDisabledMessage" />
|
||||
</p>
|
||||
);
|
||||
} else if (!listingNotFound && stripeErrors && stripeErrors.length > 0) {
|
||||
// NOTE: Error messages from Stripes are not part of translations.
|
||||
// By default they are in English.
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@
|
|||
"BookingPanel.perUnit": "per unit",
|
||||
"BookingPanel.subTitleClosedListing": "Sorry, this listing has been closed.",
|
||||
"CheckoutPage.bookingTimeNotAvailableMessage": "Unfortunately, the requested time is already booked.",
|
||||
"CheckoutPage.chargeDisabledMessage": "This provider's payout information is incomplete so this listing cannot be booked. Please contact the administrator.",
|
||||
"CheckoutPage.errorlistingLinkText": "the sauna page",
|
||||
"CheckoutPage.goToLandingPage": "Go to homepage",
|
||||
"CheckoutPage.hostedBy": "Hosted by {name}",
|
||||
|
|
|
|||
|
|
@ -140,6 +140,31 @@ export const isTransactionInitiateAmountTooLowError = error => {
|
|||
return isZeroPayment || tooLowAmount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given API error (from `sdk.transaction.initiate()`) is
|
||||
* due to the transaction charge creation disabled by Stripe.
|
||||
*/
|
||||
export const isTransactionChargeDisabledError = error => {
|
||||
const chargeCreationDisabled = errorAPIErrors(error).some(apiError => {
|
||||
const isPaymentFailedError =
|
||||
apiError.status === 402 && apiError.code === ERROR_CODE_PAYMENT_FAILED;
|
||||
|
||||
let isChargeCreationDisabled = false;
|
||||
try {
|
||||
const msg = apiError.meta.stripeMessage;
|
||||
isChargeCreationDisabled =
|
||||
msg.startsWith('Your account cannot currently make charges.') ||
|
||||
msg.match(/verification.disabled_reason/);
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
return isPaymentFailedError && isChargeCreationDisabled;
|
||||
});
|
||||
|
||||
return chargeCreationDisabled;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given API error (from `sdk.transaction.initiate()`) is
|
||||
* due to other error in Stripe.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue