客戶檔案可透過允許擁有帳戶的客戶預先載入其地址和付款詳細資訊,來簡化您的結帳體驗。
此功能目前僅適用於自訂 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
這個頁面有幫助嗎?