8000 [MBL-2366] Fix update payment method for PLOT pledges by jovaniks · Pull Request #2398 · kickstarter/ios-oss · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[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

Merged
merged 2 commits into from
Apr 25, 2025

Conversation

jovaniks
Copy link
Contributor

📲 What

Fixes the Feature disabled error shown when attempting to change the payment method for PLOT pledges by ensuring only the paymentSourceId or applePay field is sent, and excluding rewardIds, amount, and locationId.

🤔 Why

The backend expects only paymentSourceId or applePay to be present in the payload when updating payment method for PLOT pledges. Sending additional fields like rewardIds causes the endpoint to reject the request with a Feature disabled error.

🛠 How

  • Introduced a new boolean condition isChangePaymentMethodAndPlot.
  • Used this to conditionally exclude amount, rewardIds, and locationId from the UpdateBackingInput payload when the context is .changePaymentMethod and the pledge is a PLOT type.

👀 See

Before 🐛 After 🦋
image image

✅ Acceptance criteria

  • Able to update the payment method on a PLOT pledge without receiving a Feature disabled error.
  • Confirm correct behavior on both Apple Pay and card-based pledges.

⏰ TODO

  • Confirm behavior with backend team across different pledge types if needed.

@jovaniks jovaniks changed the title Only include paymentSourceId or applePay when change payment meth… [MBL-2366] Fix update payment method for PLOT pledges Apr 23, 2025
Copy link
Contributor
@scottkicks scottkicks left a 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.

Comment on lines +21 to 36
// 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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jovaniks
Copy link
Contributor Author

👍

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.

This behavior changed due to a recent backend update! That’s why it didn’t surface during the original QA sessions.

@jovaniks jovaniks force-pushed the jluna/MBL-2366/plot-pledges-update-payment-method-fix branch from 8c8370f to 1bd2bff Compare April 25, 2025 15:32
@jovaniks jovaniks merged commit 1a3de55 into main Apr 25, 2025
5 checks passed
@jovaniks jovaniks deleted the jluna/MBL-2366/plot-pledges-update-payment-method-fix branch April 25, 2025 16:09
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.

3 participants
0