@inkress/admin-sdk 1.1.43 → 1.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +255 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +236 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +236 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/kyc.d.ts +107 -0
- package/dist/resources/kyc.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3473,6 +3473,62 @@ class PublicResource {
|
|
|
3473
3473
|
}
|
|
3474
3474
|
}
|
|
3475
3475
|
|
|
3476
|
+
/**
|
|
3477
|
+
* KYC document requirements by entity type
|
|
3478
|
+
* These are the standard documents required for each type of business entity
|
|
3479
|
+
*/
|
|
3480
|
+
const KYC_DOCUMENT_REQUIREMENTS = {
|
|
3481
|
+
personal: [
|
|
3482
|
+
'Proof of Identity',
|
|
3483
|
+
'Proof of Address',
|
|
3484
|
+
'Proof of Bank Account Ownership',
|
|
3485
|
+
],
|
|
3486
|
+
'sole-trader': [
|
|
3487
|
+
'Proof of Identity',
|
|
3488
|
+
'Proof of Address',
|
|
3489
|
+
'Proof of Bank Account Ownership',
|
|
3490
|
+
'Business Certificate',
|
|
3491
|
+
'Articles of Incorporation',
|
|
3492
|
+
],
|
|
3493
|
+
llc: [
|
|
3494
|
+
'Proof of Identity',
|
|
3495
|
+
'Proof of Address',
|
|
3496
|
+
'Proof of Bank Account Ownership',
|
|
3497
|
+
'Business Certificate',
|
|
3498
|
+
'Articles of Incorporation',
|
|
3499
|
+
'Annual Return',
|
|
3500
|
+
'Notice of Directors',
|
|
3501
|
+
'Notice of Secretary',
|
|
3502
|
+
'Tax Compliance Certificate',
|
|
3503
|
+
],
|
|
3504
|
+
'non-profit': [
|
|
3505
|
+
'Proof of Identity',
|
|
3506
|
+
'Proof of Address',
|
|
3507
|
+
'Proof of Bank Account Ownership',
|
|
3508
|
+
'Business Certificate',
|
|
3509
|
+
'Articles of Incorporation',
|
|
3510
|
+
'Annual Return',
|
|
3511
|
+
],
|
|
3512
|
+
alumni: [
|
|
3513
|
+
'Proof of Identity',
|
|
3514
|
+
'Proof of Address',
|
|
3515
|
+
'Proof of Bank Account Ownership',
|
|
3516
|
+
'Business Certificate',
|
|
3517
|
+
'Articles of Incorporation',
|
|
3518
|
+
'Annual Return',
|
|
3519
|
+
],
|
|
3520
|
+
other: [
|
|
3521
|
+
'Proof of Identity',
|
|
3522
|
+
'Proof of Address',
|
|
3523
|
+
'Proof of Bank Account Ownership',
|
|
3524
|
+
'Business Certificate',
|
|
3525
|
+
'Articles of Incorporation',
|
|
3526
|
+
'Annual Return',
|
|
3527
|
+
'Notice of Directors',
|
|
3528
|
+
'Notice of Secretary',
|
|
3529
|
+
'Tax Compliance Certificate',
|
|
3530
|
+
],
|
|
3531
|
+
};
|
|
3476
3532
|
// Field type definitions for query validation
|
|
3477
3533
|
const KYC_FIELD_TYPES = {
|
|
3478
3534
|
id: 'number',
|
|
@@ -3553,6 +3609,185 @@ class KycResource {
|
|
|
3553
3609
|
async updateBankInfo(data) {
|
|
3554
3610
|
return this.client.post('/legal_requests', data);
|
|
3555
3611
|
}
|
|
3612
|
+
// ============================================================================
|
|
3613
|
+
// KYC DOCUMENT REQUIREMENTS & STATUS
|
|
3614
|
+
// ============================================================================
|
|
3615
|
+
/**
|
|
3616
|
+
* Get required KYC documents for a specific entity type
|
|
3617
|
+
* This is a client-side method that doesn't make an API call
|
|
3618
|
+
*
|
|
3619
|
+
* @param entityType - The type of business entity
|
|
3620
|
+
* @returns Array of required document types
|
|
3621
|
+
*
|
|
3622
|
+
* @example
|
|
3623
|
+
* const docs = kyc.getRequiredDocuments('llc');
|
|
3624
|
+
* // Returns: ['Proof of Identity', 'Proof of Address', ...]
|
|
3625
|
+
*/
|
|
3626
|
+
getRequiredDocuments(entityType) {
|
|
3627
|
+
return [...KYC_DOCUMENT_REQUIREMENTS[entityType]];
|
|
3628
|
+
}
|
|
3629
|
+
/**
|
|
3630
|
+
* Get all KYC document requirements (without making an API call)
|
|
3631
|
+
* Useful for displaying the full list in your application
|
|
3632
|
+
*
|
|
3633
|
+
* @returns Complete mapping of entity types to required documents
|
|
3634
|
+
*
|
|
3635
|
+
* @example
|
|
3636
|
+
* const allRequirements = kyc.getAllRequirements();
|
|
3637
|
+
* console.log(allRequirements.llc); // ['Proof of Identity', ...]
|
|
3638
|
+
*/
|
|
3639
|
+
getAllRequirements() {
|
|
3640
|
+
return { ...KYC_DOCUMENT_REQUIREMENTS };
|
|
3641
|
+
}
|
|
3642
|
+
/**
|
|
3643
|
+
* Get KYC requirements and submission status for the authenticated merchant
|
|
3644
|
+
* Fetches all KYC requests and maps them to required documents
|
|
3645
|
+
*
|
|
3646
|
+
* @param entityType - The merchant's business entity type
|
|
3647
|
+
* @returns Complete KYC requirements with submission status
|
|
3648
|
+
*
|
|
3649
|
+
* @example
|
|
3650
|
+
* const status = await kyc.getRequirementsStatus('llc');
|
|
3651
|
+
* console.log(`Completion: ${status.completion_percentage}%`);
|
|
3652
|
+
* console.log(`Approved: ${status.total_approved}/${status.total_required}`);
|
|
3653
|
+
*
|
|
3654
|
+
* // Check individual document status
|
|
3655
|
+
* status.document_statuses.forEach(doc => {
|
|
3656
|
+
* console.log(`${doc.document_type}: ${doc.status || 'not submitted'}`);
|
|
3657
|
+
* });
|
|
3658
|
+
*/
|
|
3659
|
+
async getRequirementsStatus(entityType) {
|
|
3660
|
+
// Get required documents for this entity type
|
|
3661
|
+
const requiredDocuments = this.getRequiredDocuments(entityType);
|
|
3662
|
+
// Fetch all KYC requests for the authenticated merchant
|
|
3663
|
+
const params = {
|
|
3664
|
+
kind: 'document_submission',
|
|
3665
|
+
};
|
|
3666
|
+
const response = await this.list(params);
|
|
3667
|
+
if (response.state === 'error' || !response.result) {
|
|
3668
|
+
return {
|
|
3669
|
+
state: 'error',
|
|
3670
|
+
};
|
|
3671
|
+
}
|
|
3672
|
+
const kycRequests = response.result.entries || [];
|
|
3673
|
+
// Map submitted documents
|
|
3674
|
+
const submittedDocs = new Map();
|
|
3675
|
+
kycRequests.forEach(request => {
|
|
3676
|
+
var _a;
|
|
3677
|
+
const docType = (_a = request.data) === null || _a === void 0 ? void 0 : _a.document_type;
|
|
3678
|
+
if (docType && requiredDocuments.includes(docType)) {
|
|
3679
|
+
// Keep the most recent submission for each document type
|
|
3680
|
+
const existing = submittedDocs.get(docType);
|
|
3681
|
+
if (!existing || new Date(request.inserted_at) > new Date(existing.inserted_at)) {
|
|
3682
|
+
submittedDocs.set(docType, request);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
// Build document statuses
|
|
3687
|
+
const documentStatuses = requiredDocuments.map(docType => {
|
|
3688
|
+
var _a;
|
|
3689
|
+
const submission = submittedDocs.get(docType);
|
|
3690
|
+
if (!submission) {
|
|
3691
|
+
return {
|
|
3692
|
+
document_type: docType,
|
|
3693
|
+
required: true,
|
|
3694
|
+
submitted: false,
|
|
3695
|
+
};
|
|
3696
|
+
}
|
|
3697
|
+
// Convert integer status to string using translator
|
|
3698
|
+
// The API returns status as a number, but the type says it's a string
|
|
3699
|
+
const statusString = StatusTranslator.toStringWithoutContext(submission.status, 'legal_request');
|
|
3700
|
+
// Map to our simplified status types
|
|
3701
|
+
let status;
|
|
3702
|
+
if (statusString) {
|
|
3703
|
+
if (statusString === 'pending' || statusString === 'in_review') {
|
|
3704
|
+
status = 'pending';
|
|
3705
|
+
}
|
|
3706
|
+
else if (statusString === 'approved') {
|
|
3707
|
+
status = 'approved';
|
|
3708
|
+
}
|
|
3709
|
+
else if (statusString === 'rejected') {
|
|
3710
|
+
status = 'rejected';
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
const reviewedAt = submission.updated_at !== submission.inserted_at
|
|
3714
|
+
? submission.updated_at
|
|
3715
|
+
: undefined;
|
|
3716
|
+
return {
|
|
3717
|
+
document_type: docType,
|
|
3718
|
+
required: true,
|
|
3719
|
+
submitted: true,
|
|
3720
|
+
status,
|
|
3721
|
+
submitted_at: submission.inserted_at,
|
|
3722
|
+
reviewed_at: reviewedAt,
|
|
3723
|
+
rejection_reason: (_a = submission.data) === null || _a === void 0 ? void 0 : _a.rejection_reason,
|
|
3724
|
+
};
|
|
3725
|
+
});
|
|
3726
|
+
// Calculate statistics
|
|
3727
|
+
const totalRequired = requiredDocuments.length;
|
|
3728
|
+
const totalSubmitted = documentStatuses.filter(d => d.submitted).length;
|
|
3729
|
+
const totalApproved = documentStatuses.filter(d => d.status === 'approved').length;
|
|
3730
|
+
const totalRejected = documentStatuses.filter(d => d.status === 'rejected').length;
|
|
3731
|
+
const totalPending = documentStatuses.filter(d => d.status === 'pending').length;
|
|
3732
|
+
const completionPercentage = totalRequired > 0
|
|
3733
|
+
? Math.round((totalApproved / totalRequired) * 100)
|
|
3734
|
+
: 0;
|
|
3735
|
+
const isComplete = totalApproved === totalRequired;
|
|
3736
|
+
const requirements = {
|
|
3737
|
+
entity_type: entityType,
|
|
3738
|
+
required_documents: requiredDocuments,
|
|
3739
|
+
document_statuses: documentStatuses,
|
|
3740
|
+
total_required: totalRequired,
|
|
3741
|
+
total_submitted: totalSubmitted,
|
|
3742
|
+
total_approved: totalApproved,
|
|
3743
|
+
total_rejected: totalRejected,
|
|
3744
|
+
total_pending: totalPending,
|
|
3745
|
+
completion_percentage: completionPercentage,
|
|
3746
|
+
is_complete: isComplete,
|
|
3747
|
+
};
|
|
3748
|
+
return {
|
|
3749
|
+
state: 'ok',
|
|
3750
|
+
result: requirements,
|
|
3751
|
+
};
|
|
3752
|
+
}
|
|
3753
|
+
/**
|
|
3754
|
+
* Check if all required documents have been approved for the authenticated merchant
|
|
3755
|
+
*
|
|
3756
|
+
* @param entityType - The merchant's business entity type
|
|
3757
|
+
* @returns True if all required documents are approved
|
|
3758
|
+
*
|
|
3759
|
+
* @example
|
|
3760
|
+
* const isComplete = await kyc.isKycComplete('llc');
|
|
3761
|
+
* if (isComplete) {
|
|
3762
|
+
* console.log('Merchant is fully verified!');
|
|
3763
|
+
* }
|
|
3764
|
+
*/
|
|
3765
|
+
async isKycComplete(entityType) {
|
|
3766
|
+
var _a;
|
|
3767
|
+
const response = await this.getRequirementsStatus(entityType);
|
|
3768
|
+
return ((_a = response.result) === null || _a === void 0 ? void 0 : _a.is_complete) || false;
|
|
3769
|
+
}
|
|
3770
|
+
/**
|
|
3771
|
+
* Get list of missing (not submitted or rejected) documents for the authenticated merchant
|
|
3772
|
+
*
|
|
3773
|
+
* @param entityType - The merchant's business entity type
|
|
3774
|
+
* @returns Array of document types that need to be submitted or resubmitted
|
|
3775
|
+
*
|
|
3776
|
+
* @example
|
|
3777
|
+
* const missing = await kyc.getMissingDocuments('llc');
|
|
3778
|
+
* if (missing.length > 0) {
|
|
3779
|
+
* console.log('Please submit:', missing.join(', '));
|
|
3780
|
+
* }
|
|
3781
|
+
*/
|
|
3782
|
+
async getMissingDocuments(entityType) {
|
|
3783
|
+
const response = await this.getRequirementsStatus(entityType);
|
|
3784
|
+
if (response.state === 'error' || !response.result) {
|
|
3785
|
+
return [];
|
|
3786
|
+
}
|
|
3787
|
+
return response.result.document_statuses
|
|
3788
|
+
.filter(doc => !doc.submitted || doc.status === 'rejected')
|
|
3789
|
+
.map(doc => doc.document_type);
|
|
3790
|
+
}
|
|
3556
3791
|
}
|
|
3557
3792
|
|
|
3558
3793
|
class PaymentLinksResource {
|
|
@@ -4723,6 +4958,7 @@ exports.FinancialRequestQueryBuilder = FinancialRequestQueryBuilder;
|
|
|
4723
4958
|
exports.HttpClient = HttpClient;
|
|
4724
4959
|
exports.InkressApiError = InkressApiError;
|
|
4725
4960
|
exports.InkressSDK = InkressSDK;
|
|
4961
|
+
exports.KYC_DOCUMENT_REQUIREMENTS = KYC_DOCUMENT_REQUIREMENTS;
|
|
4726
4962
|
exports.MERCHANT_FIELD_TYPES = MERCHANT_FIELD_TYPES;
|
|
4727
4963
|
exports.MerchantQueryBuilder = MerchantQueryBuilder;
|
|
4728
4964
|
exports.ORDER_FIELD_TYPES = ORDER_FIELD_TYPES;
|