diff --git a/src/containers/CheckoutPage/CheckoutPage.js b/src/containers/CheckoutPage/CheckoutPage.js index 9d369754..c2e5a26d 100644 --- a/src/containers/CheckoutPage/CheckoutPage.js +++ b/src/containers/CheckoutPage/CheckoutPage.js @@ -13,6 +13,7 @@ import { createSlug } from '../../util/urlHelpers'; import { isTransactionInitiateAmountTooLowError, isTransactionInitiateListingNotFoundError, + isTransactionInitiateMissingStripeAccountError, } from '../../util/errors'; import { AvatarMedium, @@ -225,7 +226,8 @@ export class CheckoutPageComponent extends Component { currentUser && hasRequiredData && !listingNotFound && - !initiateOrderError + !initiateOrderError && + !speculateTransactionError ); const listingTitle = currentListing.attributes.title; @@ -270,6 +272,21 @@ export class CheckoutPageComponent extends Component {

) : null; + let speculateErrorMessage = null; + + if (isTransactionInitiateMissingStripeAccountError(speculateTransactionError)) { + speculateErrorMessage = ( +

+ +

+ ); + } else if (speculateTransactionError) { + speculateErrorMessage = ( +

+ +

+ ); + } const topbar = (
@@ -343,6 +360,7 @@ export class CheckoutPageComponent extends Component {
{initiateOrderErrorMessage} {listingNotFoundErrorMessage} + {speculateErrorMessage} {showPaymentForm ? ( { @@ -101,6 +102,14 @@ export const isPasswordRecoveryEmailNotVerifiedError = error => export const isTransactionInitiateListingNotFoundError = error => hasErrorWithCode(error, ERROR_CODE_TRANSACTION_LISTING_NOT_FOUND); +/** + * Check if the given API error (from `sdk.transaction.initiate()` or + * `sdk.transaction.initiateSpeculative()`) is due to missign Stripe + * connection from the listing author. + */ +export const isTransactionInitiateMissingStripeAccountError = error => + hasErrorWithCode(error, ERROR_CODE_MISSING_STRIPE_ACCOUNT); + /** * Check if the given API error (from `sdk.transaction.initiate()`) is * due to the transaction total amount being too low for Stripe. diff --git a/src/util/types.js b/src/util/types.js index 046b8600..438b5b93 100644 --- a/src/util/types.js +++ b/src/util/types.js @@ -394,6 +394,7 @@ export const ERROR_CODE_UPLOAD_OVER_LIMIT = 'request-upload-over-limit'; export const ERROR_CODE_VALIDATION_INVALID_PARAMS = 'validation-invalid-params'; export const ERROR_CODE_NOT_FOUND = 'not-found'; export const ERROR_CODE_FORBIDDEN = 'forbidden'; +export const ERROR_CODE_MISSING_STRIPE_ACCOUNT = 'transaction-missing-stripe-account'; const ERROR_CODES = [ ERROR_CODE_TRANSACTION_LISTING_NOT_FOUND, @@ -409,6 +410,7 @@ const ERROR_CODES = [ ERROR_CODE_VALIDATION_INVALID_PARAMS, ERROR_CODE_NOT_FOUND, ERROR_CODE_FORBIDDEN, + ERROR_CODE_MISSING_STRIPE_ACCOUNT, ]; // API error