Skip to content

Commit

Permalink
Merge pull request #215 from primer-io/fix/klarna-issues
Browse files Browse the repository at this point in the history
Fix error when Klarna is not included in Pods
  • Loading branch information
borisprimer authored May 28, 2024
2 parents 67f0c19 + 57d2ac4 commit ad61d6e
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 ad61d6e

Please sign in to comment.