1
傳送已驗證的客戶資訊
若要驗證客戶資料,您的後端伺服器必須進行兩個獨立的 API 呼叫,我們建議平行執行以獲得更佳的效能:
-
createCart:產生 Zonos 購物車。如需詳細指引,請參閱自訂整合文件中的設定 Zonos Checkout 部分。 -
checkoutCustomerProfileAuthenticate:提交並驗證客戶的資訊。
1
mutation checkoutCustomerProfileAuthenticate(2
$input: CheckoutCustomerProfileAuthenticateInput!3
) {4
checkoutCustomerProfileAuthenticate(input: $input) {5
email6
customerId7
organizationId8
name9
phone10
locations {11
administrativeArea12
countryCode13
locality14
line115
line216
postalCode17
}18
oneTimePassword19
}20
}驗證客戶工作階段時,請確保您在請求中傳遞的 customerId 與正確的資料相符,以在結帳時顯示準確的客戶資訊。請記住,建立購物車時,您不應在中繼資料中包含 customerId,因為它會被覆寫。
客戶通過驗證並下單後,在透過訂單查詢檢索訂單詳細資料時,customerId 將在 order.references 中提供,讓您能夠將訂單與正確的客戶建立關聯。
2
使用客戶資料建立購物車
呼叫這兩個異動後,您將獲得以下內容:
-
來自
createCart異動的cartId以產生購物車。 -
來自
checkoutCustomerProfileAuthenticate異動的oneTimePassword,用於客戶驗證。
您可以在 Zonos.init 函式中的 createCartId 回呼中傳遞這兩個值,以在 Checkout 中載入所提供的客戶資料資訊。
1
Zonos.init({2
...3
checkoutSettings: {4
...5
createCartId: async () => {6
const result = await fetch(7
'https://api.merchant.com/api/get-cart-info',8
{9
body: JSON.stringify(payload),10
method: 'POST',11
},12
);13
const json =14
await result.json();15
return {16
cartId: json.cartId,17
customerAuthenticationToken:18
json.customerProfileAuthenticate19
?.checkoutCustomerProfileAuthenticate.oneTimePassword ||20
'',21
};22
}23
},24
}3
管理客戶資料
您首次提交客戶資訊時,Zonos 會儲存提供的客戶資訊。付款方式將安全地儲存在 Stripe 中。每次傳遞新的地址或付款方式詳細資料時,它們都會新增到客戶的資料中。
目前,客戶資料只能更新為其他資訊——現有詳細資料無法編輯或刪除。
客戶資料
將重複購物者資訊預先載入 Zonos Checkout。客戶資料簡化了您的結帳體驗,讓擁有帳戶的客戶能夠預先載入其地址和付款詳細資料。
此功能目前僅適用於自訂 API 整合。此功能還不適用於使用 Checkout 外掛程式的商家。