处理 3DS 验证
用于处理需要客户进行 3D Secure(3DS)验证的扣款请求。
当您提交扣款请求后,若收到的响应中包含 "status_code": "waiting_for_shopper_action",请按照以下步骤处理 3DS 流程:
准备挑战页面:包含以下字段的 HTML 表单:
challenge_jwtchallenge_md
自动提交表单:将该表单自动提交至
challenge_url接口。客户完成验证:客户在挑战页面上完成 3DS 验证后,支付请求将提交进行身份认证。
以下是一个嵌入 iframe 的 3DS 验证示例:
<body>
....
<iframe id="iframe-name" height="250" width="400"></iframe>
....
<script>
....
function onShopperActionForm(form) {
const formElement = document.createElement('form');
formElement.method = form.method;
formElement.action = form.action;
formElement.target = 'iframe-name';
// 创建并添加 input 元素到表单中
form.inputs.forEach(inputData => {
const input = document.createElement('input');
input.type = inputData.type;
input.name = inputData.name;
input.value = inputData.value;
formElement.appendChild(input);
});
// 将表单添加到 body 中
document.getElementsByTagName('body')[0].appendChild(formElement);
// 自动提交表单
formElement.submit();
}
....
</script>
</body>
类型:重定向
提交付款后,如果您收到“status_code”为“waiting_for_shopper_action”且“type”为“redirection”的响应,您可以按照以下步骤处理重定向类型的 3DS 验证:
从 shopper_action.redirection 对象中提取 URL。
使用指定方法(GET)将客户重定向到此 URL。
顾客在跳转后的页面上完成 3DS 验证。
完成后,客户将被重定向回您的返回 URL 并查看结果。
最后更新于
这有帮助吗?