Skip to content
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

[ShopperInsights] Add EligiblePayments API Call #1171

Merged
merged 12 commits into from
Jan 18, 2024

Conversation

scannillo
Copy link
Contributor

@scannillo scannillo commented Jan 10, 2024

Summary of changes

  • Update BTAPIClient & BTHTTP to support API calls to paypal.com APIs
  • Add BTEligiblePaymentsRequest struct to house POST body for v2/payments/find-eligible-methods API call
  • Add relevant unit tests
  • Leave TODO for parsing result of API call

Notes

  • API call still expected to 403 right now ⚠️
  • Adding support for hitting a PayPal API reveals how tightly coupled our networking implementation is to BT API specifics
    • A few highlights:
      • BTHTTP & BTGraphQLHTTP have a lot of overlap & duplication (3 different URLSession configurations, 2 different URLRequest creation sites)
      • No service-agnostic networking interface
    • When time permits, I think there's room to rework things similar to how we did in a series of PPCP PRs
    • Especially if we want to make BraintreeCore the potential unified dependency for networking & analytics b/w PPCP & BT 👀

Checklist

  • Added a changelog entry

Authors

@scannillo

return
}

let customer = lastPostParameters["customer"] as! [String: Any]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏈 Would love for us to implement a cleaner way to verify JSON structure across our SDKs test suite

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android, we use https://github.com/skyscreamer/JSONassert.
Maybe you could try using https://github.com/iwill/generic-json-swift on iOS?

Copy link
Contributor Author

@scannillo scannillo Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 Thanks for those resources! Cool that it plays easy w/ Codable, too.

@scannillo scannillo marked this pull request as ready for review January 11, 2024 23:03
@scannillo scannillo requested a review from a team as a code owner January 11, 2024 23:03
Sources/BraintreeCore/BTAPIClient.swift Outdated Show resolved Hide resolved
@@ -178,6 +179,14 @@ import Foundation
graphQLHTTP = BTGraphQLHTTP(url: graphQLBaseURL, tokenizationKey: tokenizationKey)
}
}

if paypalHTTP == nil {
let paypalBaseURL: URL? = paypalAPIURL(forEnvironment: configuration?.environment ?? "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make this method return a non-optional URL? Based on this method it seems like the default is the prod URL. Based on the defaulting behavior it may also make sense to make the environment optional instead of passing an empty string here if we don't get one from the config. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - good ❓. I was following the existing pattern that we have for the GraphQL API implementation (see here).

I agree though, it's definitely funky.

Wrote this in the PR notes a bit, but this PR revealed how tightly coupled our networking layer is to BT APIs. Even the GraphQL stuff feels very tacked-on. I think we could benefit from a re-design, but wanted to 🏈 on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure down to 🏈 on it. Agree the network layer as a whole needs an overhaul, so we can certainly tackle it in a future PR.

@scannillo
Copy link
Contributor Author

scannillo commented Jan 16, 2024

Marking this as "Blocked" since there is talks that the BT GW will wrap this API call, versus us having to hit the PP API directly.

@scannillo scannillo removed the blocked label Jan 17, 2024
@scannillo
Copy link
Contributor Author

scannillo commented Jan 17, 2024

Removing blocked label, as the API team has updated the API to send mock response values back given certain emails. Follow-up PR to come with parsing logic!

@scannillo scannillo requested a review from agedd January 18, 2024 16:57
Copy link

@MaxHastingsPP MaxHastingsPP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@jaxdesmarais jaxdesmarais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@scannillo scannillo merged commit 296691a into payment-insights-feature Jan 18, 2024
6 of 7 checks passed
@scannillo scannillo deleted the eligibile-payments-api branch January 18, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants