IdentityVerificationSheet
IdentityVerificationSheetは、Stripe Identityを使用できます。Stripe Identityを使用すると、グローバルユーザーの身元をプログラムで確認できるため、詐欺師からの攻撃を防ぐと同時に、正当な顧客の摩擦を最小限に抑えることができます。これは簡単な方法です。この機能は日本ではまだ利用することはできません。
Androidでのインストール
あなたのプロジェクトの AndroidManifest.xml
と res/values/strings.xml
を以下のように変更してください。
+ <meta-data
+ android:name="com.getcapacitor.community.stripe.enableIdentifier"
+ android:value="@bool/enableIdentifier"/>
+ <bool name="enableIdentifier">true</bool>
また、 res/values/styles.xml
を以下のように変更してください。
- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+ <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
parent
に指定するMaterialComponentsはどれでも可能です。
詳細はこちらをご覧ください。.
すべてのプロセスはこちらにあります。 https://github.com/capacitor-community/stripe/commit/f514d893e9193bed2edbaf52c0d3ed1d534c7890
使い方
import { Stripe } from '@capacitor-community/stripe';
await Stripe.createIdentityVerificationSheet({
ephemeralKeySecret,
verificationId,
});
const result = await Stripe.presentIdentityVerificationSheet();
🐾 Implements Guide
1. createIdentityVerificationSheet
Props ephemeralKeySecret
and verificationId
is required. This requires to generate at server side. See
Stripe Identity for more details. https://stripe.com/docs/identity/verify-identity-documents?platform=ios&type=new-integration#create-a-verificationsession
import { Stripe } from '@capacitor-community/stripe';
(async () => {
// Connect to your backend endpoint, and get every key.
const { verficationSessionId, ephemeralKeySecret } = await this.http.post<{
verficationSessionId: string;
ephemeralKeySecret: string;
}>(environment.api + 'identify', {}).pipe(first()).toPromise(Promise);
// prepare IdentityVerificationSheet with createIdentityVerificationSheet.
await Stripe.createIdentityVerificationSheet({
ephemeralKeySecret,
verificationId: verficationSessionId,
})
})();
You can use options of
CreateIdentityVerificationSheetOption
on createIdentityVerificationSheet
.
method
createIdentityVerificationSheet(...)
createIdentityVerificationSheet(options: CreateIdentityVerificationSheetOption) => Promise<void>
Props ephemeralKeySecret
and verificationId
is required.
interface
CreateIdentityVerificationSheetOption
Prop Type verificationId
string
ephemeralKeySecret
string
2. presentIdentityVerificationSheet
When you do presentIdentityVerificationSheet
method, plugin present PaymentSheet and get result. This method must do after
createIdentityVerificationSheet
.
(async () => {
// present IdentityVerificationSheet and get result.
const result = await Stripe.presentIdentityVerificationSheet()
if (result.identityVerificationResult === IdentityVerificationSheetEventsEnum.Completed) {
// Happy path
}
})();
You can get
IdentityVerificationSheetResultInterface
from presentIdentityVerificationSheet
.
method
presentIdentityVerificationSheet()
presentIdentityVerificationSheet() => Promise<{ identityVerificationResult: IdentityVerificationSheetResultInterface; }>
IdentityVerificationSheetResultInterface
is created from Enum of IdentityVerificationSheetEventsEnum
. So you should import and check result.
type alias
IdentityVerificationSheetResultInterface
IdentityVerificationSheetEventsEnum.Completed | IdentityVerificationSheetEventsEnum.Canceled | IdentityVerificationSheetEventsEnum.Failed
enum
IdentityVerificationSheetEventsEnum
Members Value Loaded
"identityVerificationSheetLoaded"
FailedToLoad
"identityVerificationSheetFailedToLoad"
Completed
"identityVerificationSheetCompleted"
Canceled
"identityVerificationSheetCanceled"
Failed
"identityVerificationSheetFailed"
3. addListener
Method of IdentityVerificationSheet notify any listeners. If you want to get event of IdentityVerificationSheet process is 'Completed', you should add
IdentityVerificationSheetEventsEnum.Completed
listener to
Stripe
object:
// be able to get event of IdentityVerificationSheet
Stripe.addListener(IdentityVerificationSheetEventsEnum.Completed, () => {
console.log('IdentityVerificationSheetEventsEnum.Completed');
});
The event name you can use is
IdentityVerificationSheetEventsEnum
.
enum
IdentityVerificationSheetEventsEnum
Members Value Loaded
"identityVerificationSheetLoaded"
FailedToLoad
"identityVerificationSheetFailedToLoad"
Completed
"identityVerificationSheetCompleted"
Canceled
"identityVerificationSheetCanceled"
Failed
"identityVerificationSheetFailed"