-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NT-422] Payment source refactor #895
Conversation
KsApi/models/Backing.swift
Outdated
public let expirationDate: String? | ||
public let id: String? | ||
public let lastFour: String? | ||
public let paymentType: PaymentType? |
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 this should be non-optional.
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 was following the description of this ticket
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.
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.
OMG! paymentType is non-optional, but type is! Got lost between types π
import Prelude | ||
import ReactiveExtensions | ||
import ReactiveSwift | ||
import UIKit |
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.
Can we get rid of the UIKit
import here and just return the imageName
as a string? I think we generally try to keep our VMs decoupled from UIKit.
|
||
public protocol ManagePledgePaymentMethodViewModelOutputs { | ||
/// Emits the card's image. | ||
var cardImage: Signal<UIImage?, Never> { get } |
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.
Here this could be cardImageName: Signal<String?, Never>
|
||
self.cardNumberAccessibilityLabel = self.paymentSourceSignal | ||
.map { | ||
[$0.type?.description, Strings.Card_ending_in_last_four(last_four: $0.lastFour ?? .init())] |
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.
Is it possible to set this up such that if type
and lastFour
are nil, we don't send anything back in the output? It doesn't seem like we'd ever want a situation where the label reads " , ending in "
π€
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.
Good point. I will change that
.map { Strings.Ending_in_last_four(last_four: $0) } | ||
|
||
self.expirationDateText = self.paymentSourceSignal | ||
.map { String($0.expirationDate?.dropLast(3) ?? "") } |
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.
Same here, I think we probably shouldn't have the signal output when the expirationDate
is nil:
self.expirationDateText = self.paymentSourceSignal
.map { $0.expirationDate }
.skipNil()
.map { String($0.dropLast(3)) }
... etc
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 missed that one. Good catch!
Generated by π« Danger |
@@ -68,12 +91,12 @@ extension Backing: Argo.Decodable { | |||
on that environment. This is a workaround to allow us to test on Staging and should be deleted once the | |||
data is being returned normally. | |||
*/ | |||
private func tryDecodePaymentSource(_ json: JSON?) -> Decoded<GraphUserCreditCard.CreditCard?> { | |||
private func tryDecodePaymentSource(_ json: JSON?) -> Decoded<Backing.PaymentSource?> { |
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 still need this 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.
We do. I tried removing it, but same issue still happens on Staging.
@@ -91,8 +114,27 @@ extension Backing: EncodableType { | |||
} | |||
} | |||
|
|||
extension Backing.PaymentSource: Argo.Decodable { |
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 we could have this only conform to Swift's Decodable
and do a similar function like before to return an Argo.Decodable
success
or failure
?
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.
Just a thought, perhaps this PR is not the place to start doing that, but I think that can be an approach to help us to start moving away from Argo.
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.
Couple questions/comments.
KsApi/models/Backing.swift
Outdated
public static func decode(_ json: JSON) -> Decoded<Backing.PaymentSource?> { | ||
return curry(Backing.PaymentSource.init) | ||
<^> json <|? "expiration_date" | ||
<*> (json <|? "id" <|> (json <| "id" >>- intToString)) |
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.
CJ merged the change to return a String
instead of an Int
so you should be able to remove this now! π
|
||
public protocol ManagePledgePaymentMethodViewModelOutputs { | ||
/// Emits the card's image. | ||
var cardImage: Signal<String, Never> { get } |
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.
Maybe cardImageName
would be more accurate here?
self.vm.inputs.configureWith(value: Backing.PaymentSource.applePay) | ||
|
||
self.cardImage.assertValue("icon--apple-pay") | ||
self.cardNumberTextShortStyle.assertLastValue("Ending in 1111") |
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.
Are we missing an assertion here for the accessibility label? And actually on second thought, do we want to update the accessibility label to indicate that the card is associated with Apple Pay?
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.
Regarding the accessibility label, it's a good idea, but I think this ends up being out of scope for 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.
Thanks for making this change! π
π² What
PaymentSource
to be used on the manage pledge context.π€ Why
GraphUserCreditCard
model, but due some differences between the payloads returned byv1
andgraphQL
, we've decided to create a new model to avoid work arounds.π How
PaymentSource
and making it Argo decodable.ManagePledgePaymentMethodViewModel
π See
β Acceptance criteria
ManagePledgeViewController
orManagePledgePaymentMethodView