Panduan ini memberikan referensi API teknis dan skema payload untuk checkout native Universal Commerce Protocol (UCP) versi
2026-04-08.
Sebelum membuat endpoint, pastikan Anda telah meninjau Ringkasan checkout native untuk memahami alur checkout tingkat tinggi, persyaratan autentikasi, dan alat developer.
Buat sesi checkout
Endpoint ini memungkinkan pembuatan sesi checkout yang berisi produk yang ingin dibeli pengguna.
- Endpoint:
POST /checkout-sessions - Pemicu: Pengguna mengklik "Beli sekarang" pada produk atau "Checkout di Google" dari keranjang.
Permintaan: Google mengirimkan item baris, dan informasi alamat terbatas tentang pembeli, yang mencakup kota, negara bagian, dan kode pos.
// Request Example: Create checkout with multiple items.
{
"line_items": [
{
"item": {
// Must match ID in product feed
"id": "product_12345"
},
"quantity": 1
},
{
"item": {
// Must match ID in product feed
"id": "product_67890"
},
"quantity": 1
}
],
"context": {
"language": "en"
},
"fulfillment": {
"methods": [
{
"type": "shipping",
"line_item_ids": [
"line_1",
"line_2"
],
"destinations": [
{
"id": "addr_1",
"address_locality": "Sunnyvale",
"address_region": "CA",
"postal_code": "94089",
"address_country": "US"
}
],
"selected_destination_id": "addr_1"
}
]
}
}
Respons: Anda menampilkan sesi yang diinisialisasi dengan total, pajak (awalnya diperkirakan), dan kemampuan pembayaran.
Catatan tentang kolom ucp.status:
Diperkenalkan di versi 2026-04-08, kolom ucp.status menunjukkan
hasil pembuatan:
"success"(atau tidak ada): Default. Sesi dibuat, bahkan denganmessagesyang dapat dipulihkan."error": Pembuatan sesi gagal karena error yang tidak dapat dipulihkan (misalnya, semua item stok habis). Dalam hal ini, isi respons harus berupa objek Respons Error, bukan objek Checkout. Lihat Contoh Error yang Tidak Dapat Dipulihkan di bagian Penanganan Error.
Catatan tentang perubahan array totals:
- Kolom
typedalam setiap objek di arraytotalskini berupa string terbuka. - Kolom
amountkini dapat bernilai negatif (misalnya, untuk merepresentasikan diskon). - Objek di
totals(sepertitype: "fee"dantype: "tax") dapat secara opsional menyertakan arraylinesuntuk mengelompokkan sub-komponen (misalnya, biaya layanan atau daur ulang, atau perincian pajak provinsi dan federal bertingkat seperti GST, PST, atau QST Kanada). - Harga termasuk pajak: Untuk pasar yang menyertakan pajak,
subtotalharus mencakup pajak, item baristaxharus dihilangkan, dandisplay_textharus diberikan secara eksplisit untuk entrisubtotaldanfulfillmentditotals. Lihat Harga yang sudah termasuk pajak untuk mengetahui detailnya.
// Response Example: Initialize Session with multiple items.
{
"ucp": {
"version": "2026-04-08",
"status": "success",
"capabilities": {
"dev.ucp.shopping.checkout": [ { "version": "2026-04-08" } ],
"dev.ucp.shopping.fulfillment": [ { "version": "2026-04-08", "extends": "dev.ucp.shopping.checkout" } ]
},
"payment_handlers": {
"com.google.pay": [
{
"id": "8c9202bd-63cc-4241-8d24-d57ce69ea31c",
"version": "2026-01-23",
"spec": "https://pay.google.com/gp/p/ucp/2026-01-23/",
"schema": "https://pay.google.com/gp/p/ucp/2026-01-23/schemas/config.json",
"config": {
"api_version": 2,
"api_version_minor": 0,
"environment": "TEST",
"merchant_info": {
"merchant_name": "Example Merchant",
"merchant_id": "KWMZPRLQFTYNXSDB",
"merchant_origin": "checkout.merchant.com"
},
"allowed_payment_methods": [
{
"type": "CARD",
"parameters": {
"allowed_auth_methods": [ "PAN_ONLY", "CRYPTOGRAM_3DS" ],
"allowed_card_networks": [ "AMEX", "DISCOVER", "JCB", "MASTERCARD", "VISA" ],
"billing_address_required": true,
"billing_address_parameters": {
"format": "FULL",
"phone_number_required": true
}
},
"tokenization_specification": {
"type": "PAYMENT_GATEWAY",
"parameters": {
"gateway": "example",
"gatewayMerchantId": "exampleGatewayMerchantId"
}
}
}
]
}
}
]
}
},
"id": "bf8c1b4b-6b1c-4c6a-8f2a-53c2a7c3b2e1",
"status": "incomplete",
"messages": [
{
"type": "error",
"code": "missing_buyer_info",
"path": "$.buyer",
"content_type": "plain",
"content": "Buyer information is required for checkout",
"severity": "recoverable"
},
{
"type": "error",
"code": "missing_fulfillment_info",
"path": "$.fulfillment.methods[0].destinations[0]",
"content_type": "plain",
"content": "Shipping address is incomplete",
"severity": "recoverable"
}
],
"currency": "USD",
"line_items": [
{
"id": "line_1",
"item": {
"id": "product_12345",
"title": "Running Shoes",
"price": 10000,
"image_url": "https://merchant.example.com/images/product_12345.png"
},
"quantity": 1,
"totals": [
{
"type": "subtotal",
"amount": 10000
},
{
"type": "total",
"amount": 10000
}
]
},
{
"id": "line_2",
"item": {
"id": "product_67890",
"title": "T-Shirt",
"price": 2500,
"image_url": "https://merchant.example.com/images/product_67890.png"
},
"quantity": 1,
"totals": [
{
"type": "subtotal",
"amount": 2500
},
{
"type": "total",
"amount": 2500
}
]
}
],
"totals": [
{
"type": "subtotal",
"display_text": "Subtotal", // Tax-inclusive markets: Set to "Subtotal (including taxes)".
"amount": 12500 // Tax-inclusive markets: Amount must include tax.
},
{
"type": "fee",
"display_text": "Fees",
"amount": 549,
"lines": [
{ "display_text": "Service Fee", "amount": 399 },
{ "display_text": "Recycling Fee", "amount": 150 }
]
},
{
"type": "fulfillment",
"display_text": "Ground Shipping", // Tax-inclusive markets: Provide display text for fulfillment totals.
"amount": 500
},
{
"type": "tax", // Tax-inclusive markets: Omit this entry.
"display_text": "Estimated Tax",
"amount": 1050
},
{
"type": "total",
"display_text": "Total",
"amount": 14599
}
],
"fulfillment": {
"methods": [
{
"id": "method_shipping",
"type": "shipping",
"line_item_ids": [
"line_1",
"line_2"
],
"destinations": [
{
"id": "addr_1",
"address_locality": "Sunnyvale",
"address_region": "CA",
"postal_code": "94089",
"address_country": "US"
}
],
"selected_destination_id": "addr_1",
"groups": [
{
"id": "group_1",
"line_item_ids": [
"line_1",
"line_2"
],
"options": [
{
"id": "ship_ground",
"title": "Ground (3-5 days)",
"description": "Estimated Delivery: Fri 5/8", // Maximum length: 200 characters.
"totals": [ {"type": "total", "amount": 500} ]
},
{
"id": "ship_express",
"title": "Express (1-2 days)",
"description": "Estimated Delivery: Wed 5/6", // Maximum length: 200 characters.
"totals": [ {"type": "total", "amount": 1500} ]
}
],
"selected_option_id": "ship_ground"
}
]
}
]
},
"links": [
{
"type": "terms_of_service",
"url": "https://m.com/terms",
"title": "Terms of Service"
},
{
"type": "privacy_policy",
"url": "https://m.com/privacy",
"title": "Privacy Policy"
}
]
}
Harga termasuk pajak
Untuk pasar yang menyertakan pajak dalam subtotal yang ditampilkan, bukan mengelompokkannya secara terpisah, penerapan Anda harus mematuhi persyaratan berikut saat memberikan data sesi checkout:
- Sertakan pajak dalam subtotal: Kolom
amountuntuk entrisubtotalharus menyertakan semua pajak yang berlaku. - Menghilangkan entri pajak terpisah: Jangan sertakan objek khusus dengan
type: "tax"dalam arraytotals. - Berikan teks tampilan kustom: Anda harus menyertakan atribut
display_textdalam objek subtotal yang secara eksplisit menyatakan bahwa pajak sudah termasuk, seperti"Subtotal (including taxes)". Anda juga harus menyertakan atributdisplay_textuntuk entri pemenuhan (misalnya,"Shipping").
Contoh: Array total termasuk pajak
Contoh berikut menunjukkan array totals untuk penjual di pasar yang mencakup pajak:
"totals": [
{
"type": "subtotal",
"display_text": "Subtotal (including taxes)",
"amount": 12500
},
{
"type": "fulfillment",
"display_text": "Shipping",
"amount": 399
},
{
"type": "total",
"display_text": "Total",
"amount": 12899
}
]
Perincian item pajak multi-tingkat
Untuk pasar yang mewajibkan pengungkapan pajak multi-tingkat atau multi-yurisdiksi yang terperinci (seperti GST atau HST federal Kanada dan PST atau QST provinsi), Anda dapat memberikan objek type: "tax" tingkat teratas dengan array lines bertingkat:
- Pajak tingkat teratas gabungan: Menampilkan satu objek
taxgabungan yang berisi total pajakamountdan deskripsidisplay_text(misalnya,"Taxes"). - Perincian sub-baris: Perinci setiap komponen pajak dalam array
linesdengandisplay_text(mis."TPS / GST (5%)","TVQ / QST (9.975%)") danamountmasing-masing. - Invarian: Jumlah semua jumlah sub-baris harus sama dengan
taxentri induk'amount.
Contoh: Perincian pajak bertingkat
{
"type": "tax",
"display_text": "Taxes",
"amount": 1498,
"lines": [
{ "display_text": "TPS / GST (5%)", "amount": 500 },
{ "display_text": "TVQ / QST (9.975%)", "amount": 998 }
]
}
Mendapatkan sesi checkout
Endpoint ini memungkinkan pengambilan sesi checkout.
- Endpoint:
GET /checkout-sessions/{id}
Permintaan: Google mengirimkan ID sesi checkout. Jika Anda menggunakan ID Global
(misalnya, gid://merchant.example.com/Checkout/session_abc123), perhatikan bahwa
ID di jalur permintaan hanya akan menjadi komponen terakhir dari ID ini (misalnya,
session_abc123).
Respons: Anda menampilkan objek checkout lengkap. Untuk sesi multi-item
yang dibuat di versi 2026-01-23 atau yang lebih baru, array line_items akan
berisi beberapa entri item.
Memperbarui sesi checkout
Endpoint ini memungkinkan pembaruan sesi checkout. Saat alamat pengiriman diperbarui, alamat tersebut harus menghitung ulang dan menampilkan pajak serta opsi pengiriman.
- Endpoint:
PUT /checkout-sessions/{id}
Perbarui alamat pengiriman
- Pemicu: Pengguna memilih atau mengubah alamat pengiriman mereka.
Permintaan: Google memperbarui alamat pemenuhan saat pengguna mengubah alamat pengirimannya.
// Request Example: Update shipping address with multiple items.
{
"line_items": [
{
// line_items id from Create Checkout response
"id": "line_1",
"item": {
"id": "product_12345"
},
"quantity": 1
},
{
// line_items id from Create Checkout response
"id": "line_2",
"item": {
"id": "product_67890"
},
"quantity": 1
}
],
"context": {
"language": "en"
},
"fulfillment": {
"methods": [
{
"id": "method_shipping",
"type": "shipping",
"line_item_ids": [
"line_1",
"line_2"
],
"destinations": [
{
"id": "addr_1",
"address_locality": "Mountain View",
"address_region": "CA",
"postal_code": "94043",
"address_country": "US"
}
],
"selected_destination_id": "addr_1",
"groups": [
{
"id": "group_1",
"selected_option_id": "ship_ground"
}
]
}
]
}
}
Respons: Anda menghitung ulang pajak dan opsi pengiriman sesuai kebutuhan dan menampilkan objek checkout lengkap.
// Response Example: Updated session with new address for multiple items.
{
"id": "bf8c1b4b-6b1c-4c6a-8f2a-53c2a7c3b2e1",
"currency": "USD",
"line_items": [
{
"id": "line_1",
"item": {
"id": "product_12345",
"title": "Running Shoes",
"price": 10000,
"image_url": "https://merchant.example.com/images/product_12345.png"
},
"quantity": 1,
"totals": [
{ "type": "subtotal", "amount": 10000 },
{ "type": "total", "amount": 10000 }
]
},
{
"id": "line_2",
"item": {
"id": "product_67890",
"title": "T-Shirt",
"price": 2500,
"image_url": "https://merchant.example.com/images/product_67890.png"
},
"quantity": 1,
"totals": [
{ "type": "subtotal", "amount": 2500 },
{ "type": "total", "amount": 2500 }
]
}
],
"totals": [
{ "type": "subtotal", "display_text": "Subtotal", "amount": 12500 },
// Shipping cost might change based on new address
{ "type": "fulfillment", "display_text": "Ground Shipping", "amount": 600 },
{
"type": "fee",
"display_text": "Fees",
"amount": 549,
"lines": [
{ "display_text": "Service Fee", "amount": 399 },
{ "display_text": "Recycling Fee", "amount": 150 }
]
},
// Tax will likely change based on new address
{ "type": "tax", "display_text": "Estimated Tax", "amount": 1120 },
{ "type": "total", "display_text": "Total", "amount": 14769 }
],
"fulfillment": {
"methods": [
{
"id": "method_shipping",
"type": "shipping",
"line_item_ids": ["line_1", "line_2"],
"selected_destination_id": "addr_1",
"destinations": [
{
"id": "addr_1",
"address_locality": "Mountain View",
"address_region": "CA",
"postal_code": "94043",
"address_country": "US"
}
],
"groups": [
{
"id": "group_1",
"line_item_ids": ["line_1", "line_2"],
"selected_option_id": "ship_ground",
"options": [
{
"id": "ship_ground",
"title": "Ground (3-5 days)",
"description": "Estimated Delivery: Fri 5/8", // Maximum length: 200 characters.
"totals": [ { "type": "total", "amount": 600 } ]
},
{
"id": "ship_express",
"title": "Express (1-2 days)",
"description": "Estimated Delivery: Wed 5/6", // Maximum length: 200 characters.
"totals": [ { "type": "total", "amount": 1600 } ]
}
]
}
]
}
]
}
// ... other fields like ucp, status, messages, links
}
Pengisian objek checkout lengkap
Permintaan: Google mengirimkan objek checkout lengkap dengan informasi yang diperbarui (termasuk alamat pemenuhan lengkap dan kontak pembeli) saat pembeli mengklik "Bayar dengan GPay".
// Request Example: full checkout object hydration for multiple items.
{
"buyer": {
"first_name": "John",
"last_name": "Buyer",
"email": "johnbuyer@example.com",
"phone_number": "+18888888888"
},
"line_items": [
{
"id": "line_1",
"item": { "id": "product_12345" },
"quantity": 1
},
{
"id": "line_2",
"item": { "id": "product_67890" },
"quantity": 1
}
],
"fulfillment": {
"methods": [
{
"id": "method_shipping",
"type": "shipping",
"line_item_ids": ["line_1", "line_2"],
"selected_destination_id": "addr_1",
"destinations": [
{
"id": "addr_1",
"first_name": "Alice",
"last_name": "Receiver",
"street_address": "1600 Amphitheatre Pkwy",
"extended_address": "Suite #60",
"address_locality": "Mountain View",
"address_region": "CA",
"postal_code": "94043",
"address_country": "US",
"phone_number": "+18888888888"
}
],
"groups": [
{
"id": "group_1",
"selected_option_id": "ship_ground"
}
]
}
]
}
}
Respons: Anda menghitung ulang pajak dan opsi pengiriman sesuai kebutuhan dan menampilkan objek checkout lengkap.
// Response Example: Session after full hydration with multiple items.
{
"ucp": {
"version": "2026-04-08",
"status": "success",
"capabilities": {
"dev.ucp.shopping.checkout": [ { "version": "2026-04-08" } ],
"dev.ucp.shopping.fulfillment": [ { "version": "2026-04-08", "extends": "dev.ucp.shopping.checkout" } ]
},
"payment_handlers": {
"com.google.pay": [
{
"id": "8c9202bd-63cc-4241-8d24-d57ce69ea31c",
"version": "2026-01-23",
"spec": "https://pay.google.com/gp/p/ucp/2026-01-23/",
"schema": "https://pay.google.com/gp/p/ucp/2026-01-23/schemas/config.json",
"config": {
"api_version": 2,
"api_version_minor": 0,
"environment": "TEST",
"merchant_info": {
"merchant_name": "Example Merchant",
"merchant_id": "KWMZPRLQFTYNXSDB",
"merchant_origin": "checkout.merchant.com"
},
"allowed_payment_methods": [
{
"type": "CARD",
"parameters": {
"allowed_auth_methods": [ "PAN_ONLY", "CRYPTOGRAM_3DS" ],
"allowed_card_networks": [ "AMEX", "DISCOVER", "JCB", "MASTERCARD", "VISA" ],
"billing_address_required": true,
"billing_address_parameters": {
"format": "FULL",
"phone_number_required": true
}
},
"tokenization_specification": {
"type": "PAYMENT_GATEWAY",
"parameters": {
"gateway": "example",
"gatewayMerchantId": "exampleGatewayMerchantId"
}
}
}
]
}
}
]
}
},
"id": "bf8c1b4b-6b1c-4c6a-8f2a-53c2a7c3b2e1",
"status": "ready_for_complete",
"currency": "USD",
"buyer": {
"first_name": "John",
"last_name": "Buyer",
"email": "johnbuyer@example.com",
"phone_number": "+18888888888"
},
"line_items": [
{
"id": "line_1",
"item": {
"id": "product_12345",
"title": "Running Shoes",
"price": 10000,
"image_url": "https://merchant.example.com/images/product_12345.png"
},
"quantity": 1,
"totals": [
{ "type": "subtotal", "amount": 10000 },
{ "type": "total", "amount": 10000 }
]
},
{
"id": "line_2",
"item": {
"id": "product_67890",
"title": "T-Shirt",
"price": 2500,
"image_url": "https://merchant.example.com/images/product_67890.png"
},
"quantity": 1,
"totals": [
{ "type": "subtotal", "amount": 2500 },
{ "type": "total", "amount": 2500 }
]
}
],
"totals": [
{ "type": "subtotal", "display_text": "Subtotal", "amount": 12500 },
{ "type": "fulfillment", "display_text": "Ground Shipping", "amount": 600 },
{
"type": "fee",
"display_text": "Fees",
"amount": 549,
"lines": [
{ "display_text": "Service Fee", "amount": 399 },
{ "display_text": "Recycling Fee", "amount": 150 }
]
},
{ "type": "tax", "display_text": "Estimated Tax", "amount": 1120 },
{ "type": "total", "display_text": "Total", "amount": 14769 }
],
"fulfillment": {
"methods": [
{
"id": "method_shipping",
"type": "shipping",
"line_item_ids": ["line_1", "line_2"],
"selected_destination_id": "addr_1",
"destinations": [
{
"id": "addr_1",
"first_name": "Alice",
"last_name": "Receiver",
"street_address": "1600 Amphitheatre Pkwy",
"extended_address": "Suite #60",
"address_locality": "Mountain View",
"address_region": "CA",
"postal_code": "94043",
"address_country": "US",
"phone_number": "+18888888888"
}
],
"groups": [
{
"id": "group_1",
"line_item_ids": ["line_1", "line_2"],
"selected_option_id": "ship_ground",
"options": [
{
"id": "ship_ground",
"title": "Ground (3-5 days)",
"description": "Estimated Delivery: Fri 5/8", // Maximum length: 200 characters.
"totals": [ { "type": "total", "amount": 600 } ]
},
{
"id": "ship_express",
"title": "Express (1-2 days)",
"description": "Estimated Delivery: Wed 5/6", // Maximum length: 200 characters.
"totals": [ { "type": "total", "amount": 1600 } ]
}
]
}
]
}
]
},
"links": [
{
"type": "terms_of_service",
"url": "https://m.com/terms",
"title": "Terms of Service"
},
{
"type": "privacy_policy",
"url": "https://m.com/privacy",
"title": "Privacy Policy"
}
]
}
Selesaikan sesi checkout
Endpoint ini memungkinkan penyelesaian sesi checkout dan melakukan pemesanan. Fungsi ini harus menampilkan sesi checkout yang telah selesai dan menyertakan informasi pesanan. Pemrosesan pembayaran harus dimulai setelah panggilan ini diterima.
- Endpoint:
POST /checkout-sessions/{id}/complete - Pemicu: Pengguna mengklik "Bayar dengan GPay", dan Google menerima respons yang berhasil dari update checkout yang sepenuhnya di-hydrate.
Permintaan: Google mengirimkan instrumen pembayaran yang dipilih dari penyedia layanan pembayaran, termasuk kredensial (misalnya, data tokenisasi Google Pay) dan sinyal risiko tentang pembeli agar Anda dapat melakukan deteksi penipuan sendiri. Isi token akan bergantung pada Penyedia Layanan Pembayaran Anda.
{
"payment": {
"instruments": [
{
"billing_address": {
"first_name": "John",
"last_name": "Buyer",
"street_address": "100 Main St",
"extended_address": "Apt 4B",
"address_locality": "San Francisco",
"address_region": "CA",
"postal_code": "94105",
"address_country": "US",
"phone_number": "+18888888888"
},
"credential": {
"token": "examplePaymentMethodToken",
"type": "PAYMENT_GATEWAY"
},
"display": {
"brand": "VISA",
"description": "Visa •••• 1234",
"last_digits": "1234"
},
"handler_id": "8c9202bd-63cc-4241-8d24-d57ce69ea31c",
"id": "94e7fee0-1a82-4c2a-9ef4-0861a3c829b2",
"selected": true,
"type": "card"
}
]
},
"signals": {
"com.google.authentication_triggered": "",
"com.google.authorization_processed_with_3ds": "",
"com.google.avs_full_result": "",
"com.google.cvv_result": "",
"com.google.ip_address": "203.0.113.1",
"dev.ucp.buyer_id": "ec46fedc6aad89d3660a50a61d00b4908fd160ecf5dda6d49ed41a605c5b180a",
"dev.ucp.buyer_ip": "203.0.113.1"
}
}
Jika Anda memerlukan informasi wajib untuk menyelesaikan checkout yang belum diberikan dalam sesi checkout, Anda dapat mencegah penyelesaian checkout dan meminta informasi tersebut dengan menampilkan status tidak selesai dalam respons.
Jika Google dapat mengumpulkan informasi yang tidak ada menggunakan kolom yang ditentukan UCP (misalnya, alamat email pembeli), tetapkan status ke incomplete dan sertakan satu atau beberapa pesan dalam array messages dengan severity ditetapkan ke recoverable, yang menunjukkan informasi yang tidak ada.
{
"ucp": {
"version": "2026-04-08",
"status": "success"
},
"id": "bf8c1b4b-6b1c-4c6a-8f2a-53c2a7c3b2e1",
"status": "incomplete",
"messages": [
{
"type": "error",
"code": "missing_buyer_info",
"severity": "recoverable",
"content": "Buyer email is required"
},
{
"type": "error",
"code": "missing_fulfillment_info",
"severity": "recoverable",
"content": "Select delivery window for your purchase"
}
]
}
Setelah menerima instrumen pembayaran Google Pay, Anda harus:
- Validasi handler: Mengonfirmasi bahwa
handler_idsesuai dengan handler pembayaran Google Pay yang ditentukan dalam konfigurasi Anda. - Ekstrak token: Ambil token metode pembayaran yang dibuat dari
payment.instruments[0].credential.token. - Memproses pembayaran: Gunakan token dan detail transaksi untuk menyelesaikan pembayaran. Lihat dokumentasi Google Pay API untuk mengetahui dokumentasi mendetail tentang spesifikasi dan penanganan tokenisasi.
Respons: Jika checkout dapat diselesaikan dan Anda telah memproses pembayaran, Anda
akan menampilkan objek checkout lengkap yang menunjukkan bahwa pesanan telah selesai, termasuk
instrumen pembayaran yang dikonfirmasi (mengulang metadata instrumen dan alamat
penagihan, tanpa token credential atau signals yang sensitif), ID pesanan, dan URL permalink ke pesanan.
{
"ucp": {
"version": "2026-04-08",
"status": "success",
"capabilities": [...]
},
"id": "bf8c1b4b-6b1c-4c6a-8f2a-53c2a7c3b2e1",
"status": "completed",
// ... other fields (line_items, currency, etc.)
"payment": {
"instruments": [
{
"id": "94e7fee0-1a82-4c2a-9ef4-0861a3c829b2",
"handler_id": "8c9202bd-63cc-4241-8d24-d57ce69ea31c",
"type": "card",
"selected": true,
"display": {
"brand": "VISA",
"description": "Visa •••• 1234",
"last_digits": "1234"
},
"billing_address": {
"first_name": "John",
"last_name": "Buyer",
"street_address": "100 Main St",
"extended_address": "Apt 4B",
"address_locality": "San Francisco",
"address_region": "CA",
"postal_code": "94105",
"address_country": "US",
"phone_number": "+18888888888"
}
}
]
},
"order": {
"id": "ORD1773956535.2727807",
// Example customer-facing order number
"label": "#100",
"permalink_url": "https://merchant.example.com/orders/789"
}
}
Membatalkan sesi checkout
Endpoint ini membatalkan sesi checkout.
- Endpoint:
POST /checkout-sessions/{id}/cancel
Permintaan: Google mengirimkan ID sesi checkout.
Respons: Anda menampilkan objek checkout lengkap dengan status yang diperbarui menjadi
canceled.
Penanganan error
Untuk mengetahui panduan lengkap tentang cara memformat pesan error dan perbedaan antara error protokol dan error logika bisnis, lihat Ringkasan kode error.
Error yang Tidak Dapat Dipulihkan
Mulai dari versi 2026-04-08, jika terjadi error yang tidak dapat dipulihkan yang mencegah pembuatan sesi checkout (misalnya, semua item stok habis), akan ditampilkan HTTP 200 OK. Dalam isi respons, tetapkan "status": "error" dalam objek ucp.
Hal ini memberi tahu Google bahwa permintaan valid, tetapi aturan bisnis memblokir pembuatan sesi. Tidak ada ID sesi checkout yang ditampilkan dalam kasus ini.
HTTP/1.1 200 OK
Content-Type: application/json
{
"ucp": {
"version": "2026-04-08",
"status": "error"
},
"messages": [
{
"type": "error",
"code": "out_of_stock",
"content": "All requested items are currently out of stock",
"severity": "unrecoverable"
}
],
"continue_url": "https://merchant.com/"
}