capacitor-portone
v0.0.6
Published
Capacitor PortOne Plugin
Readme
capacitor-portone
Capacitor plugin for PortOne (formerly iamport) identity verification on Android, iOS, and Web.
Install
npm install capacitor-portone
npx cap syncConfiguration
Android
1. Add JitPack Repository
Add JitPack repository to your project. Open android/settings.gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // Add this line
}
}Or if using older Gradle setup, add to android/build.gradle:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // Add this line
}
}2. Enable Core Library Desugaring
Add to your app's android/app/build.gradle:
android {
// ... other configurations ...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
coreLibraryDesugaringEnabled true // Add this line
}
}
dependencies {
// ... other dependencies ...
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4' // Add this line
}3. MainActivity
Make sure your app's MainActivity extends ComponentActivity (which it should by default in Capacitor apps).
iOS
No additional setup required. The PortOne SDK is bundled with the plugin.
Usage
import { CapacitorPortOne } from 'capacitor-portone';
async function verifyIdentity() {
try {
const result = await CapacitorPortOne.requestIdentityVerification({
storeId: 'your-store-id',
identityVerificationId: 'unique-verification-id',
channelKey: 'your-channel-key',
// Optional: redirectUrl is recommended for web platform
redirectUrl: `${window.location.origin}/verification-complete`
});
if (result.success) {
console.log('Verification successful:', result.identityVerificationId);
// Send identityVerificationId to your server for verification
} else {
console.error('Verification failed:', result.code, result.message);
}
} catch (error) {
console.error('Error during verification:', error);
}
}Web Platform Notes
The plugin uses @portone/browser-sdk for web platform support. The SDK is automatically installed as a dependency.
- redirectUrl: While optional in the API, it's recommended for web platforms, especially on mobile browsers where redirect mode is commonly used.
- Server-side verification: After successful verification, send the
identityVerificationIdto your server to verify the authentication status using PortOne's REST API.
Platform Support
- ✅ Android
- ✅ iOS
- ✅ Web
API
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
requestIdentityVerification(...)
requestIdentityVerification(request: IdentityVerificationRequest) => Promise<IdentityVerificationResponse>Request identity verification using PortOne
| Param | Type | Description |
| ------------- | ----------------------------------------------------------------------------------- | ------------------------------------------ |
| request | IdentityVerificationRequest | - Identity verification request parameters |
Returns: Promise<IdentityVerificationResponse>
Interfaces
IdentityVerificationSuccessResponse
| Prop | Type |
| ---------------------------- | ------------------- |
| success | true |
| identityVerificationId | string |
IdentityVerificationFailResponse
| Prop | Type |
| ------------- | ------------------- |
| success | false |
| code | string |
| message | string |
IdentityVerificationRequest
| Prop | Type |
| ---------------------------- | ------------------- |
| storeId | string |
| identityVerificationId | string |
| channelKey | string |
| redirectUrl | string |
Type Aliases
IdentityVerificationResponse
IdentityVerificationSuccessResponse | IdentityVerificationFailResponse
IdentityVerificationRequest
{ storeId: string; identityVerificationId: string; channelKey?: string; pgProvider?: Entity.PgProvider; isTestChannel?: boolean; customer?: Entity.Customer; windowType?: Entity.WindowTypes; redirectUrl?: string; customData?: string; bypass?: Entity.IdentityVerificationBypass; popup?: Entity.Popup; iframe?: Entity.Iframe; }
