-
Notifications
You must be signed in to change notification settings - Fork 296
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
Create encodable for credit cards post #1488
base: v7
Are you sure you want to change the base?
Conversation
…dingKeys for the rest body
if card.firstName != nil { | ||
self.billingAddress = BillingAddress(card: card) | ||
} |
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.
Why do we evaluate whether the firstName is not null to create the BillingAddress? I believe that BillingAddress is optional and does not depend on the firstName. What do you think?
if card.firstName != nil { | |
self.billingAddress = BillingAddress(card: card) | |
} | |
self.billingAddress = BillingAddress(card: card) |
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.
This was the original logic. If we don't need it that would be fantastic. @jaxdesmarais can you weigh in on whether this is a business rule?
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 don't see where the logic to check the first name existed for billing address unless I am missing it: https://github.com/braintree/braintree_ios/blob/main/Sources/BraintreeCard/BTCard.swift. Looks like that was changed in this PR.
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 think you're right. I'm not sure why I remembered some logic that encased the BillingInfo...
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.
Okay, I think we can remove this condition here in func encode
if let billingAddress {
try container.encodeIfPresent(billingAddress, forKey: .billingAddress)
}
But we still need to keep a conditional check here
init(card: BTCard) {
if [someCondition]
self.billingAddress = BillingAddress(card: card)
Doing so will keep this original logic intact for not sending an empty BillingAddress json object
if !billingAddressDictionary.isEmpty {
cardDictionary["billingAddress"] = billingAddressDictionary
}
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.
Gotcha, that makes sense to me. Thanks for tracking that down. Maybe here we can do if !card.billingAddress. isEmpty
to match the rest of the object? What do you think?
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.
Hmm.. I don't see a property for billingAddress.
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.
Ah you may be right, I don't think it exists yet. Maybe then doing this makes the most sense:
if let billingAddress {
try container.encodeIfPresent(billingAddress, forKey: .billingAddress)
}
I think there are cases when merchants pass a billing address but don't pass a first name, and with the logic as is we just wouldn't pass the other details along even if they existed if no firstName exists.
…create-encodable-for-credit-cards-post # Conflicts: # Sources/BraintreePayPal/Models/PayPalCheckoutPOSTBody.swift
Summary of changes
Move
/credit_cards
POST to Encodable.Checklist
Authors
@warmkesselj
@jwarmkessel