fingerprint 返回该值。当同一客户多次注册同一张卡时,Yuno 会创建多个独立的注册,各自具有不同的 vaulted_token 值,而 fingerprint 可帮助您检测重复项。
关键特性:
- 在同一张卡的多次注册中保持一致
- 对每个不同的卡号是唯一的
- 不暴露完整卡号,从而保障 PCI 合规
- 无需存储或访问敏感卡数据即可实现去重
在客户输入卡片信息之前,您无法检查 fingerprint。这是 PCI 合规要求。
工作原理
同一张卡,多次注册
// First enrollment
{
"vaulted_token": "b82b7682-def1-4d46-ad51-7da446b2966c",
"card_data": {
"fingerprint": "fp_abc123xyz789",
"iin": "41111111",
"lfd": "1111"
}
}
// Second enrollment of the SAME card
{
"vaulted_token": "7ce53292-c402-4e3d-8ddd-a49268633294", // Different token
"card_data": {
"fingerprint": "fp_abc123xyz789", // Same fingerprint!
"iin": "41111111",
"lfd": "1111"
}
}
不同的卡片
{
"vaulted_token": "...",
"card_data": {
"fingerprint": "fp_different456", // Different fingerprint
"iin": "52222222",
"lfd": "2222"
}
}
为什么会出现重复注册
为避免运营问题,Yuno 不会自动阻止重复的卡片注册。当客户多次注册同一张卡时:- 每次注册都会创建一个新的
vaulted_token - 不会自动去重
- 无论到期日期或持卡人信息是否发生变化,均适用此规则
实施指南
第 1 步:检索现有支付方式
使用检索已注册的支付方式 endpoint 列出客户现有的卡片。GET /v1/customers/{customer_id}/payment-methods
{
"payment_methods": [
{
"vaulted_token": "token_1",
"card_data": {
"fingerprint": "fp_abc123",
"iin": "41111111",
"lfd": "1111",
"brand": "VISA"
}
},
{
"vaulted_token": "token_2",
"card_data": {
"fingerprint": "fp_xyz789",
"iin": "52222222",
"lfd": "2222",
"brand": "MASTERCARD"
}
}
]
}
第 2 步:注册后检查重复项
async function checkForDuplicates(customerId, newCardFingerprint) {
// Get existing payment methods
const existingMethods = await getCustomerPaymentMethods(customerId);
// Extract fingerprints (filter out nulls)
const existingFingerprints = existingMethods
.map(method => method.card_data?.fingerprint)
.filter(Boolean);
// Check for duplicates
const isDuplicate = existingFingerprints.includes(newCardFingerprint);
if (isDuplicate) {
// Handle duplicate (see options below)
console.log('Duplicate card detected');
}
return isDuplicate;
}
第 3 步:处理重复项
检测到重复项时,您有几种选择: **推荐:**对于大多数集成,推荐选项 A(阻止注册)。仅当您的产品有意允许同一张卡保存多个副本时,才使用 B 或 C。选项 A:阻止注册(推荐,用户体验最佳)
// Before enrollment, fetch existing cards and display them
// Show user: "You already have these cards saved:"
// - VISA ending in 1111
// - MASTERCARD ending in 2222
//
// This prevents the duplicate enrollment from happening
选项 B:注册后通知
enrollmentStatus: async ({ status, vaultedToken }) => {
if (status === 'ENROLLED' && vaultedToken) {
const newCard = await getPaymentMethodDetails(customerId, vaultedToken);
const isDuplicate = await checkForDuplicates(
customerId,
newCard.card_data?.fingerprint
);
if (isDuplicate) {
// Notify user
showNotification("This card was already saved. We've removed the duplicate.");
// Optionally remove the duplicate
await unenrollPaymentMethod(customerId, vaultedToken);
} else {
showNotification("Card saved successfully!");
}
}
}
选项 C:保留两次注册
// Allow duplicates for customer flexibility
// Display all cards with visual indicators:
// - VISA •••• 1111 (Primary)
// - VISA •••• 1111 (Duplicate - added Jan 15)
完整实施示例
// Enrollment flow with duplicate detection
const enrollmentFlow = {
// 1. Customer completes enrollment via SDK
enrollmentStatus: async ({ status, vaultedToken }) => {
if (status !== 'ENROLLED' || !vaultedToken) {
return;
}
try {
// 2. Fetch the newly enrolled payment method
const newCard = await fetch(
`/api/payment-methods/${vaultedToken}`
).then(r => r.json());
const newFingerprint = newCard.card_data?.fingerprint;
// 3. Handle cases where fingerprint is not available
if (!newFingerprint) {
console.warn('Fingerprint not available for this card');
showNotification("Card saved successfully!");
return;
}
// 4. Get existing cards for this customer
const existingCards = await fetch(
`/api/customers/${customerId}/payment-methods`
).then(r => r.json());
// 5. Check for duplicates
const duplicates = existingCards.payment_methods.filter(card =>
card.card_data?.fingerprint === newFingerprint &&
card.vaulted_token !== vaultedToken // Exclude the newly enrolled card
);
// 6. Handle duplicate
if (duplicates.length > 0) {
const confirmRemove = await showConfirmDialog(
"This card is already saved to your account. " +
"Would you like to remove the duplicate?"
);
if (confirmRemove) {
await fetch(
`/api/payment-methods/${vaultedToken}`,
{ method: 'DELETE' }
);
showNotification("Duplicate card removed.");
} else {
showNotification("Card saved. You now have multiple copies of this card.");
}
} else {
showNotification("Card saved successfully!");
}
} catch (error) {
console.error('Error checking for duplicates:', error);
// Fail gracefully - card is still enrolled
showNotification("Card saved successfully!");
}
}
};
重要注意事项
Fingerprint 可用性
对于某些支付方式或服务提供商,fingerprint 字段可能为 null。使用前请始终检查 fingerprint 是否存在:
const fingerprint = card.card_data?.fingerprint;
if (!fingerprint) {
// Handle this case gracefully
// Option 1: Skip duplicate detection
// Option 2: Use alternative matching (IIN + LFD)
// Option 3: Log and notify your team
console.warn('Fingerprint not available');
}
// Fallback: Match by IIN + LFD + expiration
const isSameCard = (card1, card2) => {
return card1.card_data?.iin === card2.card_data?.iin &&
card1.card_data?.lfd === card2.card_data?.lfd &&
card1.card_data?.expiration_month === card2.card_data?.expiration_month &&
card1.card_data?.expiration_year === card2.card_data?.expiration_year;
};
不同的卡片可能具有相同的 IIN 和 LFD。
卡片更新
卡片更新时 fingerprint 的行为:| 变更 | Fingerprint 行为 |
|---|---|
| 卡号变更 | ✅ 生成新的 fingerprint |
| 到期日期变更 | ❌ fingerprint 保持不变 |
| 持卡人姓名变更 | ❌ fingerprint 保持不变 |
| 卡片重新发行(卡号相同) | ❌ fingerprint 保持不变 |
网络令牌 fingerprint
对于网络令牌,Yuno 使用network_token_fingerprint,其工作方式与卡片 fingerprint 类似,作用范围限定于您的组织以及 PCI vault 中网络令牌的唯一标识符。这意味着同一 PAN 的重复注册可以映射到同一个网络令牌。更多详情,请参阅 Network Tokens。
使用场景
- 避免钱包杂乱
帮助用户避免多次保存同一张卡:
// Show before enrollment form
"You already have these cards saved:
- VISA ending in 1111
- MASTERCARD ending in 2222"
- 改善用户体验
自动清理重复项:
if (isDuplicate) {
await removeOlderDuplicate(vaultedToken);
showMessage("We updated your saved card.");
}
- 数据清理
批量识别并删除重复注册:
async function cleanupDuplicates(customerId) {
const cards = await getPaymentMethods(customerId);
const fingerprints = new Map();
for (const card of cards.payment_methods) {
const fp = card.card_data?.fingerprint;
if (!fp) continue;
if (fingerprints.has(fp)) {
// Keep the most recent, remove older duplicates
const existing = fingerprints.get(fp);
const newerCard = new Date(card.created_at) > new Date(existing.created_at)
? card
: existing;
const olderCard = newerCard === card ? existing : card;
await unenrollPaymentMethod(customerId, olderCard.vaulted_token);
fingerprints.set(fp, newerCard);
} else {
fingerprints.set(fp, card);
}
}
}
- 分析与监控
跟踪重复注册率:
// Log duplicate events for monitoring
if (isDuplicate) {
analytics.track('duplicate_card_enrolled', {
customer_id: customerId,
fingerprint: fingerprint.substring(0, 10), // Partial for privacy
duplicate_count: duplicates.length + 1
});
}