react-native-klarna-inapp-sdk 2.1.13 → 2.2.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 +100 -270
- package/android/build.gradle +84 -106
- package/android/gradle.properties +7 -0
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/AndroidManifestNew.xml +4 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/KlarnaMobileSDKPackage.java +33 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/ArgumentsUtil.java +62 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/common/WebViewResizeObserver.java +100 -0
- package/android/src/main/java/com/klarna/{inapp/sdk → mobile/sdk/reactnative/payments}/KlarnaPaymentEvent.java +9 -19
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/payments/KlarnaPaymentViewManager.java +346 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/payments/PaymentViewWrapper.java +78 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEvent.java +67 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewEventSender.java +139 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/standalonewebview/KlarnaStandaloneWebViewManager.java +205 -0
- package/android/src/newarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaPaymentViewSpec.java +32 -0
- package/android/src/newarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaStandaloneWebViewSpec.java +33 -0
- package/android/src/oldarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaPaymentViewSpec.java +25 -0
- package/android/src/oldarch/java/com/klarna/mobile/sdk/reactnative/spec/RNKlarnaStandaloneWebViewSpec.java +19 -0
- package/android/src/test/java/com/klarna/{inapp/sdk/KlarnaPaymentViewPackageTest.java → mobile/sdk/reactnative/KlarnaMobileSDKPackageTest.java} +9 -4
- package/android/src/test/java/com/klarna/{inapp/sdk → mobile/sdk/reactnative/payments}/KlarnaPaymentEventTest.java +17 -20
- package/android/src/test/java/com/klarna/{inapp/sdk → mobile/sdk/reactnative/payments}/KlarnaPaymentViewManagerTest.java +72 -29
- package/ios/{KlarnaInAppSDK.xcodeproj → RNKlarnaMobileSDK.xcodeproj}/project.pbxproj +147 -87
- package/ios/{KlarnaInAppSDK.xcodeproj/xcshareddata/xcschemes/KlarnaInAppSDK.xcscheme → RNKlarnaMobileSDK.xcodeproj/xcshareddata/xcschemes/RNKlarnaMobileSDK.xcscheme} +9 -9
- package/ios/{KlarnaInAppSDK.xcodeproj/xcshareddata/xcschemes/KlarnaInAppSDKTests.xcscheme → RNKlarnaMobileSDK.xcodeproj/xcshareddata/xcschemes/RNKlarnaMobileSDKTests.xcscheme} +3 -3
- package/ios/Sources/KlarnaPaymentViewManager.h +5 -0
- package/ios/Sources/{KlarnaPaymentView.m → KlarnaPaymentViewManager.mm} +10 -15
- package/ios/Sources/KlarnaStandaloneWebViewManager.h +5 -0
- package/ios/Sources/KlarnaStandaloneWebViewManager.mm +77 -0
- package/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.h +29 -0
- package/ios/Sources/view/newarch/KlarnaStandaloneWebViewWrapper.mm +265 -0
- package/ios/Sources/view/newarch/PaymentViewWrapper.h +33 -0
- package/ios/Sources/view/newarch/PaymentViewWrapper.mm +240 -0
- package/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.h +42 -0
- package/ios/Sources/view/oldarch/KlarnaStandaloneWebViewWrapper.mm +195 -0
- package/ios/Sources/view/{PaymentViewWrapper.h → oldarch/PaymentViewWrapper.h} +9 -7
- package/ios/Sources/view/{PaymentViewWrapper.m → oldarch/PaymentViewWrapper.mm} +40 -27
- package/ios/Tests/PaymentViewWrapperTests.m +8 -10
- package/lib/commonjs/KlarnaPaymentView.js +192 -0
- package/lib/commonjs/KlarnaPaymentView.js.map +1 -0
- package/lib/commonjs/KlarnaStandaloneWebView.js +81 -0
- package/lib/commonjs/KlarnaStandaloneWebView.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/KlarnaPaymentViewNativeComponent.js +16 -0
- package/lib/commonjs/specs/KlarnaPaymentViewNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/KlarnaStandaloneWebViewNativeComponent.js +16 -0
- package/lib/commonjs/specs/KlarnaStandaloneWebViewNativeComponent.js.map +1 -0
- package/lib/module/KlarnaPaymentView.js +182 -0
- package/lib/module/KlarnaPaymentView.js.map +1 -0
- package/lib/module/KlarnaStandaloneWebView.js +71 -0
- package/lib/module/KlarnaStandaloneWebView.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/KlarnaPaymentViewNativeComponent.js +7 -0
- package/lib/module/specs/KlarnaPaymentViewNativeComponent.js.map +1 -0
- package/lib/module/specs/KlarnaStandaloneWebViewNativeComponent.js +7 -0
- package/lib/module/specs/KlarnaStandaloneWebViewNativeComponent.js.map +1 -0
- package/lib/typescript/KlarnaPaymentView.d.ts +51 -0
- package/lib/typescript/KlarnaPaymentView.d.ts.map +1 -0
- package/lib/typescript/KlarnaStandaloneWebView.d.ts +46 -0
- package/lib/typescript/KlarnaStandaloneWebView.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/specs/KlarnaPaymentViewNativeComponent.d.ts +49 -0
- package/lib/typescript/specs/KlarnaPaymentViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/KlarnaStandaloneWebViewNativeComponent.d.ts +65 -0
- package/lib/typescript/specs/KlarnaStandaloneWebViewNativeComponent.d.ts.map +1 -0
- package/package.json +86 -14
- package/react-native-klarna-inapp-sdk.podspec +32 -13
- package/src/KlarnaPaymentView.tsx +323 -0
- package/src/KlarnaStandaloneWebView.tsx +217 -0
- package/src/index.tsx +2 -0
- package/src/specs/KlarnaPaymentViewNativeComponent.ts +99 -0
- package/src/specs/KlarnaStandaloneWebViewNativeComponent.ts +96 -0
- package/.gitattributes +0 -3
- package/.watchmanconfig +0 -1
- package/.yarnrc +0 -5
- package/CHANGELOG.md +0 -116
- package/android/README.md +0 -14
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/gradlew +0 -172
- package/android/gradlew.bat +0 -84
- package/android/src/main/java/com/klarna/inapp/sdk/HeightListener.java +0 -159
- package/android/src/main/java/com/klarna/inapp/sdk/KlarnaPaymentViewManager.java +0 -282
- package/android/src/main/java/com/klarna/inapp/sdk/KlarnaPaymentViewPackage.java +0 -25
- package/android/src/main/java/com/klarna/inapp/sdk/Mappable.java +0 -10
- package/android/src/main/java/com/klarna/inapp/sdk/MappableKlarnaPaymentsSDKError.java +0 -31
- package/android/src/main/java/com/klarna/inapp/sdk/PaymentViewWrapper.java +0 -131
- package/android/src/test/java/com/klarna/inapp/sdk/MappableKlarnaPaymentsSDKErrorTest.java +0 -45
- package/babel.config.js +0 -3
- package/integration-tests/build.gradle +0 -59
- package/integration-tests/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/integration-tests/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/integration-tests/gradlew +0 -172
- package/integration-tests/gradlew.bat +0 -84
- package/integration-tests/settings.gradle +0 -2
- package/integration-tests/src/test/resources/junit-platform.properties +0 -4
- package/ios/KlarnaInAppSDK.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/KlarnaInAppSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/Podfile +0 -73
- package/ios/Sources/KlarnaPaymentView.h +0 -5
- package/scripts/bootstrap.js +0 -29
- package/src/index.js +0 -72
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "PaymentViewWrapper.h"
|
|
4
|
+
|
|
5
|
+
#import <AVFoundation/AVFoundation.h>
|
|
6
|
+
#import <KlarnaMobileSDK/KlarnaMobileSDK-Swift.h>
|
|
7
|
+
#import <React/RCTLog.h>
|
|
8
|
+
|
|
9
|
+
#import <react/renderer/components/RNKlarnaMobileSDK/ComponentDescriptors.h>
|
|
10
|
+
#import <react/renderer/components/RNKlarnaMobileSDK/EventEmitters.h>
|
|
11
|
+
#import <react/renderer/components/RNKlarnaMobileSDK/Props.h>
|
|
12
|
+
#import <react/renderer/components/RNKlarnaMobileSDK/RCTComponentViewHelpers.h>
|
|
13
|
+
|
|
14
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
15
|
+
|
|
16
|
+
using namespace facebook::react;
|
|
17
|
+
|
|
18
|
+
@interface PaymentViewWrapper () <KlarnaPaymentEventListener, RCTRNKlarnaPaymentViewViewProtocol>
|
|
19
|
+
|
|
20
|
+
@property (nonatomic, strong) KlarnaPaymentView* actualPaymentView;
|
|
21
|
+
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
@implementation PaymentViewWrapper
|
|
25
|
+
|
|
26
|
+
#pragma mark - React Native Overrides
|
|
27
|
+
|
|
28
|
+
- (void) initializeActualPaymentView:(NSString*)category withReturnUrl:(NSString*)returnUrl {
|
|
29
|
+
if (returnUrl.length > 0) {
|
|
30
|
+
self.actualPaymentView = [[KlarnaPaymentView alloc] initWithCategory:category returnUrl:[NSURL URLWithString:returnUrl] eventListener:self];
|
|
31
|
+
} else {
|
|
32
|
+
self.actualPaymentView = [[KlarnaPaymentView alloc] initWithCategory:category eventListener:self];
|
|
33
|
+
}
|
|
34
|
+
self.actualPaymentView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
[self addSubview:self.actualPaymentView];
|
|
38
|
+
|
|
39
|
+
[NSLayoutConstraint activateConstraints:[[NSArray alloc] initWithObjects:
|
|
40
|
+
[self.actualPaymentView.topAnchor constraintEqualToAnchor:self.topAnchor],
|
|
41
|
+
[self.actualPaymentView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
|
|
42
|
+
[self.actualPaymentView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
|
|
43
|
+
[self.actualPaymentView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor], nil
|
|
44
|
+
]];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)layoutSubviews {
|
|
48
|
+
[super layoutSubviews];
|
|
49
|
+
self.actualPaymentView.frame = self.bounds;
|
|
50
|
+
[self.actualPaymentView layoutSubviews];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#pragma mark - Payment View Methods
|
|
54
|
+
|
|
55
|
+
- (void)initializePaymentViewWithClientToken:(NSString *)clientToken withReturnUrl:(NSString *)returnUrl{
|
|
56
|
+
if (returnUrl.length > 0) {
|
|
57
|
+
[self.actualPaymentView initializeWithClientToken:clientToken returnUrl:[NSURL URLWithString:returnUrl]];
|
|
58
|
+
} else {
|
|
59
|
+
[self.actualPaymentView initializeWithClientToken:clientToken];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)loadPaymentViewWithSessionData:(NSString*)sessionData {
|
|
64
|
+
[self.actualPaymentView loadWithJsonData:sessionData.length > 0 ? sessionData : nil];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)loadPaymentReviewPaymentView {
|
|
68
|
+
[self.actualPaymentView loadPaymentReview];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
- (void)authorizePaymentViewWithAutoFinalize:(BOOL)autoFinalize sessionData:(NSString*)sessionData {
|
|
72
|
+
[self.actualPaymentView authorizeWithAutoFinalize:autoFinalize jsonData:sessionData.length > 0 ? sessionData : nil];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (void)reauthorizePaymentViewWithSessionData:(NSString*)sessionData {
|
|
76
|
+
[self.actualPaymentView reauthorizeWithJsonData:sessionData.length > 0 ? sessionData : nil];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)finalizePaymentViewWithSessionData:(NSString*)sessionData {
|
|
80
|
+
[self.actualPaymentView finaliseWithJsonData:sessionData.length > 0 ? sessionData : nil];
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#pragma mark - Klarna PaymentEventListener
|
|
85
|
+
|
|
86
|
+
- (void)klarnaInitializedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView {
|
|
87
|
+
if(_eventEmitter){
|
|
88
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
89
|
+
->onInitialized(RNKlarnaPaymentViewEventEmitter::OnInitialized{});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (void)klarnaLoadedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView {
|
|
94
|
+
if(_eventEmitter){
|
|
95
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
96
|
+
->onLoaded(RNKlarnaPaymentViewEventEmitter::OnLoaded{});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)klarnaLoadedPaymentReviewWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView {
|
|
101
|
+
if(_eventEmitter){
|
|
102
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
103
|
+
->onLoadedPaymentReview(RNKlarnaPaymentViewEventEmitter::OnLoadedPaymentReview{});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void)klarnaAuthorizedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView approved:(BOOL)approved authToken:(NSString * _Nullable)authToken finalizeRequired:(BOOL)finalizeRequired {
|
|
108
|
+
if(_eventEmitter){
|
|
109
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
110
|
+
->onAuthorized(RNKlarnaPaymentViewEventEmitter::OnAuthorized{
|
|
111
|
+
.approved = approved,
|
|
112
|
+
.authToken = authToken == nil ? "" : std::string([authToken UTF8String]),
|
|
113
|
+
.finalizeRequired = finalizeRequired
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
- (void)klarnaReauthorizedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView approved:(BOOL)approved authToken:(NSString * _Nullable)authToken {
|
|
118
|
+
if(_eventEmitter){
|
|
119
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
120
|
+
->onReauthorized(RNKlarnaPaymentViewEventEmitter::OnReauthorized{
|
|
121
|
+
.approved = approved,
|
|
122
|
+
.authToken = authToken == nil ? "" : std::string([authToken UTF8String]),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (void)klarnaFinalizedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView approved:(BOOL)approved authToken:(NSString * _Nullable)authToken {
|
|
128
|
+
if(_eventEmitter){
|
|
129
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
130
|
+
->onFinalized(RNKlarnaPaymentViewEventEmitter::OnFinalized{
|
|
131
|
+
.approved = approved,
|
|
132
|
+
.authToken = authToken == nil ? "" : std::string([authToken UTF8String]),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)klarnaFailedInPaymentView:(KlarnaPaymentView * _Nonnull)paymentView withError:(KlarnaPaymentError * _Nonnull)error {
|
|
138
|
+
if(_eventEmitter){
|
|
139
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
140
|
+
->onError(RNKlarnaPaymentViewEventEmitter::OnError{
|
|
141
|
+
.error = {
|
|
142
|
+
.action = std::string([error.action UTF8String]),
|
|
143
|
+
.isFatal = error.isFatal,
|
|
144
|
+
.message = std::string([error.message UTF8String]),
|
|
145
|
+
.name = std::string([error.name UTF8String]),
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (void)klarnaResizedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView to:(CGFloat)newHeight {
|
|
152
|
+
if(_eventEmitter){
|
|
153
|
+
std::dynamic_pointer_cast<const RNKlarnaPaymentViewEventEmitter>(_eventEmitter)
|
|
154
|
+
->onResized(RNKlarnaPaymentViewEventEmitter::OnResized{
|
|
155
|
+
.height = std::string([[[NSNumber numberWithFloat:newHeight] stringValue] UTF8String])
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
161
|
+
{
|
|
162
|
+
self = [super initWithFrame:frame];
|
|
163
|
+
if (self) {
|
|
164
|
+
static const auto defaultProps = std::make_shared<const RNKlarnaPaymentViewProps>();
|
|
165
|
+
_props = defaultProps;
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return self;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
173
|
+
{
|
|
174
|
+
return concreteComponentDescriptorProvider<RNKlarnaPaymentViewComponentDescriptor>();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
Class<RCTComponentViewProtocol> RNKlarnaPaymentViewCls(void)
|
|
178
|
+
{
|
|
179
|
+
return PaymentViewWrapper.class;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
183
|
+
{
|
|
184
|
+
const auto &oldViewProps = *std::static_pointer_cast<RNKlarnaPaymentViewProps const>(_props);
|
|
185
|
+
const auto &newViewProps = *std::static_pointer_cast<RNKlarnaPaymentViewProps const>(props);
|
|
186
|
+
|
|
187
|
+
if (self.actualPaymentView == nil && newViewProps.category.length() > 0) {
|
|
188
|
+
NSString * categoryConver = [[NSString alloc] initWithUTF8String: newViewProps.category.c_str()];
|
|
189
|
+
NSString * returnUrlConver = [[NSString alloc] initWithUTF8String: newViewProps.returnUrl.c_str()];
|
|
190
|
+
[self initializeActualPaymentView:categoryConver withReturnUrl:returnUrlConver];
|
|
191
|
+
} else {
|
|
192
|
+
if (oldViewProps.category != newViewProps.category) {
|
|
193
|
+
NSString * categoryConver = [[NSString alloc] initWithUTF8String: newViewProps.category.c_str()];
|
|
194
|
+
// not supported
|
|
195
|
+
// self.actualPaymentView.category = newViewProps.category
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (oldViewProps.returnUrl != newViewProps.returnUrl) {
|
|
199
|
+
NSString * returnUrlConver = [[NSString alloc] initWithUTF8String: newViewProps.returnUrl.c_str()];
|
|
200
|
+
self.actualPaymentView.returnURL = [NSURL URLWithString:returnUrlConver];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
[super updateProps:props oldProps:oldProps];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args {
|
|
209
|
+
RCTRNKlarnaPaymentViewHandleCommand(self, commandName, args);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#pragma mark - RCTRNKlarnaPaymentViewViewProtocol
|
|
213
|
+
|
|
214
|
+
- (void)initialize:(nonnull NSString *)clientToken returnUrl:(nonnull NSString *)returnUrl {
|
|
215
|
+
[self initializePaymentViewWithClientToken:clientToken withReturnUrl:returnUrl];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
- (void)load:(nonnull NSString *)sessionData {
|
|
219
|
+
[self loadPaymentViewWithSessionData:sessionData];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
- (void)loadPaymentReview {
|
|
223
|
+
[self loadPaymentReviewPaymentView];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
- (void)authorize:(BOOL)autoFinalize sessionData:(nonnull NSString *)sessionData {
|
|
227
|
+
[self authorizePaymentViewWithAutoFinalize: autoFinalize sessionData:sessionData];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
- (void)finalize:(nonnull NSString *)sessionData {
|
|
231
|
+
[self finalizePaymentViewWithSessionData:sessionData];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
- (void)reauthorize:(nonnull NSString *)sessionData {
|
|
235
|
+
[self reauthorizePaymentViewWithSessionData:sessionData];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@end
|
|
239
|
+
|
|
240
|
+
#endif
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import <React/RCTUIManager.h>
|
|
4
|
+
|
|
5
|
+
#import <AVFoundation/AVFoundation.h>
|
|
6
|
+
#import <UIKit/UIKit.h>
|
|
7
|
+
#import <React/RCTView.h>
|
|
8
|
+
#import <React/RCTUIManager.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
@interface KlarnaStandaloneWebViewWrapper : UIView
|
|
13
|
+
|
|
14
|
+
@property (nonatomic, copy) RCTDirectEventBlock onLoadStart;
|
|
15
|
+
@property (nonatomic, copy) RCTDirectEventBlock onLoadEnd;
|
|
16
|
+
@property (nonatomic, copy) RCTDirectEventBlock onError;
|
|
17
|
+
@property (nonatomic, copy) RCTDirectEventBlock onLoadProgress;
|
|
18
|
+
@property (nonatomic, copy) RCTDirectEventBlock onKlarnaMessage;
|
|
19
|
+
|
|
20
|
+
@property (nonatomic, strong) NSString* returnUrl;
|
|
21
|
+
|
|
22
|
+
#pragma mark - React Native Overrides
|
|
23
|
+
|
|
24
|
+
- (void)initializeKlarnaStandaloneWebView;
|
|
25
|
+
|
|
26
|
+
@property (nonatomic, weak) RCTUIManager* uiManager;
|
|
27
|
+
|
|
28
|
+
- (void)load:(nonnull NSString*)url;
|
|
29
|
+
|
|
30
|
+
- (void)goForward;
|
|
31
|
+
|
|
32
|
+
- (void)goBack;
|
|
33
|
+
|
|
34
|
+
- (void)reload;
|
|
35
|
+
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
NS_ASSUME_NONNULL_END
|
|
39
|
+
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "KlarnaStandaloneWebViewWrapper.h"
|
|
4
|
+
|
|
5
|
+
#import <KlarnaMobileSDK/KlarnaMobileSDK-Swift.h>
|
|
6
|
+
#import <React/RCTLog.h>
|
|
7
|
+
|
|
8
|
+
@interface KlarnaStandaloneWebViewWrapper () <KlarnaStandaloneWebViewDelegate, KlarnaEventHandler>
|
|
9
|
+
|
|
10
|
+
@property (nonatomic, strong) KlarnaStandaloneWebView* klarnaStandaloneWebView;
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation KlarnaStandaloneWebViewWrapper
|
|
15
|
+
|
|
16
|
+
// The property name in KlarnaStandaloneWebView that we want to observe for changes
|
|
17
|
+
NSString * const PROPERTY_NAME_ESTIMATED_PROGRESS = @"estimatedProgress";
|
|
18
|
+
|
|
19
|
+
- (id)init {
|
|
20
|
+
self = [super init];
|
|
21
|
+
[self initializeKlarnaStandaloneWebView];
|
|
22
|
+
self.klarnaStandaloneWebView.delegate = self;
|
|
23
|
+
self.klarnaStandaloneWebView.eventHandler = self;
|
|
24
|
+
[self.klarnaStandaloneWebView addObserver:self forKeyPath:PROPERTY_NAME_ESTIMATED_PROGRESS options:NSKeyValueObservingOptionNew context:nil];
|
|
25
|
+
return self;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
-(void)dealloc {
|
|
29
|
+
[self.klarnaStandaloneWebView removeObserver:self forKeyPath:PROPERTY_NAME_ESTIMATED_PROGRESS context:nil];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
|
33
|
+
if ([keyPath isEqualToString:PROPERTY_NAME_ESTIMATED_PROGRESS]) {
|
|
34
|
+
// newProgress is a value in range [0..1].
|
|
35
|
+
NSNumber * newProgress = [change objectForKey:NSKeyValueChangeNewKey];
|
|
36
|
+
// We need to convert it to an int value in range [0..100]
|
|
37
|
+
int progress = (int) (newProgress.doubleValue * 100);
|
|
38
|
+
[self sendLoadProgressEvent:self.klarnaStandaloneWebView progress:progress];
|
|
39
|
+
} else {
|
|
40
|
+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (void)sendLoadProgressEvent:(KlarnaStandaloneWebView * _Nonnull)webView progress:(int)progress {
|
|
45
|
+
if (!self.onLoadProgress) {
|
|
46
|
+
RCTLog(@"Missing 'onProgressChange' callback prop.");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
NSMutableDictionary<NSString *, id> *event = [self webViewDict:webView];
|
|
50
|
+
[event addEntriesFromDictionary:@{
|
|
51
|
+
@"progress": [NSNumber numberWithDouble: progress] // could use self.klarnaStandaloneWebView.estimatedProgress
|
|
52
|
+
}];
|
|
53
|
+
|
|
54
|
+
self.onLoadProgress(@{@"progressEvent": event});
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#pragma mark - React Native Overrides
|
|
59
|
+
|
|
60
|
+
- (void)setReturnUrl:(NSString *)returnUrl {
|
|
61
|
+
_returnUrl = returnUrl;
|
|
62
|
+
if (returnUrl.length > 0) {
|
|
63
|
+
self.klarnaStandaloneWebView.returnURL = [NSURL URLWithString:self.returnUrl];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)initializeKlarnaStandaloneWebView {
|
|
68
|
+
if (self.returnUrl != nil && self.returnUrl.length > 0) {
|
|
69
|
+
self.klarnaStandaloneWebView = [[KlarnaStandaloneWebView alloc] initWithReturnURL:[NSURL URLWithString:self.returnUrl]];
|
|
70
|
+
} else {
|
|
71
|
+
// TODO: initWithReturnURL expects a non-null URL. What should we do here if returnUrl is null?
|
|
72
|
+
self.klarnaStandaloneWebView = [[KlarnaStandaloneWebView alloc] initWithReturnURL:[NSURL URLWithString:@"returnUrl://"]];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
self.klarnaStandaloneWebView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
76
|
+
|
|
77
|
+
[self addSubview:self.klarnaStandaloneWebView];
|
|
78
|
+
|
|
79
|
+
[NSLayoutConstraint activateConstraints:[[NSArray alloc] initWithObjects:
|
|
80
|
+
[self.klarnaStandaloneWebView.topAnchor constraintEqualToAnchor:self.topAnchor],
|
|
81
|
+
[self.klarnaStandaloneWebView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
|
|
82
|
+
[self.klarnaStandaloneWebView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
|
|
83
|
+
[self.klarnaStandaloneWebView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor], nil
|
|
84
|
+
]];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (void)layoutSubviews {
|
|
88
|
+
[super layoutSubviews];
|
|
89
|
+
self.klarnaStandaloneWebView.frame = self.bounds;
|
|
90
|
+
[self.klarnaStandaloneWebView layoutSubviews];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#pragma mark - Klarna Standalone Web View Methods
|
|
94
|
+
|
|
95
|
+
- (void)load:(nonnull NSString *)url {
|
|
96
|
+
NSURL *urlToLoad = [NSURL URLWithString:url];
|
|
97
|
+
if ([urlToLoad scheme] && [urlToLoad host] && urlToLoad) {
|
|
98
|
+
[self.klarnaStandaloneWebView loadURL:urlToLoad];
|
|
99
|
+
} else {
|
|
100
|
+
RCTLogInfo(@"url is not a valid URL");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
- (void)goForward {
|
|
105
|
+
[self.klarnaStandaloneWebView goForward];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)goBack {
|
|
109
|
+
[self.klarnaStandaloneWebView goBack];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (void)reload {
|
|
113
|
+
[self.klarnaStandaloneWebView reload];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#pragma mark - KlarnaStandaloneWebViewDelegate methods
|
|
117
|
+
|
|
118
|
+
- (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didCommit:(WKNavigation * _Nonnull)navigation {
|
|
119
|
+
if (!self.onLoadStart) {
|
|
120
|
+
RCTLog(@"Missing 'onLoadStart' callback prop.");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
NSMutableDictionary<NSString *, id> *event = [self webViewDict:webView];
|
|
124
|
+
self.onLoadStart(@{@"navigationEvent": event});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didFinish:(WKNavigation * _Nonnull)navigation {
|
|
128
|
+
if (!self.onLoadEnd) {
|
|
129
|
+
RCTLog(@"Missing 'onLoadEnd' callback prop.");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
NSMutableDictionary<NSString *, id> *event = [self webViewDict:webView];
|
|
133
|
+
self.onLoadEnd(@{@"navigationEvent": event});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
- (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didFailProvisionalNavigation:(WKNavigation * _Nonnull)navigation withError:(NSError * _Nonnull)error {
|
|
137
|
+
if (!self.onError) {
|
|
138
|
+
RCTLog(@"Missing 'onError' callback prop.");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
NSMutableDictionary<NSString *, id> *event = [self webViewDict:webView];
|
|
142
|
+
[event addEntriesFromDictionary:@{
|
|
143
|
+
@"code": @(error.code),
|
|
144
|
+
@"description": error.description,
|
|
145
|
+
}];
|
|
146
|
+
self.onError(@{@"error": event});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
- (void)klarnaStandaloneWebView:(KlarnaStandaloneWebView * _Nonnull)webView didFail:(WKNavigation * _Nonnull)navigation withError:(NSError * _Nonnull)error {
|
|
150
|
+
if (!self.onError) {
|
|
151
|
+
RCTLog(@"Missing 'onError' callback prop.");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
NSMutableDictionary<NSString *, id> *event = [self webViewDict:webView];
|
|
155
|
+
[event addEntriesFromDictionary:@{
|
|
156
|
+
@"code": @(error.code),
|
|
157
|
+
@"description": error.description,
|
|
158
|
+
}];
|
|
159
|
+
self.onError(@{@"error": error});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#pragma mark - KlarnaEventHandler methods
|
|
163
|
+
|
|
164
|
+
- (void)klarnaComponent:(id <KlarnaComponent> _Nonnull)klarnaComponent dispatchedEvent:(KlarnaProductEvent * _Nonnull)event {
|
|
165
|
+
if (!self.onKlarnaMessage) {
|
|
166
|
+
RCTLog(@"Missing 'onKlarnaMessage' callback prop.");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
self.onKlarnaMessage(@{
|
|
170
|
+
@"klarnaMessageEvent": @{
|
|
171
|
+
@"action": event.action
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
- (void)klarnaComponent:(id <KlarnaComponent> _Nonnull)klarnaComponent encounteredError:(KlarnaError * _Nonnull)error {
|
|
177
|
+
// Not used as of now
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#pragma mark - Events
|
|
181
|
+
|
|
182
|
+
- (NSMutableDictionary<NSString *, id> *)webViewDict:(KlarnaStandaloneWebView * _Nonnull)webView {
|
|
183
|
+
NSDictionary *event = @{
|
|
184
|
+
@"url": webView.url.absoluteString ?: @"",
|
|
185
|
+
@"title": webView.title ?: @"",
|
|
186
|
+
@"loading" : @(webView.isLoading),
|
|
187
|
+
@"canGoBack": @(webView.canGoBack),
|
|
188
|
+
@"canGoForward" : @(webView.canGoForward)
|
|
189
|
+
};
|
|
190
|
+
return [[NSMutableDictionary alloc] initWithDictionary: event];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@end
|
|
194
|
+
|
|
195
|
+
#endif
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
// PaymentViewWrapper.h
|
|
3
|
-
// react-native-klarna-payment-view
|
|
4
|
-
//
|
|
5
|
-
// Created by Gabriel Banfalvi on 2019-07-24.
|
|
6
|
-
//
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
7
2
|
|
|
3
|
+
#import <React/RCTUIManager.h>
|
|
4
|
+
|
|
5
|
+
#import <AVFoundation/AVFoundation.h>
|
|
8
6
|
#import <UIKit/UIKit.h>
|
|
9
7
|
#import <React/RCTView.h>
|
|
10
8
|
#import <React/RCTUIManager.h>
|
|
@@ -20,8 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
20
18
|
@property (nonatomic, copy) RCTDirectEventBlock onReauthorized;
|
|
21
19
|
@property (nonatomic, copy) RCTDirectEventBlock onFinalized;
|
|
22
20
|
@property (nonatomic, copy) RCTDirectEventBlock onError;
|
|
21
|
+
@property (nonatomic, copy) RCTDirectEventBlock onResized;
|
|
23
22
|
|
|
24
23
|
@property (nonatomic, strong) NSString* category;
|
|
24
|
+
@property (nonatomic, strong) NSString* returnUrl;
|
|
25
25
|
|
|
26
26
|
#pragma mark - React Native Overrides
|
|
27
27
|
- (void) setCategory:(NSString *)category;
|
|
@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
30
30
|
|
|
31
31
|
@property (nonatomic, weak) RCTUIManager* uiManager;
|
|
32
32
|
|
|
33
|
-
- (void)
|
|
33
|
+
- (void)initializePaymentViewWithClientToken:(NSString*)clientToken withReturnUrl:(NSString*)returnUrl;
|
|
34
34
|
|
|
35
35
|
- (void)loadPaymentViewWithSessionData:(nullable NSString*)sessionData;
|
|
36
36
|
|
|
@@ -45,3 +45,5 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
45
45
|
@end
|
|
46
46
|
|
|
47
47
|
NS_ASSUME_NONNULL_END
|
|
48
|
+
|
|
49
|
+
#endif
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// PaymentViewWrapper.m
|
|
3
|
-
// react-native-klarna-payment-view
|
|
4
|
-
//
|
|
5
|
-
// Created by Gabriel Banfalvi on 2019-07-24.
|
|
6
|
-
//
|
|
1
|
+
#if !RCT_NEW_ARCH_ENABLED
|
|
7
2
|
|
|
8
3
|
#import "PaymentViewWrapper.h"
|
|
9
4
|
|
|
@@ -14,10 +9,8 @@
|
|
|
14
9
|
|
|
15
10
|
@property (nonatomic, strong) KlarnaPaymentView* actualPaymentView;
|
|
16
11
|
|
|
17
|
-
|
|
18
12
|
@end
|
|
19
13
|
|
|
20
|
-
|
|
21
14
|
@implementation PaymentViewWrapper
|
|
22
15
|
|
|
23
16
|
#pragma mark - React Native Overrides
|
|
@@ -27,6 +20,13 @@
|
|
|
27
20
|
[self evaluateProps];
|
|
28
21
|
}
|
|
29
22
|
|
|
23
|
+
- (void) setReturnUrl:(NSString *)returnUrl {
|
|
24
|
+
_returnUrl = returnUrl;
|
|
25
|
+
if (returnUrl.length > 0) {
|
|
26
|
+
self.actualPaymentView.returnURL = [NSURL URLWithString:self.returnUrl];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
30
|
- (void) evaluateProps {
|
|
31
31
|
if (self.category != nil) {
|
|
32
32
|
[self initializeActualPaymentView];
|
|
@@ -34,19 +34,21 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
- (void) initializeActualPaymentView {
|
|
37
|
-
self.
|
|
37
|
+
if (self.returnUrl != nil && self.returnUrl.length > 0) {
|
|
38
|
+
self.actualPaymentView = [[KlarnaPaymentView alloc] initWithCategory:self.category returnUrl:[NSURL URLWithString:self.returnUrl] eventListener:self];
|
|
39
|
+
} else {
|
|
40
|
+
self.actualPaymentView = [[KlarnaPaymentView alloc] initWithCategory:self.category eventListener:self];
|
|
41
|
+
}
|
|
38
42
|
self.actualPaymentView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
39
43
|
|
|
40
44
|
[self addSubview:self.actualPaymentView];
|
|
41
45
|
|
|
42
46
|
[NSLayoutConstraint activateConstraints:[[NSArray alloc] initWithObjects:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
[self.actualPaymentView.topAnchor constraintEqualToAnchor:self.topAnchor],
|
|
48
|
+
[self.actualPaymentView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
|
|
49
|
+
[self.actualPaymentView.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
|
|
50
|
+
[self.actualPaymentView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor], nil
|
|
51
|
+
]];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
- (void)layoutSubviews {
|
|
@@ -58,12 +60,15 @@
|
|
|
58
60
|
#pragma mark - Payment View Methods
|
|
59
61
|
|
|
60
62
|
- (void)initializePaymentViewWithClientToken:(NSString *)clientToken withReturnUrl:(NSString *)returnUrl{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
if (returnUrl.length > 0) {
|
|
64
|
+
[self.actualPaymentView initializeWithClientToken:clientToken returnUrl:[NSURL URLWithString:returnUrl]];
|
|
65
|
+
} else {
|
|
66
|
+
[self.actualPaymentView initializeWithClientToken:clientToken];
|
|
67
|
+
}
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
- (void)loadPaymentViewWithSessionData:(NSString*)sessionData {
|
|
66
|
-
[self.actualPaymentView loadWithJsonData:sessionData];
|
|
71
|
+
[self.actualPaymentView loadWithJsonData:sessionData.length > 0 ? sessionData : nil];
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
- (void)loadPaymentReview {
|
|
@@ -71,21 +76,20 @@
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
- (void)authorizePaymentViewWithAutoFinalize:(BOOL)autoFinalize sessionData:(NSString*)sessionData {
|
|
74
|
-
[self.actualPaymentView authorizeWithAutoFinalize:autoFinalize jsonData:sessionData];
|
|
79
|
+
[self.actualPaymentView authorizeWithAutoFinalize:autoFinalize jsonData:sessionData.length > 0 ? sessionData : nil];
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
- (void)reauthorizePaymentViewWithSessionData:(NSString*)sessionData {
|
|
78
|
-
[self.actualPaymentView reauthorizeWithJsonData:sessionData];
|
|
83
|
+
[self.actualPaymentView reauthorizeWithJsonData:sessionData.length > 0 ? sessionData : nil];
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
- (void)finalizePaymentViewWithSessionData:(NSString*)sessionData {
|
|
82
|
-
[self.actualPaymentView finaliseWithJsonData:sessionData];
|
|
87
|
+
[self.actualPaymentView finaliseWithJsonData:sessionData.length > 0 ? sessionData : nil];
|
|
83
88
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
#pragma mark - Klarna PaymentEventListener
|
|
87
92
|
|
|
88
|
-
|
|
89
93
|
- (void)klarnaInitializedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView {
|
|
90
94
|
if (!self.onInitialized) {
|
|
91
95
|
RCTLog(@"Missing 'onInitialized' callback prop.");
|
|
@@ -126,6 +130,7 @@
|
|
|
126
130
|
});
|
|
127
131
|
|
|
128
132
|
}
|
|
133
|
+
|
|
129
134
|
- (void)klarnaReauthorizedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView approved:(BOOL)approved authToken:(NSString * _Nullable)authToken {
|
|
130
135
|
if (!self.onReauthorized) {
|
|
131
136
|
RCTLog(@"Missing 'onReauthorized' callback prop.");
|
|
@@ -151,11 +156,11 @@
|
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
- (void)klarnaFailedInPaymentView:(KlarnaPaymentView * _Nonnull)paymentView withError:(KlarnaPaymentError * _Nonnull)error {
|
|
154
|
-
|
|
159
|
+
if (!self.onError) {
|
|
155
160
|
RCTLog(@"Missing 'onError' callback prop.");
|
|
156
161
|
return;
|
|
157
162
|
}
|
|
158
|
-
|
|
163
|
+
|
|
159
164
|
self.onError(@{
|
|
160
165
|
@"error": @{
|
|
161
166
|
@"action": error.action,
|
|
@@ -167,8 +172,16 @@
|
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
- (void)klarnaResizedWithPaymentView:(KlarnaPaymentView * _Nonnull)paymentView to:(CGFloat)newHeight {
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
if (!self.onResized) {
|
|
176
|
+
RCTLog(@"Missing 'onResized' callback prop.");
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
self.onResized(@{
|
|
181
|
+
@"height": [[NSNumber numberWithFloat:newHeight] stringValue]
|
|
182
|
+
});
|
|
172
183
|
}
|
|
173
184
|
|
|
174
185
|
@end
|
|
186
|
+
|
|
187
|
+
#endif
|