Search code examples
iosbraintree

BrainTree DropIn credit card example


I am trying to integrate BrainTree with ios using DropIn UI.

I succeeded to show the UI and when I use the test card
Number: 4111111111111111
Exp: 09/2020
It shows message "Please review your information and try again"

let request =  BTDropInRequest()
    request.amount = "100"
    request.paypalDisabled = true
    request.shouldMaskSecurityCode = true

    let dropIn = BTDropInController(authorization: tokenizationKey, request: request)
    { (controller, result, error) in
        if (error != nil) {
            print("ERROR = \(error?.localizedDescription ?? "")")
        } else if (result?.isCancelled == true) {
            print("CANCELLED")
        } else if let result = result {
            print("Payment Description = \(result.paymentDescription)")
            print("paymentOptionType = \(result.paymentOptionType)")
            print("paymentMethod = \(result.paymentMethod?.type ?? "")")
            print("isCancelled = \(result.isCancelled)")
            // Use the BTDropInResult properties to update your UI
            //   result.paymentOptionType = .
        }
        controller.dismiss(animated: true, completion: nil)
    }
    viewController.present(dropIn!, animated: true, completion: nil)

And here is the log when I click on Add Card

-canOpenURL: failed for URL: "com.venmo.touch.v2://x-callback-url/vzero/auth" - error: "This app is not allowed to query for scheme com.venmo.touch.v2"
TIC TCP Conn Failed [25:0x28008b3c0]: 12:8 Err(-65554)
Task .<2> HTTP load failed (error code: -1003 [12:8])
Task .<2> finished with error - code: -1003
TIC TCP Conn Failed [26:0x2800889c0]: 12:8 Err(-65554)
Task <650E9BB8-3AF6-4076-A6C4-977D0435B161>.<5> HTTP load failed (error code: -1003 [12:8])
Task <650E9BB8-3AF6-4076-A6C4-977D0435B161>.<5> finished with error - code: -1003
[BraintreeSDK] WARNING Failed to flush analytics events: A server with the specified hostname could not be found.


Solution

  • It seems that sandbox doesn't work on a real device when I switched to a simulator, request succeeded after adding a credit card details.

    After changing to the production environment the same problem existed, After a several tries I changed from Wifi to LTE as connection in my iPhone device, and it worked! it seems that my ISP has no DNS for production Braintree backend