105 lines
3.4 KiB
Plaintext
105 lines
3.4 KiB
Plaintext
// Example 7: KYC Info and Session Management
|
|
|
|
print("=== KYC Example ===\n");
|
|
|
|
// Get a context to work with
|
|
print("1. Getting context...");
|
|
let ctx = get_context(["alice", "bob"]);
|
|
print(" ✓ Context created: " + ctx.context_id());
|
|
|
|
// Create KYC info objects with builder pattern
|
|
print("\n2. Creating KYC info objects...");
|
|
|
|
let john_info = new_kyc_info()
|
|
.client_id("CLIENT_001")
|
|
.first_name("John")
|
|
.last_name("Doe")
|
|
.email("john.doe@example.com")
|
|
.phone("+1234567890")
|
|
.date_of_birth("1990-01-15")
|
|
.nationality("US")
|
|
.address("123 Main Street")
|
|
.city("New York")
|
|
.country("US")
|
|
.postal_code("10001")
|
|
.provider("idenfy");
|
|
|
|
print(" ✓ Created KYC info for John Doe");
|
|
|
|
let jane_info = new_kyc_info()
|
|
.client_id("CLIENT_002")
|
|
.first_name("Jane")
|
|
.last_name("Smith")
|
|
.email("jane.smith@example.com")
|
|
.phone("+9876543210")
|
|
.date_of_birth("1985-05-20")
|
|
.nationality("GB")
|
|
.provider("idenfy");
|
|
|
|
print(" ✓ Created KYC info for Jane Smith");
|
|
|
|
// Display info
|
|
print("\n3. KYC information...");
|
|
print(" John - ID: " + john_info.get_id());
|
|
print(" John - Client ID: " + john_info.get_client_id());
|
|
print(" John - Name: " + john_info.get_first_name() + " " + john_info.get_last_name());
|
|
print(" John - Email: " + john_info.get_email());
|
|
print(" John - Provider: " + john_info.get_provider());
|
|
|
|
print(" Jane - ID: " + jane_info.get_id());
|
|
print(" Jane - Client ID: " + jane_info.get_client_id());
|
|
print(" Jane - Name: " + jane_info.get_first_name() + " " + jane_info.get_last_name());
|
|
|
|
// Save KYC info to context
|
|
print("\n4. Saving KYC info to context...");
|
|
let john_id = ctx.save(john_info);
|
|
print(" ✓ Saved John's KYC info with ID: " + john_id);
|
|
|
|
let jane_id = ctx.save(jane_info);
|
|
print(" ✓ Saved Jane's KYC info with ID: " + jane_id);
|
|
|
|
// Create KYC verification sessions
|
|
print("\n5. Creating KYC verification sessions...");
|
|
|
|
let john_session = new_kyc_session("CLIENT_001", "idenfy")
|
|
.callback_url("https://example.com/kyc/callback")
|
|
.success_url("https://example.com/kyc/success")
|
|
.error_url("https://example.com/kyc/error")
|
|
.locale("en");
|
|
|
|
print(" ✓ Created verification session for John");
|
|
|
|
let jane_session = new_kyc_session("CLIENT_002", "idenfy")
|
|
.callback_url("https://example.com/kyc/callback")
|
|
.success_url("https://example.com/kyc/success")
|
|
.error_url("https://example.com/kyc/error")
|
|
.locale("en");
|
|
|
|
print(" ✓ Created verification session for Jane");
|
|
|
|
// Display session info
|
|
print("\n6. Session information...");
|
|
print(" John's session - ID: " + john_session.get_id());
|
|
print(" John's session - Client ID: " + john_session.get_client_id());
|
|
print(" John's session - Provider: " + john_session.get_provider());
|
|
|
|
// Save KYC sessions to context
|
|
print("\n7. Saving KYC sessions to context...");
|
|
let john_session_id = ctx.save(john_session);
|
|
print(" ✓ Saved John's session with ID: " + john_session_id);
|
|
|
|
let jane_session_id = ctx.save(jane_session);
|
|
print(" ✓ Saved Jane's session with ID: " + jane_session_id);
|
|
|
|
// List all KYC clients in context
|
|
print("\n8. Listing KYC clients in context...");
|
|
let client_ids = ctx.list("kyc_clients");
|
|
print(" ✓ Found " + client_ids.len() + " KYC clients in context");
|
|
|
|
// List all KYC sessions in context
|
|
print("\n9. Listing KYC sessions in context...");
|
|
let session_ids = ctx.list("kyc_sessions");
|
|
print(" ✓ Found " + session_ids.len() + " KYC sessions in context");
|
|
|
|
print("\n=== KYC Example Complete ===");
|