DOCS

客户档案

客户档案

将重复购物者信息预加载到 Zonos Checkout 中。

客户档案通过允许拥有帐户的客户预加载其地址和付款详情,简化了您的结账体验。

此功能当前仅适用于自定义 API 集成。该功能尚未可供使用 Checkout 插件的商家使用。

如果您向经销商、政府机构或非营利组织销售商品,还可以将其免税证书同步到客户档案。

要对客户档案进行身份验证,您的后端服务器必须进行两个独立的 API 调用,我们建议并行运行以获得更好的性能:

  • createCart:生成 Zonos 购物车。如需详细指导,请参阅自定义集成文档中的设置 Zonos Checkout 部分

  • checkoutCustomerProfileAuthenticate:提交并验证客户的信息。

1mutation checkoutCustomerProfileAuthenticate(
2$input: CheckoutCustomerProfileAuthenticateInput!
3) {
4 checkoutCustomerProfileAuthenticate(input: $input) {
5 email
6 customerId
7 organizationId
8 name
9 phone
10 locations {
11 administrativeArea
12 countryCode
13 locality
14 line1
15 line2
16 postalCode
17 }
18 oneTimePassword
19 }
20}

验证客户会话时,请确保您在请求中传递的 customerId 与正确的档案相匹配,以在结账时显示准确的客户信息。请注意,创建购物车时,不应在元数据中包含 customerId,因为它将被覆盖。

客户通过身份验证并下单后,在通过订单查询检索订单详情时,customerId 将在 order.references 中可用,允许您将订单与正确的客户相关联。

调用这两个变更后,您将获得以下内容:

  • 来自 createCart 变更的 cartId 以生成购物车。

  • 来自 checkoutCustomerProfileAuthenticate 变更的 oneTimePassword,用于客户身份验证。

您可以在 Zonos.init 函数中的 createCartId 回调中传递这两个值,以在 Checkout 中加载所提供的客户档案信息。

1Zonos.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.customerProfileAuthenticate
19 ?.checkoutCustomerProfileAuthenticate.oneTimePassword ||
20 '',
21 };
22 }
23 },
24}

第一次提交客户信息时,Zonos 将存储提供的客户信息。付款方式将安全地存储在 Stripe 中。每次传递新的地址或付款方式详情时,它们将被添加到客户的档案中。

地址和付款方式只能被添加——现有的无法编辑或删除。客户的姓名、邮箱和电话可以通过 checkoutCustomerUpsert 进行更新。

在没有购物者的情况下创建或更新档案 

checkoutCustomerProfileAuthenticate 需要购物者在场,因为它会为该结账会话签发一次性密码。当您想在结账之外创建或更新档案时——例如提前加载您的客户列表、从您自己的系统同步档案变更,或在客户首次下单前附加免税信息——请改用 checkoutCustomerUpsert

1mutation checkoutCustomerUpsert($input: CheckoutCustomerProfileInput!) {
2 checkoutCustomerUpsert(input: $input) {
3 customerId
4 email
5 name
6 phone
7 locations {
8 administrativeArea
9 countryCode
10 line1
11 line2
12 locality
13 postalCode
14 }
15 }
16}

档案通过 customerId 进行匹配,因此重复调用会更新同一个档案,而不会创建重复项。您可以安全地按计划对整个客户列表运行此操作。

关于更新如何生效,有三点需要了解:

  • 省略的字段保持不变。 仅发送 name 只会更新姓名,邮箱和电话保持原样。
  • 值无法被清空。 发送空值与省略该字段效果相同,因此一旦设置了姓名、邮箱或电话,就无法将其移除。
  • 地址仅会被添加。 档案中已存在的地址不会被重复添加,请求中未包含的地址也不会被移除。

checkoutCustomerUpsert 不会返回 oneTimePassword。要将档案加载到 Checkout 中, 您仍然需要 checkoutCustomerProfileAuthenticate,它会为该会话签发一次性密码。

GraphQL API ReferenceTypes, inputs, and operations used in this guide
预约演示

这个页面有帮助吗?


在此页面: