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

[V7] Add Encodable protocol for PayPal Vault #1492

Draft
wants to merge 13 commits into
base: paypal-checkout-encodable
Choose a base branch
from

Conversation

richherrera
Copy link
Contributor

Summary of changes

  • Add encodable types for post bodies used in the PayPal Vault flow.
  • PayPal Vault has been tested in the Demo app to ensure the dictionaries are still constructed as expected.

Checklist

  • [ ] Added a changelog entry
  • Tested and confirmed payment flows affected by this change are functioning as expected

Authors

@richherrera richherrera self-assigned this Jan 3, 2025
@richherrera richherrera requested a review from a team as a code owner January 3, 2025 20:43
@richherrera richherrera marked this pull request as draft January 3, 2025 20:43
@richherrera richherrera marked this pull request as ready for review January 6, 2025 20:55
@richherrera richherrera marked this pull request as draft January 6, 2025 21:01
@@ -401,6 +403,21 @@ import BraintreeDataCollector
}
}
}

private func encodedPostBody(fromRequest payPalRequest: BTPayPalRequest, configuration: BTConfiguration) -> Encodable? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private func encodedPostBody(fromRequest payPalRequest: BTPayPalRequest, configuration: BTConfiguration) -> Encodable? {
private func encodedPostBody(from payPalRequest: BTPayPalRequest, configuration: BTConfiguration) -> Encodable? {

@@ -401,6 +403,21 @@ import BraintreeDataCollector
}
}
}

private func encodedPostBody(fromRequest payPalRequest: BTPayPalRequest, configuration: BTConfiguration) -> Encodable? {
if let checkoutRequest = payPalRequest as? BTPayPalCheckoutRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we instead do a switch here on payPalRequest.paymentType?

@@ -114,6 +119,8 @@ public enum BTPayPalError: Error, CustomNSError, LocalizedError, Equatable {
return "Missing BA Token for PayPal App Switch."
case .missingPayPalRequest:
return "The PayPal Request was missing or invalid."
case .failedToCreateEncodable:
return "Unable to create Encodable object"
Copy link
Contributor

Choose a reason for hiding this comment

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

This may make it a bit more clear, but take it or leave it:

Suggested change
return "Unable to create Encodable object"
return "The request was not a Checkout or Vault request."

@@ -350,19 +350,21 @@ import BraintreeDataCollector

self.isConfigFromCache = configuration.isFromCache

guard json["paypalEnabled"].isTrue else {
guard configuration.isPayPalEnabled else {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can also remove let json = configuration.json above on line 346

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.

2 participants