Booking failure specification

Booking failure can happen at the stage of (1) creating a Lease, or (2) creating or updating a Booking.

// Status data that conveys why (1) creating a lease or (2) creating or updating
// a booking fails.
// BookingFailure is intended to primarily capture business logic errors.
message BookingFailure {
  enum Cause {
    // Default value: Don't use; amounts to an "unknown error"
    CAUSE_UNSPECIFIED = 0;
    // The referenced availability slot is not available any longer.
    SLOT_UNAVAILABLE = 1;
    // The user has already booked an appointment for the referenced
    // availability slot.
    SLOT_ALREADY_BOOKED_BY_USER = 2;
    // The lease (if provided) has expired and cannot be used any longer to
    // complete the requested booking.
    LEASE_EXPIRED = 3;
    // The requested cancellation cannot be performed at the current time due
    // to time restrictions in the merchant's cancellation policy.
    OUTSIDE_CANCELLATION_WINDOW = 4;
    // An error was encountered while processing the payment because the
    // provided credit card type was not accepted by the merchant. The credit
    // card type must be supplied in rejected_card_type.
    PAYMENT_ERROR_CARD_TYPE_REJECTED = 5;
    // An error was encountered while processing the payment because the
    // provided credit card was declined.
    PAYMENT_ERROR_CARD_DECLINED = 6;
    // An error was encountered with the pack/membership used to pay for the
    // booking. There could be no valid uses left, it could have expired, etc.
    PAYMENT_OPTION_NOT_VALID = 7;
    // An error was encountered while processing the payment for this booking.
    // Use this value to indicate a general payment related error, only if the
    // error does not match to a specific payment error above.
    PAYMENT_ERROR = 8;
    // User cannot use the given payment option (e.g. user trying to use a
    // first time price for the second time).
    USER_CANNOT_USE_PAYMENT_OPTION = 9;
    // A booking that the user tried to cancel has already been cancelled.
    BOOKING_ALREADY_CANCELLED = 10;
    // A booking that the user tried to cancel is not cancellable.
    BOOKING_NOT_CANCELLABLE = 11;
    // User has an existing reservation too close to this time.
    OVERLAPPING_RESERVATION = 12;
    // Booking failed due to the user being over the aggregator's per-user
    // bookings limit.
    USER_OVER_BOOKING_LIMIT = 13;
  }
  // The reason why the booking failed. (required)
  Cause cause = 1;

  // Set if cause is PAYMENT_ERROR_CARD_TYPE_REJECTED to indicate the type of
  // credit card that was rejected.
  enum CreditCardType {
    // Default value. Used if credit card type does not match to one below.
    CREDIT_CARD_TYPE_UNSPECIFIED = 0;
    VISA = 1;
    MASTERCARD = 2;
    AMERICAN_EXPRESS = 3;
    DISCOVER = 4;
    JCB = 5;
  }
  // (required only if cause is PAYMENT_ERROR_CARD_TYPE_REJECTED)
  CreditCardType rejected_card_type = 2;

  // This optional field is used for the partner to include additional
  // information for debugging purpose only. (optional)
  string description = 3;
}