braintree / braintree_ios

Braintree SDK for iOS
https://developer.paypal.com/braintree/docs/start/hello-client/ios/v5
MIT License
557 stars 291 forks source link

[QL] Parse App Switch Return URL #1237

Closed jaxdesmarais closed 4 months ago

jaxdesmarais commented 4 months ago

Summary of changes

Checklist

Authors

scannillo commented 4 months ago

Were you able to test with any stubbed redirect URL (using our demo apps fly.io site)? I'm curious if /v1/payment_methods/paypal_accounts works as expected with an HTTPS path or if we'll need an update from the GW

jaxdesmarais commented 4 months ago

Were you able to test with any stubbed redirect URL (using our demo apps fly.io site)? I'm curious if /v1/payment_methods/paypal_accounts works as expected with an HTTPS path or if we'll need an update from the GW

I was able to test this and there were no issues with the HTTPS path, since we are mainly parsing the data from that path to send into paypal_accounts. It's a bit awkward to test since we are working off of mocks right now, but this is what I did (it needs a real EC token and BA token to work):

  1. Comment out our UIApplication.shared.open line in the View Controller
  2. Add a breakpoint in line 169 of handleReturn and grab the valid EC and BA token from the URL
  3. Stop the app and replace line 169-175 with:

        let newURL = URL(string: "https://www.paypal.com/success?token=MY_EC_TOKEN&ba_token=MY_BA_TOKEN&switch_initiated_time=123456789")!
        guard isValidURLAction(url: newURL) else {
            notifyFailure(with: BTPayPalError.invalidURLAction, completion: completion)
            return
        }
    
        guard let response = responseDictionary(from: newURL) else {
  4. Run the app again with this change
  5. No errors are returned in paypal_accounts and we get a nonce back as expected in notifySuccess

We can really only test pieces of this so far until we actually start getting the expected data back, but working off of our mocks this should work as expected 🤞. Let me know if I misunderstood what you were thinking we'd test here, did a lot of very hacky workarounds based on mocks to test different pieces. 😅