react-native-klarna-inapp-sdk 2.4.9 → 2.5.0
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 +2 -1
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/KlarnaMobileSDKPackage.java +5 -1
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/checkout/KlarnaCheckoutViewManager.java +4 -10
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/WebViewResizeObserver.java +28 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/event/ComponentEventSender.java +5 -1
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/ui/ResizeObserverWrapperView.java +2 -2
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/ui/WrapperView.java +2 -2
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/ui/YogaLayoutHelper.java +39 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/expresscheckout/KlarnaExpressCheckoutViewCallback.kt +30 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/expresscheckout/KlarnaExpressCheckoutViewEventSender.kt +80 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/expresscheckout/KlarnaExpressCheckoutViewManager.java +544 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/osm/KlarnaOSMViewEventHandler.java +30 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/osm/KlarnaOSMViewEventSender.java +64 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/osm/KlarnaOSMViewManager.java +356 -0
- package/android/src/newarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaExpressCheckoutViewSpec.java +31 -0
- package/android/src/newarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaOSMViewSpec.java +31 -0
- package/android/src/oldarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaExpressCheckoutViewSpec.java +36 -0
- package/android/src/oldarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaOSMViewSpec.java +32 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/KlarnaMobileSDKPackageTest.java +5 -1
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/common/ui/YogaLayoutHelperTest.java +79 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/expresscheckout/KlarnaExpressCheckoutViewManagerTest.java +259 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/osm/KlarnaOSMViewEventHandlerTest.java +136 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/osm/KlarnaOSMViewEventSenderTest.java +184 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/osm/KlarnaOSMViewManagerTest.java +385 -0
- package/ios/RNKlarnaMobileSDK.xcodeproj/project.pbxproj +55 -1
- package/ios/Sources/KlarnaExpressCheckoutViewManager.h +5 -0
- package/ios/Sources/KlarnaExpressCheckoutViewManager.mm +39 -0
- package/ios/Sources/KlarnaOSMViewManager.h +5 -0
- package/ios/Sources/KlarnaOSMViewManager.mm +59 -0
- package/ios/Sources/view/KlarnaExpressCheckoutButtonDelegateProxy.swift +145 -0
- package/ios/Sources/view/KlarnaExpressCheckoutViewWrapper.h +41 -0
- package/ios/Sources/view/KlarnaOSMViewWrapper.h +48 -0
- package/ios/Sources/view/newarch/KlarnaExpressCheckoutViewWrapper.mm +228 -0
- package/ios/Sources/view/newarch/KlarnaOSMViewWrapper.mm +294 -0
- package/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm +20 -13
- package/ios/Sources/view/oldarch/KlarnaExpressCheckoutViewWrapper.mm +222 -0
- package/ios/Sources/view/oldarch/KlarnaOSMViewWrapper.mm +273 -0
- package/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm +11 -13
- package/ios/Tests/KlarnaExpressCheckoutViewWrapperTests.m +391 -0
- package/ios/Tests/KlarnaOSMViewWrapperTests.m +450 -0
- package/ios/Tests/KlarnaStandaloneWebViewWrapperTests.m +105 -0
- package/lib/commonjs/KlarnaExpressCheckoutView.js +75 -0
- package/lib/commonjs/KlarnaExpressCheckoutView.js.map +1 -0
- package/lib/commonjs/KlarnaOSMView.js +94 -0
- package/lib/commonjs/KlarnaOSMView.js.map +1 -0
- package/lib/commonjs/index.js +99 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/KlarnaExpressCheckoutViewNativeComponent.js +11 -0
- package/lib/commonjs/specs/KlarnaExpressCheckoutViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KlarnaOSMViewNativeComponent.js +16 -0
- package/lib/commonjs/specs/KlarnaOSMViewNativeComponent.js.map +1 -0
- package/lib/commonjs/types/button/KlarnaButtonShape.js +14 -0
- package/lib/commonjs/types/button/KlarnaButtonShape.js.map +1 -0
- package/lib/commonjs/types/button/KlarnaButtonStyle.js +13 -0
- package/lib/commonjs/types/button/KlarnaButtonStyle.js.map +1 -0
- package/lib/commonjs/types/button/KlarnaButtonTheme.js +14 -0
- package/lib/commonjs/types/button/KlarnaButtonTheme.js.map +1 -0
- package/lib/commonjs/types/common/KlarnaExpressCheckoutSessionOptions.js +9 -0
- package/lib/commonjs/types/common/KlarnaExpressCheckoutSessionOptions.js.map +1 -0
- package/lib/commonjs/types/common/KlarnaOSMPlacementKey.js +2 -0
- package/lib/commonjs/types/common/KlarnaOSMPlacementKey.js.map +1 -0
- package/lib/commonjs/types/common/KlarnaTheme.js +14 -0
- package/lib/commonjs/types/common/KlarnaTheme.js.map +1 -0
- package/lib/module/KlarnaExpressCheckoutView.js +64 -0
- package/lib/module/KlarnaExpressCheckoutView.js.map +1 -0
- package/lib/module/KlarnaOSMView.js +84 -0
- package/lib/module/KlarnaOSMView.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/KlarnaExpressCheckoutViewNativeComponent.js +3 -0
- package/lib/module/specs/KlarnaExpressCheckoutViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KlarnaOSMViewNativeComponent.js +7 -0
- package/lib/module/specs/KlarnaOSMViewNativeComponent.js.map +1 -0
- package/lib/module/types/button/KlarnaButtonShape.js +7 -0
- package/lib/module/types/button/KlarnaButtonShape.js.map +1 -0
- package/lib/module/types/button/KlarnaButtonStyle.js +6 -0
- package/lib/module/types/button/KlarnaButtonStyle.js.map +1 -0
- package/lib/module/types/button/KlarnaButtonTheme.js +7 -0
- package/lib/module/types/button/KlarnaButtonTheme.js.map +1 -0
- package/lib/module/types/common/KlarnaExpressCheckoutSessionOptions.js +2 -0
- package/lib/module/types/common/KlarnaExpressCheckoutSessionOptions.js.map +1 -0
- package/lib/module/types/common/KlarnaOSMPlacementKey.js +2 -0
- package/lib/module/types/common/KlarnaOSMPlacementKey.js.map +1 -0
- package/lib/module/types/common/KlarnaTheme.js +7 -0
- package/lib/module/types/common/KlarnaTheme.js.map +1 -0
- package/lib/typescript/KlarnaExpressCheckoutView.d.ts +47 -0
- package/lib/typescript/KlarnaExpressCheckoutView.d.ts.map +1 -0
- package/lib/typescript/KlarnaOSMView.d.ts +36 -0
- package/lib/typescript/KlarnaOSMView.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/specs/KlarnaExpressCheckoutViewNativeComponent.d.ts +45 -0
- package/lib/typescript/specs/KlarnaExpressCheckoutViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/KlarnaOSMViewNativeComponent.d.ts +35 -0
- package/lib/typescript/specs/KlarnaOSMViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/types/button/KlarnaButtonShape.d.ts +6 -0
- package/lib/typescript/types/button/KlarnaButtonShape.d.ts.map +1 -0
- package/lib/typescript/types/button/KlarnaButtonStyle.d.ts +5 -0
- package/lib/typescript/types/button/KlarnaButtonStyle.d.ts.map +1 -0
- package/lib/typescript/types/button/KlarnaButtonTheme.d.ts +6 -0
- package/lib/typescript/types/button/KlarnaButtonTheme.d.ts.map +1 -0
- package/lib/typescript/types/common/KlarnaExpressCheckoutSessionOptions.d.ts +10 -0
- package/lib/typescript/types/common/KlarnaExpressCheckoutSessionOptions.d.ts.map +1 -0
- package/lib/typescript/types/common/KlarnaOSMPlacementKey.d.ts +2 -0
- package/lib/typescript/types/common/KlarnaOSMPlacementKey.d.ts.map +1 -0
- package/lib/typescript/types/common/KlarnaTheme.d.ts +6 -0
- package/lib/typescript/types/common/KlarnaTheme.d.ts.map +1 -0
- package/package.json +8 -3
- package/react-native-klarna-inapp-sdk.podspec +2 -1
- package/src/KlarnaExpressCheckoutView.tsx +169 -0
- package/src/KlarnaOSMView.tsx +157 -0
- package/src/index.tsx +9 -0
- package/src/specs/KlarnaExpressCheckoutViewNativeComponent.ts +66 -0
- package/src/specs/KlarnaOSMViewNativeComponent.ts +50 -0
- package/src/types/button/KlarnaButtonShape.ts +5 -0
- package/src/types/button/KlarnaButtonStyle.ts +4 -0
- package/src/types/button/KlarnaButtonTheme.ts +5 -0
- package/src/types/common/KlarnaExpressCheckoutSessionOptions.ts +13 -0
- package/src/types/common/KlarnaOSMPlacementKey.ts +3 -0
- package/src/types/common/KlarnaTheme.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/common/KlarnaOSMPlacementKey.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KlarnaTheme"],"sourceRoot":"../../../../src","sources":["types/common/KlarnaTheme.ts"],"mappings":"AAAA,WAAYA,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { Component, type RefObject } from 'react';
|
|
2
|
+
import type { NativeMethods, ViewStyle } from 'react-native';
|
|
3
|
+
import type { KlarnaMobileSDKError } from './types/common/KlarnaMobileSDKError';
|
|
4
|
+
import type { KlarnaEnvironment } from './types/common/KlarnaEnvironment';
|
|
5
|
+
import type { KlarnaRegion } from './types/common/KlarnaRegion';
|
|
6
|
+
import type { KlarnaExpressCheckoutSessionOptions } from './types/common/KlarnaExpressCheckoutSessionOptions';
|
|
7
|
+
import type { KlarnaButtonTheme } from './types/button/KlarnaButtonTheme';
|
|
8
|
+
import type { KlarnaButtonShape } from './types/button/KlarnaButtonShape';
|
|
9
|
+
import type { KlarnaButtonStyle } from './types/button/KlarnaButtonStyle';
|
|
10
|
+
import { type RNKlarnaExpressCheckoutViewProps } from './specs/KlarnaExpressCheckoutViewNativeComponent';
|
|
11
|
+
export interface KlarnaExpressCheckoutAuthorizationResponse {
|
|
12
|
+
readonly showForm: boolean;
|
|
13
|
+
readonly approved: boolean;
|
|
14
|
+
readonly finalizedRequired: boolean;
|
|
15
|
+
readonly clientToken: string;
|
|
16
|
+
readonly authorizationToken: string;
|
|
17
|
+
readonly sessionId: string;
|
|
18
|
+
readonly collectedShippingAddress: string;
|
|
19
|
+
readonly merchantReference1: string;
|
|
20
|
+
readonly merchantReference2: string;
|
|
21
|
+
}
|
|
22
|
+
export interface KlarnaExpressCheckoutViewProps {
|
|
23
|
+
style?: ViewStyle;
|
|
24
|
+
readonly sessionOptions: KlarnaExpressCheckoutSessionOptions;
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
readonly environment: KlarnaEnvironment;
|
|
27
|
+
readonly region: KlarnaRegion;
|
|
28
|
+
readonly returnUrl: string;
|
|
29
|
+
readonly theme?: KlarnaButtonTheme;
|
|
30
|
+
readonly shape?: KlarnaButtonShape;
|
|
31
|
+
readonly buttonStyle?: KlarnaButtonStyle;
|
|
32
|
+
readonly autoFinalize?: boolean;
|
|
33
|
+
readonly collectShippingAddress?: boolean;
|
|
34
|
+
readonly sessionData?: string;
|
|
35
|
+
readonly onAuthorized?: (response: KlarnaExpressCheckoutAuthorizationResponse) => void;
|
|
36
|
+
readonly onError?: (error: KlarnaMobileSDKError) => void;
|
|
37
|
+
}
|
|
38
|
+
interface KlarnaExpressCheckoutViewState {
|
|
39
|
+
nativeViewHeight: number;
|
|
40
|
+
}
|
|
41
|
+
export declare class KlarnaExpressCheckoutView extends Component<KlarnaExpressCheckoutViewProps, KlarnaExpressCheckoutViewState> {
|
|
42
|
+
viewRef: RefObject<Component<RNKlarnaExpressCheckoutViewProps> & Readonly<NativeMethods>>;
|
|
43
|
+
constructor(props: KlarnaExpressCheckoutViewProps);
|
|
44
|
+
render(): React.JSX.Element;
|
|
45
|
+
}
|
|
46
|
+
export default KlarnaExpressCheckoutView;
|
|
47
|
+
//# sourceMappingURL=KlarnaExpressCheckoutView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaExpressCheckoutView.d.ts","sourceRoot":"","sources":["../../src/KlarnaExpressCheckoutView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EACV,aAAa,EAEb,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oDAAoD,CAAC;AAC9G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAoC,EAClC,KAAK,gCAAgC,EACtC,MAAM,kDAAkD,CAAC;AAE1D,MAAM,WAAW,0CAA0C;IACzD,QAAQ,CAA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BAAa,yBAA0B,SAAQ,SAAS,CACtD,8BAA8B,EAC9B,8BAA8B,CAC/B;IACC,OAAO,EAAE,SAAS,CAChB,SAAS,CAAC,gCAAgC,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CACtE,CAAC;gBAEU,KAAK,EAAE,8BAA8B;IAQjD,MAAM;CAsFP;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { type ViewStyle } from 'react-native';
|
|
3
|
+
import type { KlarnaMobileSDKError } from './types/common/KlarnaMobileSDKError';
|
|
4
|
+
import type { KlarnaOSMPlacementKey } from './types/common/KlarnaOSMPlacementKey';
|
|
5
|
+
import { KlarnaEnvironment } from './types/common/KlarnaEnvironment';
|
|
6
|
+
import { KlarnaRegion } from './types/common/KlarnaRegion';
|
|
7
|
+
import { KlarnaTheme } from './types/common/KlarnaTheme';
|
|
8
|
+
export interface KlarnaOSMViewProps {
|
|
9
|
+
style?: ViewStyle;
|
|
10
|
+
readonly clientId: string;
|
|
11
|
+
readonly placementKey: KlarnaOSMPlacementKey;
|
|
12
|
+
readonly locale: string;
|
|
13
|
+
readonly purchaseAmount: string;
|
|
14
|
+
readonly environment: KlarnaEnvironment;
|
|
15
|
+
readonly region: KlarnaRegion;
|
|
16
|
+
readonly theme?: KlarnaTheme;
|
|
17
|
+
readonly backgroundColor?: string;
|
|
18
|
+
readonly textColor?: string;
|
|
19
|
+
readonly returnUrl?: string;
|
|
20
|
+
readonly onError?: (error: KlarnaMobileSDKError) => void;
|
|
21
|
+
}
|
|
22
|
+
interface KlarnaOSMViewState {
|
|
23
|
+
nativeViewHeight: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class KlarnaOSMView extends Component<KlarnaOSMViewProps, KlarnaOSMViewState> {
|
|
26
|
+
private osmViewRef;
|
|
27
|
+
private isOSMViewReady;
|
|
28
|
+
private hasError;
|
|
29
|
+
constructor(props: KlarnaOSMViewProps);
|
|
30
|
+
componentDidUpdate(prevProps: KlarnaOSMViewProps): void;
|
|
31
|
+
componentWillUnmount(): void;
|
|
32
|
+
render(): React.JSX.Element;
|
|
33
|
+
private renderNative;
|
|
34
|
+
}
|
|
35
|
+
export default KlarnaOSMView;
|
|
36
|
+
//# sourceMappingURL=KlarnaOSMView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaOSMView.d.ts","sourceRoot":"","sources":["../../src/KlarnaOSMView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAC;AACzD,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAMzD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC1D;AAED,UAAU,kBAAkB;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,aAAc,SAAQ,SAAS,CAC1C,kBAAkB,EAClB,kBAAkB,CACnB;IACC,OAAO,CAAC,UAAU,CAEhB;IACF,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAS;gBAEb,KAAK,EAAE,kBAAkB;IAQrC,kBAAkB,CAAC,SAAS,EAAE,kBAAkB;IAiBhD,oBAAoB;IAIpB,MAAM;IAiEN,OAAO,CAAC,YAAY,CAMlB;CACH;AASD,eAAe,aAAa,CAAC"}
|
|
@@ -2,4 +2,13 @@ export * from './KlarnaPaymentView';
|
|
|
2
2
|
export * from './KlarnaStandaloneWebView';
|
|
3
3
|
export * from './KlarnaCheckoutView';
|
|
4
4
|
export * from './KlarnaSignInSDK';
|
|
5
|
+
export * from './KlarnaExpressCheckoutView';
|
|
6
|
+
export * from './types/common/KlarnaEnvironment';
|
|
7
|
+
export * from './types/common/KlarnaRegion';
|
|
8
|
+
export * from './types/common/KlarnaExpressCheckoutSessionOptions';
|
|
9
|
+
export * from './types/button/KlarnaButtonTheme';
|
|
10
|
+
export * from './types/button/KlarnaButtonShape';
|
|
11
|
+
export * from './types/button/KlarnaButtonStyle';
|
|
12
|
+
export * from './KlarnaOSMView';
|
|
13
|
+
export * from './types/common/KlarnaTheme';
|
|
5
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oDAAoD,CAAC;AACnE,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
2
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import type { HostComponent } from 'react-native';
|
|
4
|
+
export interface RNKlarnaExpressCheckoutViewProps extends ViewProps {
|
|
5
|
+
readonly sessionType: string;
|
|
6
|
+
readonly clientId: string;
|
|
7
|
+
readonly clientToken: string;
|
|
8
|
+
readonly locale: string;
|
|
9
|
+
readonly environment: string;
|
|
10
|
+
readonly region: string;
|
|
11
|
+
readonly returnUrl: string;
|
|
12
|
+
readonly theme: string;
|
|
13
|
+
readonly shape: string;
|
|
14
|
+
readonly buttonStyle: string;
|
|
15
|
+
readonly autoFinalize: boolean;
|
|
16
|
+
readonly collectShippingAddress: boolean;
|
|
17
|
+
readonly sessionData: string;
|
|
18
|
+
readonly onAuthorized: DirectEventHandler<Readonly<{
|
|
19
|
+
readonly authorizationResponse: Readonly<{
|
|
20
|
+
readonly showForm: boolean;
|
|
21
|
+
readonly approved: boolean;
|
|
22
|
+
readonly finalizedRequired: boolean;
|
|
23
|
+
readonly clientToken: string;
|
|
24
|
+
readonly authorizationToken: string;
|
|
25
|
+
readonly sessionId: string;
|
|
26
|
+
readonly collectedShippingAddress: string;
|
|
27
|
+
readonly merchantReference1: string;
|
|
28
|
+
readonly merchantReference2: string;
|
|
29
|
+
}>;
|
|
30
|
+
}>>;
|
|
31
|
+
readonly onError: DirectEventHandler<Readonly<{
|
|
32
|
+
readonly error: Readonly<{
|
|
33
|
+
readonly isFatal: boolean;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
}>;
|
|
37
|
+
}>>;
|
|
38
|
+
readonly onResized: DirectEventHandler<Readonly<{
|
|
39
|
+
readonly height: string;
|
|
40
|
+
}>>;
|
|
41
|
+
}
|
|
42
|
+
type KlarnaExpressCheckoutViewNativeComponentType = HostComponent<RNKlarnaExpressCheckoutViewProps>;
|
|
43
|
+
declare const _default: KlarnaExpressCheckoutViewNativeComponentType;
|
|
44
|
+
export default _default;
|
|
45
|
+
//# sourceMappingURL=KlarnaExpressCheckoutViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaExpressCheckoutViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/specs/KlarnaExpressCheckoutViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sDAAsD,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,gCAAiC,SAAQ,SAAS;IAEjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAG7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAG3B,QAAQ,CAAC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aAAa,CAAC,gCAAgC,CAAC,CAAC;;AAElD,wBAEkD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
2
|
+
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import type { HostComponent } from 'react-native';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface RNKlarnaOSMViewProps extends ViewProps {
|
|
6
|
+
readonly clientId: string;
|
|
7
|
+
readonly placementKey: string;
|
|
8
|
+
readonly locale: string;
|
|
9
|
+
readonly purchaseAmount: string;
|
|
10
|
+
readonly environment: string;
|
|
11
|
+
readonly region: string;
|
|
12
|
+
readonly theme: string;
|
|
13
|
+
readonly backgroundColor: string;
|
|
14
|
+
readonly textColor: string;
|
|
15
|
+
readonly returnUrl?: string;
|
|
16
|
+
readonly onError: DirectEventHandler<Readonly<{
|
|
17
|
+
readonly error: Readonly<{
|
|
18
|
+
readonly isFatal: boolean;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
}>;
|
|
22
|
+
}>>;
|
|
23
|
+
readonly onResized: DirectEventHandler<Readonly<{
|
|
24
|
+
readonly height: string;
|
|
25
|
+
}>>;
|
|
26
|
+
readonly onOSMViewReady?: DirectEventHandler<{}>;
|
|
27
|
+
}
|
|
28
|
+
type KlarnaOSMViewNativeComponentType = HostComponent<RNKlarnaOSMViewProps>;
|
|
29
|
+
interface RNKlarnaOSMViewNativeCommands {
|
|
30
|
+
render: (viewRef: React.ElementRef<KlarnaOSMViewNativeComponentType>) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare const Commands: RNKlarnaOSMViewNativeCommands;
|
|
33
|
+
declare const _default: KlarnaOSMViewNativeComponentType;
|
|
34
|
+
export default _default;
|
|
35
|
+
//# sourceMappingURL=KlarnaOSMViewNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Klarna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CAAC,CAAC;CAClD;AAED,KAAK,gCAAgC,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAAC;AAE5E,UAAU,6BAA6B;IACrC,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,gCAAgC,CAAC,KAAK,IAAI,CAAC;CAC/E;AAED,eAAO,MAAM,QAAQ,EAAE,6BAGnB,CAAC;;AAEL,wBAEsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaButtonShape.d.ts","sourceRoot":"","sources":["../../../../src/types/button/KlarnaButtonShape.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,SAAS,cAAc;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaButtonStyle.d.ts","sourceRoot":"","sources":["../../../../src/types/button/KlarnaButtonStyle.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaButtonTheme.d.ts","sourceRoot":"","sources":["../../../../src/types/button/KlarnaButtonTheme.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;CACd"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare namespace KlarnaExpressCheckoutSessionOptions {
|
|
2
|
+
interface ClientSideSession {
|
|
3
|
+
readonly clientId: string;
|
|
4
|
+
}
|
|
5
|
+
interface ServerSideSession {
|
|
6
|
+
readonly clientToken: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export type KlarnaExpressCheckoutSessionOptions = KlarnaExpressCheckoutSessionOptions.ClientSideSession | KlarnaExpressCheckoutSessionOptions.ServerSideSession;
|
|
10
|
+
//# sourceMappingURL=KlarnaExpressCheckoutSessionOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaExpressCheckoutSessionOptions.d.ts","sourceRoot":"","sources":["../../../../src/types/common/KlarnaExpressCheckoutSessionOptions.ts"],"names":[],"mappings":"AAAA,yBAAiB,mCAAmC,CAAC;IACnD,UAAiB,iBAAiB;QAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC3B;IAED,UAAiB,iBAAiB;QAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;KAC9B;CACF;AAED,MAAM,MAAM,mCAAmC,GAC3C,mCAAmC,CAAC,iBAAiB,GACrD,mCAAmC,CAAC,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaOSMPlacementKey.d.ts","sourceRoot":"","sources":["../../../../src/types/common/KlarnaOSMPlacementKey.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,4BAA4B,GAC5B,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaTheme.d.ts","sourceRoot":"","sources":["../../../../src/types/common/KlarnaTheme.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,SAAS,cAAc;CACxB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-klarna-inapp-sdk",
|
|
3
3
|
"title": "Klarna Mobile SDK React Native",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"description": "This library wraps Klarna Mobile SDK and exposes its functionality as React Native components.",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
7
7
|
"module": "lib/module/index",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"clean": "del-cli android/build ios/build TestApp/android/build TestApp/android/app/build TestApp/ios/build",
|
|
41
41
|
"pods": "pod-install --quiet",
|
|
42
42
|
"test:android": "cd TestApp/android && ./gradlew :react-native-klarna-inapp-sdk:testDebugUnitTest && cd ../..",
|
|
43
|
-
"test:ios": "cd ios && xcodebuild test -workspace RNKlarnaMobileSDK.xcworkspace -scheme RNKlarnaMobileSDK -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 16'",
|
|
43
|
+
"test:ios": "cd ios && xcodebuild test -workspace RNKlarnaMobileSDK.xcworkspace -scheme RNKlarnaMobileSDK -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 16 Pro'",
|
|
44
44
|
"build:android": "cd TestApp/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
45
45
|
"build:ios": "cd TestApp/ios && xcodebuild -workspace TestApp.xcworkspace -scheme TestApp -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
46
46
|
"TestApp": "yarn --cwd TestApp"
|
|
@@ -110,7 +110,12 @@
|
|
|
110
110
|
"componentProvider": {
|
|
111
111
|
"RNKlarnaStandaloneWebView": "KlarnaStandaloneWebViewWrapper",
|
|
112
112
|
"RNKlarnaCheckoutView": "KlarnaCheckoutViewWrapper",
|
|
113
|
-
"RNKlarnaPaymentView": "PaymentViewWrapper"
|
|
113
|
+
"RNKlarnaPaymentView": "PaymentViewWrapper",
|
|
114
|
+
"RNKlarnaExpressCheckoutView": "KlarnaExpressCheckoutViewWrapper",
|
|
115
|
+
"RNKlarnaOSMView": "KlarnaOSMViewWrapper"
|
|
116
|
+
},
|
|
117
|
+
"modulesProvider": {
|
|
118
|
+
"RNKlarnaSignIn": "KlarnaSignInModule"
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
}
|
|
@@ -16,6 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/Sources/**/*.{pch,h,m,mm,swift}"
|
|
18
18
|
s.requires_arc = true
|
|
19
|
+
s.swift_version = '5.0'
|
|
19
20
|
|
|
20
21
|
s.prefix_header_file = 'ios/Sources/PrefixHeader.pch'
|
|
21
22
|
|
|
@@ -48,5 +49,5 @@ Pod::Spec.new do |s|
|
|
|
48
49
|
end
|
|
49
50
|
end
|
|
50
51
|
|
|
51
|
-
s.dependency 'KlarnaMobileSDK', '2.
|
|
52
|
+
s.dependency 'KlarnaMobileSDK', '2.11.2'
|
|
52
53
|
end
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React, { Component, type RefObject } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
NativeMethods,
|
|
4
|
+
NativeSyntheticEvent,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import type { KlarnaMobileSDKError } from './types/common/KlarnaMobileSDKError';
|
|
8
|
+
import type { KlarnaEnvironment } from './types/common/KlarnaEnvironment';
|
|
9
|
+
import type { KlarnaRegion } from './types/common/KlarnaRegion';
|
|
10
|
+
import type { KlarnaExpressCheckoutSessionOptions } from './types/common/KlarnaExpressCheckoutSessionOptions';
|
|
11
|
+
import type { KlarnaButtonTheme } from './types/button/KlarnaButtonTheme';
|
|
12
|
+
import type { KlarnaButtonShape } from './types/button/KlarnaButtonShape';
|
|
13
|
+
import type { KlarnaButtonStyle } from './types/button/KlarnaButtonStyle';
|
|
14
|
+
import RNKlarnaExpressCheckoutView, {
|
|
15
|
+
type RNKlarnaExpressCheckoutViewProps,
|
|
16
|
+
} from './specs/KlarnaExpressCheckoutViewNativeComponent';
|
|
17
|
+
|
|
18
|
+
export interface KlarnaExpressCheckoutAuthorizationResponse {
|
|
19
|
+
readonly showForm: boolean;
|
|
20
|
+
readonly approved: boolean;
|
|
21
|
+
readonly finalizedRequired: boolean;
|
|
22
|
+
readonly clientToken: string;
|
|
23
|
+
readonly authorizationToken: string;
|
|
24
|
+
readonly sessionId: string;
|
|
25
|
+
readonly collectedShippingAddress: string;
|
|
26
|
+
readonly merchantReference1: string;
|
|
27
|
+
readonly merchantReference2: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface KlarnaExpressCheckoutViewProps {
|
|
31
|
+
style?: ViewStyle;
|
|
32
|
+
// Session
|
|
33
|
+
readonly sessionOptions: KlarnaExpressCheckoutSessionOptions;
|
|
34
|
+
// Required
|
|
35
|
+
readonly locale: string;
|
|
36
|
+
readonly environment: KlarnaEnvironment;
|
|
37
|
+
readonly region: KlarnaRegion;
|
|
38
|
+
readonly returnUrl: string;
|
|
39
|
+
// Style
|
|
40
|
+
readonly theme?: KlarnaButtonTheme;
|
|
41
|
+
readonly shape?: KlarnaButtonShape;
|
|
42
|
+
readonly buttonStyle?: KlarnaButtonStyle;
|
|
43
|
+
// Optional
|
|
44
|
+
readonly autoFinalize?: boolean;
|
|
45
|
+
readonly collectShippingAddress?: boolean;
|
|
46
|
+
readonly sessionData?: string;
|
|
47
|
+
// Callbacks
|
|
48
|
+
readonly onAuthorized?: (
|
|
49
|
+
response: KlarnaExpressCheckoutAuthorizationResponse
|
|
50
|
+
) => void;
|
|
51
|
+
readonly onError?: (error: KlarnaMobileSDKError) => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface KlarnaExpressCheckoutViewState {
|
|
55
|
+
nativeViewHeight: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const normalizeSessionData = (sessionData?: string): string => {
|
|
59
|
+
if (sessionData?.trim()) {
|
|
60
|
+
return sessionData;
|
|
61
|
+
}
|
|
62
|
+
return '';
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export class KlarnaExpressCheckoutView extends Component<
|
|
66
|
+
KlarnaExpressCheckoutViewProps,
|
|
67
|
+
KlarnaExpressCheckoutViewState
|
|
68
|
+
> {
|
|
69
|
+
viewRef: RefObject<
|
|
70
|
+
Component<RNKlarnaExpressCheckoutViewProps> & Readonly<NativeMethods>
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
constructor(props: KlarnaExpressCheckoutViewProps) {
|
|
74
|
+
super(props);
|
|
75
|
+
this.state = {
|
|
76
|
+
nativeViewHeight: 0,
|
|
77
|
+
};
|
|
78
|
+
this.viewRef = React.createRef();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
render() {
|
|
82
|
+
return (
|
|
83
|
+
<RNKlarnaExpressCheckoutView
|
|
84
|
+
ref={this.viewRef}
|
|
85
|
+
/* eslint-disable-next-line react-native/no-inline-styles */
|
|
86
|
+
style={{
|
|
87
|
+
width: '100%',
|
|
88
|
+
height:
|
|
89
|
+
this.state.nativeViewHeight > 0 ? this.state.nativeViewHeight : 48,
|
|
90
|
+
...this.props.style,
|
|
91
|
+
}}
|
|
92
|
+
sessionType={
|
|
93
|
+
'clientId' in this.props.sessionOptions ? 'clientId' : 'clientToken'
|
|
94
|
+
}
|
|
95
|
+
clientId={
|
|
96
|
+
'clientId' in this.props.sessionOptions
|
|
97
|
+
? this.props.sessionOptions.clientId
|
|
98
|
+
: ''
|
|
99
|
+
}
|
|
100
|
+
clientToken={
|
|
101
|
+
'clientToken' in this.props.sessionOptions
|
|
102
|
+
? this.props.sessionOptions.clientToken
|
|
103
|
+
: ''
|
|
104
|
+
}
|
|
105
|
+
locale={this.props.locale}
|
|
106
|
+
environment={this.props.environment}
|
|
107
|
+
region={this.props.region}
|
|
108
|
+
returnUrl={this.props.returnUrl}
|
|
109
|
+
theme={this.props.theme ?? ''}
|
|
110
|
+
shape={this.props.shape ?? ''}
|
|
111
|
+
buttonStyle={this.props.buttonStyle ?? ''}
|
|
112
|
+
autoFinalize={this.props.autoFinalize ?? true}
|
|
113
|
+
collectShippingAddress={this.props.collectShippingAddress ?? false}
|
|
114
|
+
sessionData={normalizeSessionData(this.props.sessionData)}
|
|
115
|
+
onAuthorized={(
|
|
116
|
+
event: NativeSyntheticEvent<
|
|
117
|
+
Readonly<{
|
|
118
|
+
readonly authorizationResponse: Readonly<{
|
|
119
|
+
readonly showForm: boolean;
|
|
120
|
+
readonly approved: boolean;
|
|
121
|
+
readonly finalizedRequired: boolean;
|
|
122
|
+
readonly clientToken: string;
|
|
123
|
+
readonly authorizationToken: string;
|
|
124
|
+
readonly sessionId: string;
|
|
125
|
+
readonly collectedShippingAddress: string;
|
|
126
|
+
readonly merchantReference1: string;
|
|
127
|
+
readonly merchantReference2: string;
|
|
128
|
+
}>;
|
|
129
|
+
}>
|
|
130
|
+
>
|
|
131
|
+
) => {
|
|
132
|
+
this.props.onAuthorized?.(event.nativeEvent.authorizationResponse);
|
|
133
|
+
}}
|
|
134
|
+
onError={(
|
|
135
|
+
event: NativeSyntheticEvent<
|
|
136
|
+
Readonly<{
|
|
137
|
+
readonly error: Readonly<{
|
|
138
|
+
readonly isFatal: boolean;
|
|
139
|
+
readonly message: string;
|
|
140
|
+
readonly name: string;
|
|
141
|
+
}>;
|
|
142
|
+
}>
|
|
143
|
+
>
|
|
144
|
+
) => {
|
|
145
|
+
const mobileSdkError: KlarnaMobileSDKError = {
|
|
146
|
+
isFatal: event.nativeEvent.error.isFatal,
|
|
147
|
+
message: event.nativeEvent.error.message,
|
|
148
|
+
name: event.nativeEvent.error.name,
|
|
149
|
+
};
|
|
150
|
+
this.props.onError?.(mobileSdkError);
|
|
151
|
+
}}
|
|
152
|
+
onResized={(
|
|
153
|
+
event: NativeSyntheticEvent<
|
|
154
|
+
Readonly<{
|
|
155
|
+
readonly height: string;
|
|
156
|
+
}>
|
|
157
|
+
>
|
|
158
|
+
) => {
|
|
159
|
+
const newHeight = Number(event.nativeEvent.height);
|
|
160
|
+
if (newHeight !== this.state.nativeViewHeight) {
|
|
161
|
+
this.setState({ nativeViewHeight: newHeight });
|
|
162
|
+
}
|
|
163
|
+
}}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export default KlarnaExpressCheckoutView;
|