DOCS

客户档案

客户档案

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

客户档案通过允许拥有账户的客户预加载他们的地址和支付信息,简化了您的checkout体验。

此功能目前仅适用自定义API集成。此功能尚不适用于使用Checkout插件的商家。

1

发送经过身份验证的客户信息

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

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

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

变更

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

变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
	"input": {
		"email": "test@zonos.com",
		"locations": [
			{
				"administrativeArea": "BC",
				"countryCode": "CA",
				"line1": "411-1033 Davie Street",
				"line2": "123 testAddress2",
				"locality": "Vancouver",
				"name": "TestCanada TestCanada",
				"postalCode": "V6E1M7"
			},
			{
				"administrativeArea": "UT",
				"countryCode": "US",
				"line1": "411-1033 Davie Street",
				"line2": "123 testAddress2",
				"locality": "Saint George",
				"name": "TestUS TestLastName",
				"postalCode": "84770"
			}
		],
		"customerId": "1234567",
		"name": "testFirstName1 testLastName",
		"phone": "7022920000"
	}
}

在验证客户会话时,请确保您在请求中传递的 customerId 与正确的个人资料匹配,以便在checkout上显示准确的客户信息。请记住,在创建购物车时,您不应在元数据中包含 customerId,因为它将被覆盖。

在客户通过身份验证并下单后,customerId 将在通过订单查询检索订单详细信息时可在 order.references 中获得,从而使您能够将订单与正确的客户关联。

2

使用客户个人资料创建购物车

在您调用这两个变更后,您将收到以下内容:

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

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

您可以将这两个值传递到 Zonos.init 函数中的 createCartId 回调中,以加载提供的客户个人资料信息到Checkout。

Zonos.init

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 ||
          '',
      };
    }
  },
}
3

管理客户档案

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

目前,客户档案只能通过附加信息进行更新——现有详细信息无法编辑或删除。

这个页面有帮助吗?


在本页上: