Open intsitesdotru opened 7 months ago
Can you share a bit of code involving tokenization ?
The crash is repeated in the this project example if you make an empty line in tokenizationKey variable. Thank you. https://github.com/pikaju/flutter-braintree/blob/main/example/lib/main.dart#L106
Put it in a try/catch block and make sure the tokenizationKey is not empty. Handle the condition in case it doesn't work as expected. Something like this,
try { result = await Braintree.tokenizeCreditCard( tokenizationKey, request, ); log('nonce -> ${result.nonce}'); } catch (e) { Get.back(); debuPrint("ERROR TOKENIZATION -> ${e.toString()}"); return {"status": false, "message": "Transaction declined"}; }
try/catch won't help, error from native code doesn't pop up to dart code.
tokenizationKey
may be some non-empty string, but you will get the crash.
if you ever had a valid token, but then it suddenly became invalid, then you will get the crash.
Hi, iOS application crashes when we calling the Braintree.tokenizeCreditCard function if you pass an invalid tokenization key(empty string for example) in the authorization field. You can check in your example by replacing the tokenizationKey variable with an empty string
`[BraintreeSDK] ERROR Invalid client token. Please ensure your server is generating a valid Braintree ClientToken. [BraintreeSDK] ERROR BTClient could not initialize because the provided clientToken was invalid flutter_braintree/FlutterBraintreeCustomPlugin.swift:77: Fatal error: Unexpectedly found nil while unwrapping an Optional value flutter_braintree/FlutterBraintreeCustomPlugin.swift:77: Fatal error: Unexpectedly found nil while unwrapping an Optional value
thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value frame #0: 0x000000018518debc libswiftCore.dylib
_swift_runtime_on_report libswiftCore.dylib
: -> 0x18518debc <+0>: retlibswiftCore.dylib
: 0x18518dec0 <+0>: b 0x18518debc ; _swift_runtime_on_report libswiftCore.dylib
: 0x18518dec4 <+0>: adrp x8, 461960 0x18518dec8 <+4>: ldrb w0, [x8, #0x2cc] Target 0: (Runner) stopped. Lost connection to device. the Dart compiler exited unexpectedly.`Flutter Channel stable, 3.16.7 Xcode 14.3