客戶資料簡化了您的結帳體驗,讓擁有帳戶的客戶能夠預先載入其地址和付款詳細資料。
此功能目前僅適用於自訂 API 整合。此功能還不適用於使用 Checkout 外掛程式的商家。
如果您銷售對象包括經銷商、政府機構或非營利組織,您也可以將其免稅證明同步至客戶資料。
若要驗證客戶資料,您的後端伺服器必須進行兩個獨立的 API 呼叫,我們建議平行執行以獲得更佳的效能:
createCart:產生 Zonos 購物車。如需詳細指引,請參閱自訂整合文件中的設定 Zonos Checkout 部分。
createCart
checkoutCustomerProfileAuthenticate:提交並驗證客戶的資訊。
checkoutCustomerProfileAuthenticate
mutation checkoutCustomerProfileAuthenticate(
$input: CheckoutCustomerProfileAuthenticateInput!
) {
checkoutCustomerProfileAuthenticate(input: $input) {
email
customerId
organizationId
name
phone
locations {
administrativeArea
countryCode
locality
line1
line2
postalCode
}
oneTimePassword
驗證客戶工作階段時,請確保您在請求中傳遞的 customerId 與正確的資料相符,以在結帳時顯示準確的客戶資訊。請記住,建立購物車時,您不應在中繼資料中包含 customerId,因為它會被覆寫。
客戶通過驗證並下單後,在透過訂單查詢檢索訂單詳細資料時,customerId 將在 order.references 中提供,讓您能夠將訂單與正確的客戶建立關聯。
order.references
呼叫這兩個異動後,您將獲得以下內容:
來自 createCart 異動的 cartId 以產生購物車。
cartId
來自 checkoutCustomerProfileAuthenticate 異動的 oneTimePassword,用於客戶驗證。
您可以在 Zonos.init 函式中的 createCartId 回呼中傳遞這兩個值,以在 Checkout 中載入所提供的客戶資料資訊。
Zonos.init
createCartId
Zonos.init({
...
checkoutSettings: {
createCartId: async () => {
const result = await fetch(
'https://api.merchant.com/api/get-cart-info',
{
body: JSON.stringify(payload),
method: 'POST',
},
);
const json =
await result.json();
return {
cartId: json.cartId,
customerAuthenticationToken:
json.customerProfileAuthenticate
?.checkoutCustomerProfileAuthenticate.oneTimePassword ||
'',
};
您首次提交客戶資訊時,Zonos 會儲存提供的客戶資訊。付款方式將安全地儲存在 Stripe 中。每次傳遞新的地址或付款方式詳細資料時,它們都會新增到客戶的資料中。
地址與付款方式僅能新增——現有項目無法編輯或刪除。客戶的姓名、電子郵件及電話號碼可透過 checkoutCustomerUpsert 進行更新。
checkoutCustomerUpsert
checkoutCustomerProfileAuthenticate 需要購物者在場,因為它會為該結帳工作階段核發一次性密碼。當您想在結帳流程之外建立或更新資料——例如預先載入您的客戶清單、從您自己的系統同步資料變更,或在客戶首次下單前附加稅務豁免——請改用 checkoutCustomerUpsert。
mutation checkoutCustomerUpsert($input: CheckoutCustomerProfileInput!) {
checkoutCustomerUpsert(input: $input) {
客戶資料是以 customerId 進行比對,因此重複呼叫此項操作會更新同一份客戶資料,而非建立重複項目。您可以安全地按排程對整個客戶清單執行此操作。
更新套用方式有三項重點:
checkoutCustomerUpsert 不會回傳 oneTimePassword。若要將資料載入 Checkout, 您仍需要 checkoutCustomerProfileAuthenticate,該項操作會為該工作階段核發一次性密碼。
CheckoutCustomerProfileInput
客戶資料
客戶資料
將重複購物者資訊預先載入 Zonos Checkout。客戶資料簡化了您的結帳體驗,讓擁有帳戶的客戶能夠預先載入其地址和付款詳細資料。
此功能目前僅適用於自訂 API 整合。此功能還不適用於使用 Checkout 外掛程式的商家。
如果您銷售對象包括經銷商、政府機構或非營利組織,您也可以將其免稅證明同步至客戶資料。
傳送已驗證的客戶資訊
若要驗證客戶資料,您的後端伺服器必須進行兩個獨立的 API 呼叫,我們建議平行執行以獲得更佳的效能:
createCart:產生 Zonos 購物車。如需詳細指引,請參閱自訂整合文件中的設定 Zonos Checkout 部分。checkoutCustomerProfileAuthenticate:提交並驗證客戶的資訊。mutation checkoutCustomerProfileAuthenticate($input: CheckoutCustomerProfileAuthenticateInput!) {checkoutCustomerProfileAuthenticate(input: $input) {emailcustomerIdorganizationIdnamephonelocations {administrativeAreacountryCodelocalityline1line2postalCode}oneTimePassword}}驗證客戶工作階段時,請確保您在請求中傳遞的
customerId與正確的資料相符,以在結帳時顯示準確的客戶資訊。請記住,建立購物車時,您不應在中繼資料中包含customerId,因為它會被覆寫。客戶通過驗證並下單後,在透過訂單查詢檢索訂單詳細資料時,customerId 將在
order.references中提供,讓您能夠將訂單與正確的客戶建立關聯。使用客戶資料建立購物車
呼叫這兩個異動後,您將獲得以下內容:
來自
createCart異動的cartId以產生購物車。來自
checkoutCustomerProfileAuthenticate異動的oneTimePassword,用於客戶驗證。您可以在
Zonos.init函式中的createCartId回呼中傳遞這兩個值,以在 Checkout 中載入所提供的客戶資料資訊。Zonos.init({...checkoutSettings: {...createCartId: async () => {const result = await fetch('https://api.merchant.com/api/get-cart-info',{body: JSON.stringify(payload),method: 'POST',},);const json =await result.json();return {cartId: json.cartId,customerAuthenticationToken:json.customerProfileAuthenticate?.checkoutCustomerProfileAuthenticate.oneTimePassword ||'',};}},}管理客戶資料
您首次提交客戶資訊時,Zonos 會儲存提供的客戶資訊。付款方式將安全地儲存在 Stripe 中。每次傳遞新的地址或付款方式詳細資料時,它們都會新增到客戶的資料中。
地址與付款方式僅能新增——現有項目無法編輯或刪除。客戶的姓名、電子郵件及電話號碼可透過
checkoutCustomerUpsert進行更新。在沒有購物者在場的情況下建立或更新資料
checkoutCustomerProfileAuthenticate需要購物者在場,因為它會為該結帳工作階段核發一次性密碼。當您想在結帳流程之外建立或更新資料——例如預先載入您的客戶清單、從您自己的系統同步資料變更,或在客戶首次下單前附加稅務豁免——請改用checkoutCustomerUpsert。mutation checkoutCustomerUpsert($input: CheckoutCustomerProfileInput!) {checkoutCustomerUpsert(input: $input) {customerIdemailnamephonelocations {administrativeAreacountryCodeline1line2localitypostalCode}}}客戶資料是以
customerId進行比對,因此重複呼叫此項操作會更新同一份客戶資料,而非建立重複項目。您可以安全地按排程對整個客戶清單執行此操作。更新套用方式有三項重點:
name只會更新姓名,電子郵件與電話號碼會維持原狀。checkoutCustomerUpsert不會回傳oneTimePassword。若要將資料載入 Checkout, 您仍需要checkoutCustomerProfileAuthenticate,該項操作會為該工作階段核發一次性密碼。CheckoutCustomerProfileInput
checkoutCustomerUpsert
這個頁面有幫助嗎?