-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[MBL-2366] Fix update payment method for PLOT pledges #2398
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
[MBL-2366] Fix update payment method for PLOT pledges #2398
Conversation
paymentSourceId
or applePay
when change payment meth…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 have a suggestion around avoiding so many conditional properties and ternary operators.
Also, was this error due to a recent backend change? I'm surprised this didn't come up in the original QA sessions.
// Check if this is a change payment method and PLOT pledge; if so, only include paymentSourceId or applePay. | ||
let isChangePaymentMethodAndPlot = updateBackingData | ||
.pledgeContext == .changePaymentMethod && updateBackingData.backing.paymentIncrements.count > 0 | ||
|
||
let shouldOmitAmount = updateBackingData.backing | ||
.isLatePledge || isFixPledge || isChangePaymentMethodAndPlot | ||
let shouldOmitLocationAndRewards = isFixPledge || isChangePaymentMethodAndPlot | ||
|
||
return UpdateBackingInput( | ||
amount: (updateBackingData.backing.isLatePledge || isFixPledge) ? nil : pledgeTotal, | ||
amount: shouldOmitAmount ? nil : pledgeTotal, | ||
applePay: isApplePay ? updateBackingData.applePayParams : nil, | ||
id: backingId, | ||
locationId: isFixPledge ? nil : locationId, | ||
locationId: shouldOmitLocationAndRewards ? nil : locationId, | ||
paymentSourceId: isApplePay ? nil : updateBackingData.paymentSourceId, | ||
rewardIds: isFixPledge ? nil : rewardIds, | ||
rewardIds: shouldOmitLocationAndRewards ? nil : rewardIds, | ||
setupIntentClientSecret: updateBackingData.setupIntentClientSecret |
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.
The multiple ternary operators and conditional properties are starting to make this constructor method a bit messy and convoluted.
It could be worth considering making a new constructor method specific to this use case instead of handling the different cases in this one.
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’ll take care of this refactor in a dedicated clean-up ticket. I’ll also use that ticket to address a related fix needed for late pledges.
More details in the clean-up ticket.
This behavior changed due to a recent backend update! That’s why it didn’t surface during the original QA sessions. |
…od for PLOT pledges
8c8370f
to
1bd2bff
Compare
📲 What
Fixes the Feature disabled error shown when attempting to change the payment method for PLOT pledges by ensuring only the
paymentSourceId
orapplePay
field is sent, and excludingrewardIds
,amount
, andlocationId
.🤔 Why
The backend expects only
paymentSourceId
orapplePay
to be present in the payload when updating payment method for PLOT pledges. Sending additional fields likerewardIds
causes the endpoint to reject the request with a Feature disabled error.🛠 How
isChangePaymentMethodAndPlot
.amount
,rewardIds
, andlocationId
from theUpdateBackingInput
payload when the context is.changePaymentMethod
and the pledge is a PLOT type.👀 See
✅ Acceptance criteria
⏰ TODO