Order specification

Order contains the information about a customer order, including information about each Line Item.

// An order for service appointments with a merchant.
message Order {
  // ID of this Order, chosen by the booking partner who handles the order
  // (required in CreateOrderResponse and ListOrdersResponse, must not be set in
  // CreateOrderRequest)
  string order_id = 1;
  // Personal information of the user making the order (required)
  UserInformation user_information = 2;
  // Information about payment transactions that relate to the Order.
  // (optional)
  PaymentInformation payment_information = 3;
  // The merchant that all services in this Order belong to.
  string merchant_id = 4;
  // Line items in this order.
  repeated LineItem item = 5;
}
// A single item in an Order--the booking of a single service in a single time
// slot.
message LineItem {
  // ID of the merchant Service. (required)
  string service_id = 1;
  // Start time of the appointment slot in seconds of UTC time since Unix epoch.
  // (required)
  int64 start_sec = 2;
  // Duration of the appointment slot in seconds. (required)
  int64 duration_sec = 3;

  message OrderedTickets {
    string ticket_id = 1;
    int32 count = 2;
  }
  // Number of tickets ordered by Ticket Type.
  repeated OrderedTickets tickets = 4;

  // The price should be updated to the correct value if the line item can be
  // fulfilled but the value from the request has changed. The updated price
  // should align with the enum in the 'warning_reason' field below, otherwise
  // the booking will be considered as failure. (required)
  Price price = 5;

  // Status of the Line Item. (required in CreateOrderResponse and
  // ListOrdersResponse; should not be set in requests)
  BookingStatus status = 6;

  // The user's answers to merchant questions for this services.
  // If there are both service level and per-ticket answers, this message will
  // be ordered with service level answers first and per-ticket answers after.
  // Will not be set in CheckOrderFulfillabilityRequest.
  IntakeFormAnswers intake_form_answers = 7;

  enum WarningReason {
    UNSPECIFIED_WARNING_REASON = 0;
    // This Line Item can be fulfilled and has increased in price.
    PRICE_INCREASE = 1;
    // This Line Item can be fulfilled and has decreased in price.
    PRICE_DECREASE = 2;
  }
  // If the total price is different from the price in the request, please use
  // this field to indicate a price change. The enum has to be aligned with the
  // actual price change, otherwise the booking will be considered as failure.
  WarningReason warning_reason = 8;
}
// User's answers to merchant questions.
message IntakeFormAnswers {
  repeated IntakeFormFieldAnswer answer = 1;
}

message IntakeFormFieldAnswer {
  // This id should be the same as the id of the corresponding question.
  string id = 1;

  // The response given by the user.
  // One string for MULTIPLE_CHOICE, DROPDOWN, SHORT_ANSWER, and PARAGRAPH
  // One string ("true" or "false") for BOOLEAN
  // One or more strings for CHECKBOXES.
  // For MULTIPLE_CHOICE, DROPDOWN or CHECKBOXES, the string would match exactly
  // one of the (possibly localized) strings sent by partner in choice_text in
  // the ServiceIntakeForm.
  // For LOCATION_SEARCH, the response could be:
  //   1. Matches one of the "location_id" in the "location" field in the
  //   service feed.
  //   2. User input answer containing location information that are not
  //   provided in the feed.
  repeated string response = 2;
}
// Status data that conveys why creating an order fails.
// OrderFailure is intended to primarily capture business logic errors.
message OrderFailure {
  enum Cause {
    // Default value: Don't use; amounts to an "unknown error"
    CAUSE_UNSPECIFIED = 0;
    // The order is no longer fulfillable.
    ORDER_UNFULFILLABLE = 1;
    // 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 = 2;
    // An error was encountered while processing the payment because the
    // provided credit card was declined.
    PAYMENT_ERROR_CARD_DECLINED = 3;
    // An error was encountered while processing the payment for this order.
    // 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 = 4;
    // The fee total in the request is incorrect or not up-to-date.
    INCORRECT_FEE_TOTAL = 5;
    // Set when payment is rejected because you are requesting that the
    // transaction be tried again, but this time after undergoing 3DS1
    // challenge/response.  Note that the current transaction's failure state
    // will stay failed.  The retry will be completely separate.
    //
    // When this is the failure reason, payment_failure.3DS1_parameters
    // MUST be set.  If it is not, then the current cause will be treated as
    // if it were AGGREGATOR_PAYMENT_ERROR.
    PAYMENT_REQUIRES_3DS1 = 6;
  }
  // The reason why the order failed. (required)
  Cause cause = 1;

  // (required only if cause is ORDER_UNFULFILLABLE)
  OrderFulfillability fulfillability = 2;

  // (required only if cause is PAYMENT_ERROR_CARD_TYPE_REJECTED)
  CreditCardType rejected_card_type = 3;

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

  // Information about payment failures.
  message PaymentFailureInformation {
    // Parameters requesting that RwG perform a 3DS1 challenge.
    //
    // The parameters are set by EMVCo's description of the 3DS1 protocol.
    message ThreeDS1Parameters {
      // The URL from which to load a form to present to the User for
      // authentication.
      string acs_url = 1;
      // A PaymentAuthentication Request.  To be posted to the ACSUrl form if
      // supplied.
      string pa_req = 2;
      // An identifier used by the ACS provider.  To be posted to the ACSUrl
      // form if supplied.
      string transaction_id = 3;
      // Merchant data.  To be posted to the ACSUrl form if supplied.
      string md_merchant_data = 4;
    }

    // Parameters used by a RwG aggregator to initiate a 3DS1 authentication
    // protocol with the user.  Will be ignored unless BookingFailure.cause
    // is set to PAYMENT_REQUIRES_3DS1.
    ThreeDS1Parameters threeds1_parameters = 5;
  }

  // Information about payment failures.
  PaymentFailureInformation payment_failure = 5;
}