-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open PayPal App URL if present in BT GW response #1234
Open PayPal App URL if present in BT GW response #1234
Conversation
…perty to check for empty string on token/ba_token query param
var urlComponents = URLComponents(url: paypalAppRedirectUrl, resolvingAgainstBaseURL: true) | ||
urlComponents?.queryItems = [ | ||
URLQueryItem(name: "source", value: "braintree_sdk"), | ||
URLQueryItem(name: "switch_initiated_time", value: String(UInt64(Date().timeIntervalSince1970 * 1000))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to update this based on the discussion on confluence around adding additional precision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! Also using Int
instead of UInt64
, which I think we only needed when we supported 32 bit devices way back when
Ran some local tests to confirm the rounding looks good:
- 1711390872156.703 --> 1711390872157
- 1711390872661.359 --> 1711390872661
- 1711390873618.973 --> 1711390873619
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll also want to make that change in main
for our analytics timestamps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTBTSDK-3703 - ticket to fix on main
switch redirectType { | ||
case .webBrowser(let url), .payPalApp(let url): | ||
let url = URLComponents(url: url, resolvingAgainstBaseURL: true) | ||
if let token = url?.queryItems?.first(where: { $0.name == "token" || $0.name == "ba_token" })?.value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question, is there ever an instance where we'd get both of these params back for the app switch flow but only actually care about 1 of them? Asking because if so we may always want to attempt to parse the ba_token
first then if not there move on to the token
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! We should prioritize the ba_token
over the token
if both are available. Since this change also needs to be made on main
(+ tests added for the priority), I was thinking it could be a separate PR targeting main
first, and then handling the merge conflicts when updating this branch. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I am fine if we want to target that on main instead of here. The merge conflict may be a bit weird since it'll likely be in the section we removed in this PR, but the tests would help us remember.
if let urlTimestamp = urlComponents?.queryItems?[1].value { | ||
XCTAssertNotNil(Int(urlTimestamp)) | ||
} else { | ||
XCTFail("Expected integer value for query param `switch_initiated_time`") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let urlTimestamp = urlComponents?.queryItems?[1].value { | |
XCTAssertNotNil(Int(urlTimestamp)) | |
} else { | |
XCTFail("Expected integer value for query param `switch_initiated_time`") | |
} | |
XCTAssertNotNil(Int(urlComponents?.queryItems?[1].value ?? '')) |
🧶 : Take or leave to avoid if statement in the test.
#endif | ||
|
||
/// The type of PayPal authentication flow to occur | ||
enum PayPalRedirectType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: Would it make sense for this enum to be in it's own file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to leave in here since it's so small, but down to move if folks feel strongly!
@@ -4,7 +4,8 @@ import BraintreeCore | |||
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { | |||
|
|||
private let returnURLScheme = "com.braintreepayments.Demo.payments" | |||
private let universalLinkURL = "https://braintree-ios-demo.fly.dev/braintree-payments" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: Is this the domain that hosts the apple-app-site-association
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Our Demo app now has an HTTPS URL registered for it 🎊 - https://braintree-ios-demo.fly.dev/.well-known/apple-app-site-association
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jax built it out https://github.com/jaxdesmarais/fly-server-demo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that's cool!
… preferred styling & remove unneeded newling in PP tests
DTBTSDK-3612
Summary of changes
/v1/paypal_hermes/create_payment_resource
&/v1/paypal_hermes/setup_billing_agreement
URL response parsing into new fileBTPayPalApprovalURLParser
URLComponents
paypalAppApprovalUrl
response param present from gatewayChecklist
Added a changelog entryAuthors
@scannillo