Skip to content

Commit

Permalink
Fix error when Klarna is not included in Pods
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisNikolic committed May 28, 2024
1 parent 67f0c19 commit 57d2ac4
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import PrimerSDK
@objc(RNTPrimerHeadlessUniversalCheckoutKlarnaComponent)
class RNTPrimerHeadlessUniversalCheckoutKlarnaComponent: RCTEventEmitter {

#if canImport(PrimerKlarnaSDK)
private var klarnaManager: PrimerHeadlessUniversalCheckout.KlarnaManager = PrimerHeadlessUniversalCheckout.KlarnaManager()
#endif
var klarnaComponent: (any KlarnaComponent)?
var clientToken: String?

Expand Down Expand Up @@ -46,12 +48,21 @@ class RNTPrimerHeadlessUniversalCheckoutKlarnaComponent: RCTEventEmitter {
recoverySuggestion: "'intent' can be 'CHECKOUT' or 'VAULT'.")
throw err
}
#if canImport(PrimerKlarnaSDK)
klarnaComponent = try klarnaManager.provideKlarnaComponent(with: sessionIntent)
klarnaComponent?.stepDelegate = self
klarnaComponent?.errorDelegate = self
klarnaComponent?.validationDelegate = self

#else
let err = RNTNativeError(
errorId: "native-ios",
errorDescription: "PrimerKlarnaSDK missing",
recoverySuggestion: "Check if PrimerKlarnaSDK is included in your Podfile")

throw err
#endif


resolver(nil)
} catch {
rejecter(error.rnError["errorId"]!, error.rnError["description"], error)
Expand Down

0 comments on commit 57d2ac4

Please sign in to comment.