Checkify
开发者文档

嵌入SDK参考

浏览器API进行Checkify Pass验证。 CDN URL: https://checkify.me/sdk/v1/checkify.min.js

安装

<script src="https://checkify.me/sdk/v1/checkify.min.js"></script>

加载后, window.Checkify.version 报告SDK版本(当前为1.0.4)。

HTML自动挂载

SDK在页面加载时自动挂载具有这些属性的元素:

<div
  data-checkify-pass="YOUR_PASS_ID"
  data-checkify-request="human"
  data-checkify-text="Verify with Checkify"
  data-checkify-return-url="https://yoursite.com/done"
></div>

已弃用: data-checkify-launcher 仍然有效,但会记录控制台警告。请改用 Pass + 请求类型。

方法描述
data-checkify-passYour Checkify Pass public ID (required)
data-checkify-requestRequest type: human, age_over_18, age_over_21, age_over_25, or age_over_N
data-checkify-textButton label text
data-checkify-return-urlOptional URL to return to after app handoff
data-checkify-fieldsOptional comma-separated identity fields to request (for example country)
data-checkify-proofsOptional comma-separated proof types when your Pass supports multiple proofs
data-checkify-launcherDeprecated launcher ID — use data-checkify-pass instead

Form integration attributes

When using Checkify.bindForm, you can also set these on the form element:

方法描述
data-checkify-passYour Checkify Pass public ID (required)
data-checkify-requestRequest type: human, age_over_18, age_over_21, age_over_25, or age_over_N
data-checkify-auto="true"Set data-checkify-auto="true" on a form to auto-bind on page load without calling bindForm manually
data-checkify-hidden-inputCSS selector for the hidden input that receives request_id (default: input[name=checkify_token])

Checkify.configure(options)

在安装小部件之前设置全局默认值。

Checkify.configure({
  baseUrl: 'https://checkify.me',
  completeUrl: '/checkify/complete'
});

Checkify.bindForm(form, options)

Render 是一个验证按钮,将令牌写入隐藏输入,并在验证之前禁用提交。

Checkify.bindForm('#my-form', {
  passId: 'YOUR_PASS_ID',
  requestType: 'human',
  buttonTarget: '#checkify-wrap',
  submitButton: '#submit',
  hiddenInput: '#checkify_token',
  disableSubmitUntilVerified: true
});

bindForm options

Common options passed as the second argument to Checkify.bindForm(form, options):

方法描述
passIdCheckify Pass public ID (required unless set on the form via data-checkify-pass)
requestTypeRequest type (human, age_over_18, etc.)
buttonTargetContainer element where the verify button is rendered
submitButtonSubmit control to enable after verification
hiddenInputHidden field selector for request_id
disableSubmitUntilVerifiedWhen true, keeps submit disabled until verification succeeds

Checkify.createHumanGate(options)

在验证完成之前阻止内容的全页或容器门。

Checkify.createHumanGate({
  passId: 'YOUR_PASS_ID',
  requestType: 'human',
  container: '#gate-root',
  title: 'Verify to continue'
});

返回 URL 流程

当用户在 Checkify 应用程序中完成验证时,他们可能会在查询字符串中使用 checkify_request_id 返回到您的网站。 SDK 在加载时自动调用 Checkify.checkReturnedVerification()

Checkify.verify(options)

Start verification programmatically without auto-mounting HTML. Returns a promise that resolves when the user completes or cancels.

const result = await Checkify.verify({
  passId: 'YOUR_PASS_ID',
  requestType: 'human',
  container: document.getElementById('checkify-root')
});
console.log(result.requestId); // send to your server as request_id

事件

window.addEventListener('checkify:verified', (e) => {
  console.log('Verified', e.detail);
});

window.addEventListener('checkify:error', (e) => {
  console.error('Checkify error', e.detail);
});

Status polling (optional)

Most integrations should verify on form submit with POST /v1/qr/results/verify. For custom frontends without the embed, you may poll status while the user completes verification in the app.

服务器验证

方法

方法描述
Checkify.mount(root?)在可选根元素下挂载传递小部件
Checkify.bindForm(...)表单集成助手
Checkify.createHumanGate(...)人工验证门UI
Checkify.verify(options)编程验证流程
Checkify.checkReturnedVerification()处理应用程序切换后的返回URL