CreateBooking 메서드

클라이언트가 예약 생성을 요청합니다. 파트너 백엔드는 요청한 시간대에 대한 예약을 하고, 성공 시 시간대를 반환하거나 로직 오류 (예: 슬롯을 사용할 수 없게 되었거나 결제가 등)를 표시합니다.

비즈니스 로직 오류는 200이 아닌 HTTP 응답 코드를 통해서가 아니라 CreateBookingResponse.booking_failure 필드에서 반환해야 합니다.

요청

CreateBookingRequest

반환값

CreateBookingResponse

// Request to create a Booking for an inventory slot. Consumes the lease if
// provided.
message CreateBookingRequest {
  // The inventory slot that is being requested to make this booking.
  // If lease_ref is provided, slot must match the lease; slot is provided for
  // the partner to verify the lease information.
  // If lease_ref is absent, then create the booking for the slot. (required)
  Slot slot = 1;


  // Personal information of the user making the appointment (required)
  UserInformation user_information = 3;

  // Information about payments. When payment authorizations are handled by
  // Google, if the booking request does not succeed, payment authorizations are
  // automatically canceled. (optional)
  PaymentInformation payment_information = 4;

  // The parameters to be used if the payment is processed by the partner
  // (i.e. payment_information.payment_processed_by is equal to
  // PROCESSED_BY_PARTNER). (optional)
  PaymentProcessingParameters payment_processing_parameters = 5;

  // Idempotency token for CreateBooking requests. (required)
  //
  // This uniquely identifies a booking request. Specifically:
  // - If a booking was already created for a CreateBooking request with this
  // idempotency token, that booking should be returned.
  // - If no booking has been created for a CreateBooking request with this
  // idempotency token, this should be considered to be a request for a new
  // booking, and **no previously-created booking may be returned**.
  //
  // If a partner considers the requested booking to be a duplicate of a
  // previously-created booking, this request should fail with reason
  // BookingFailure.OVERLAPPING_RESERVATION. The partner is responsible for
  // determining whether this duplicates a previous booking, but for example the
  // partner may consider a booking request to be a duplicate if an existing
  // booking has the same party size, time, and email address.
  string idempotency_token = 6;

  // A string from the user which contains any special requests or additional
  // information that they would like to notify the merchant about. (optional)
  string additional_request = 7;

  // Partner provided offer id associated with this slot. (optional)
  //
  // If the offer is no longer available, the booking should not be made, and in
  // response.booking_failure should be set to OFFER_UNAVAILABLE.
  string offer_id = 9;

}

// Response with the created Booking for an inventory slot.
message CreateBookingResponse {
  // The created booking (required)
  Booking booking = 1;

  // The updated user payment option used in this booking.
  // If a new payment option was purchased to pay for the booking, this should
  // be a newly created user payment option.
  // If an already purchased user payment option was used for this booking,
  // this should reflect an updated version of that user payment option.
  // (optional)
  UserPaymentOption user_payment_option = 2;

  // If creating a booking fails, this field should reflect the business logic
  // error (e.g., slot has become unavailable) and all other fields in the
  // CreateBookingResponse message are expected to be unset. (required if
  // failure occurs)
  BookingFailure booking_failure = 3;
}

CreateBooking 샘플

뷰티 샘플 CreateBooking

요청

{
   "idempotency_token" : "11195193155056732768",
   "payment_information" : {
      "prepayment_status" : "PREPAYMENT_NOT_PROVIDED"
   },
   "slot" : {
      "confirmation_mode" : "CONFIRMATION_MODE_SYNCHRONOUS",
      "duration_sec" : "1800",
      "merchant_id" : "1234",
      "resources" : {
         "staff_id" : "82725"
      },
      "service_id" : "5678",
      "start_sec" : "1606509000"
   },
   "user_information" : {
      "email" : "john.smith@gmail.com",
      "family_name" : "Smith",
      "given_name" : "John",
      "telephone" : "+12091111111",
      "user_id" : "1111111111111111111"
   }
}

응답

{
   "booking" : {
      "booking_id" : "890",
      "payment_information" : {
         "prepayment_status" : "PREPAYMENT_NOT_PROVIDED"
      },
      "slot" : {
         "duration_sec" : "1800",
         "merchant_id" : "1234",
         "resources" : {
            "staff_id" : "82725"
         },
         "service_id" : "5678",
         "start_sec" : 1606509000
      },
      "status" : "CONFIRMED",
      "user_information" : {
         "user_id" : "1111111111111111111"
      }
   }
}

피트니스용 CreateBooking 샘플

요청

{
   "idempotency_token" : "13490670332760737439",
   "payment_information" : {
      "prepayment_status" : "PREPAYMENT_NOT_PROVIDED"
   },
   "slot" : {
      "availability_tag" : "5042328",
      "confirmation_mode" : "CONFIRMATION_MODE_SYNCHRONOUS",
      "duration_sec" : "4500",
      "merchant_id" : "1234",
      "resources" : {
         "staff_id" : "276191"
      },
      "service_id" : "5678",
      "start_sec" : "1606359600"
   },
   "user_information" : {
      "email" : "john.smith@gmail.com",
      "family_name" : "Smith",
      "given_name" : "John",
      "telephone" : "+12091111111",
      "user_id" : "1111111111111111111"
   }
}

응답

{
   "booking" : {
      "booking_id" : "890",
      "payment_information" : {
         "prepayment_status" : "PREPAYMENT_NOT_PROVIDED"
      },
      "slot" : {
         "availability_tag" : "5042328",
         "confirmation_mode" : "CONFIRMATION_MODE_SYNCHRONOUS",
         "duration_sec" : "4500",
         "merchant_id" : "1234",
         "resources" : {
            "staff_id" : "276191"
         },
         "service_id" : "5678",
         "start_sec" : "1606359600"
      },
      "status" : "CONFIRMED",
      "user_information" : {
         "email" : "john.smith@gmail.com",
         "family_name" : "Smith",
         "given_name" : "John",
         "telephone" : "+12091111111",
         "user_id" : "1111111111111111111"
      }
   }
}

금융 서비스용 CreateBooking 샘플

TODO