CreateBooking yöntemi
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Müşteri rezervasyon oluşturma isteğinde bulunur. İş ortağı arka uç, istenen alan için rezervasyon yapar ve başarılı olduğunda alanı döndürür veya başarısız olduğunda iş mantığı hatası (ör. alan kullanılamaz hale geldiyse veya ödeme geçersizse vb.) döndürür.
İşlem mantığı hatalarının, 200 olmayan bir HTTP yanıt kodu yerine CreateBookingResponse.booking_failure
alanında döndürülmesi gerektiğini lütfen unutmayın.
İstek
CreateBookingRequest
Döndürülen değer
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;
}
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-26 UTC.
[null,null,["Son güncelleme tarihi: 2025-07-26 UTC."],[[["\u003cp\u003ePartners receive a \u003ccode\u003eCreateBookingRequest\u003c/code\u003e containing user and booking details, including an idempotency token to manage duplicate requests.\u003c/p\u003e\n"],["\u003cp\u003ePartners attempt to create the booking and return a \u003ccode\u003eCreateBookingResponse\u003c/code\u003e with the confirmed \u003ccode\u003eBooking\u003c/code\u003e details upon success.\u003c/p\u003e\n"],["\u003cp\u003eIf the booking fails due to business logic (e.g., slot unavailable, invalid payment), partners must indicate the reason in the \u003ccode\u003ebooking_failure\u003c/code\u003e field of the \u003ccode\u003eCreateBookingResponse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003ePartners are responsible for handling idempotency and detecting duplicate booking requests, responding with \u003ccode\u003eBookingFailure.OVERLAPPING_RESERVATION\u003c/code\u003e if a conflict is found.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eCreateBookingResponse\u003c/code\u003e may optionally include updated user payment information if applicable.\u003c/p\u003e\n"]]],["The client sends a `CreateBookingRequest` to create a booking. This request includes the slot, user information, payment details, an idempotency token, and optional data like special requests and an offer ID. Upon success, the partner returns a `CreateBookingResponse` containing the created booking. If the booking fails due to business logic errors, such as slot unavailability or an invalid payment, it's communicated in the `booking_failure` field of the response, rather than through HTTP status codes.\n"],null,["# CreateBooking method\n\nThe client requests to create a booking. The partner backend makes a\nbooking for the requested slot, and returns the slot upon success, or business\nlogic error (e.g. if the slot has become unavailable, or if payment is\ninvalid, etc.) upon failure.\n\n\nPlease note that business logic errors should be returned in the\n`CreateBookingResponse.booking_failure` field, rather than via a non-200 HTTP response\ncode.\n\n**Request**\n\nCreateBookingRequest\n\n**Return value**\n\nCreateBookingResponse \n\n```carbon\n// Request to create a Booking for an inventory slot. Consumes the lease if\n// provided.\nmessage CreateBookingRequest {\n // The inventory slot that is being requested to make this booking.\n // If lease_ref is provided, slot must match the lease; slot is provided for\n // the partner to verify the lease information.\n // If lease_ref is absent, then create the booking for the slot. (required)\n Slot slot = 1;\n\n\n // Personal information of the user making the appointment (required)\n UserInformation user_information = 3;\n\n // Information about payments. When payment authorizations are handled by\n // Google, if the booking request does not succeed, payment authorizations are\n // automatically canceled. (optional)\n PaymentInformation payment_information = 4;\n\n // The parameters to be used if the payment is processed by the partner\n // (i.e. payment_information.payment_processed_by is equal to\n // PROCESSED_BY_PARTNER). (optional)\n PaymentProcessingParameters payment_processing_parameters = 5;\n\n // Idempotency token for CreateBooking requests. (required)\n //\n // This uniquely identifies a booking request. Specifically:\n // - If a booking was already created for a CreateBooking request with this\n // idempotency token, that booking should be returned.\n // - If no booking has been created for a CreateBooking request with this\n // idempotency token, this should be considered to be a request for a new\n // booking, and **no previously-created booking may be returned**.\n //\n // If a partner considers the requested booking to be a duplicate of a\n // previously-created booking, this request should fail with reason\n // BookingFailure.OVERLAPPING_RESERVATION. The partner is responsible for\n // determining whether this duplicates a previous booking, but for example the\n // partner may consider a booking request to be a duplicate if an existing\n // booking has the same party size, time, and email address.\n string idempotency_token = 6;\n\n // A string from the user which contains any special requests or additional\n // information that they would like to notify the merchant about. (optional)\n string additional_request = 7;\n\n // Partner provided offer id associated with this slot. (optional)\n //\n // If the offer is no longer available, the booking should not be made, and in\n // response.booking_failure should be set to OFFER_UNAVAILABLE.\n string offer_id = 9;\n\n}\n\n// Response with the created Booking for an inventory slot.\nmessage CreateBookingResponse {\n // The created booking (required)\n Booking booking = 1;\n\n // The updated user payment option used in this booking.\n // If a new payment option was purchased to pay for the booking, this should\n // be a newly created user payment option.\n // If an already purchased user payment option was used for this booking,\n // this should reflect an updated version of that user payment option.\n // (optional)\n UserPaymentOption user_payment_option = 2;\n\n // If creating a booking fails, this field should reflect the business logic\n // error (e.g., slot has become unavailable) and all other fields in the\n // CreateBookingResponse message are expected to be unset. (required if\n // failure occurs)\n BookingFailure booking_failure = 3;\n}\n```"]]