UNPKG

@adyen/react-native

Version:

Wraps Adyen Checkout Drop-In and Components for iOS and Android for convenient use with React Native

37 lines (30 loc) 1.02 kB
import type { NativeModule } from 'react-native'; import type { BaseConfiguration, PaymentAction, PaymentDetailsData, } from '../../core'; import type { ActionModule } from './AdyenAction'; /** Native module interface specific to Action */ interface ActionNativeModule extends NativeModule { handle( action: PaymentAction, configuration: BaseConfiguration ): Promise<PaymentDetailsData>; hide(success: boolean): void; getConstants(): { threeDS2SdkVersion: string }; } export class ActionModuleWrapper implements ActionModule { private readonly nativeModule: ActionNativeModule; public threeDS2SdkVersion: string; constructor(nativeModule: ActionNativeModule) { this.nativeModule = nativeModule; this.threeDS2SdkVersion = nativeModule.getConstants().threeDS2SdkVersion; } handle(action: PaymentAction, configuration: BaseConfiguration) { return this.nativeModule.handle(action, configuration); } hide(success: boolean) { this.nativeModule.hide(success); } }