-
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-209, NT-156] Pledge Button Interaction (Create Backing) #855
Conversation
…pledge-button-interaction # Conflicts: # Kickstarter-iOS/Views/Controllers/PledgePaymentMethodsViewController.swift
@@ -4,31 +4,32 @@ public struct CreateBackingInput: GraphMutationInput { | |||
let amount: String | |||
let locationId: String? | |||
let paymentSourceId: String | |||
let paymentType: String |
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.
Removed paymentType
because after chatted with the backend team, it's not really an input field (should always be set to credit_card
). They plan on removing the field entirely in the near future.
refTag: RefTag?, | ||
paymentSourceId: String | ||
) -> CreateBackingInput { | ||
let pledgeAmountDecimal = Decimal(pledgeAmount) |
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.
A lot of this is duplicated from CreateApplePayBackingInput
- I decided not to refactor out the shared parts because I know we're planning to consolidate the two mutations in the near future. When we do, we can simply merge the differences from CreateApplePayInput
into this input.
.map(CreateBackingInput.input(from:reward:pledgeAmount:selectedShippingRule:refTag:paymentSourceId:)) | ||
.switchMap { input in | ||
AppEnvironment.current.apiService.createBacking(input: input) | ||
.ksr_delay(AppEnvironment.current.apiDelayInterval, on: AppEnvironment.current.scheduler) |
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.
Notice that we don't care about the result here - since we are moving to a synchronous createBacking
mutation, any errors in creating the pledge should come back as regular graph errors.
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.
Great work on this! Appears to do exactly what is says on the tin!
Worth noting that I entered a pledge amount of 0
and could still hit the button and got an 'Oops, something went wrong error'. But as you mention - this will be resolved in follow-up PRs.
|
||
func pledgePaymentMethodsViewControllerDidTapPledgeButton( | ||
_ | ||
viewController: PledgePaymentMethodsViewController |
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 know how much you love formatting comments but this is strange 😄
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.
-_-
|
||
func pledgePaymentMethodsViewControllerDidTapPledgeButton( | ||
_: | ||
PledgePaymentMethodsViewController |
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.
☝️
} | ||
|
||
public func toInputDictionary() -> [String: Any] { | ||
var inputDictionary = [ | ||
"amount": amount, | ||
"paymentSourceId": paymentSourceId, | ||
"paymentType": paymentType, | ||
// swiftlint:disable:next line_length | ||
"paymentType": "credit_card", // this is temporary and will be removed once the mutation has been updated |
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'm guessing we can flag the PaymentType
enum
for removal too?
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.
Oh yeah good call.
📲 What
Hooks up the
createBacking
mutation to the pledge button to allow users to create backings natively.🤔 Why
So that users can pledge with a stored card.
🛠 How
When the pledge button is tapped, a request is made to the
createBacking
mutation which creates the pledge. On success, the user is taken to the "Thanks" screen. If an error occurs, the error is displayed in the message banner on the Pledge Screen.Things to note:
createApplePayBacking
mutation into thecreateBacking
mutation👀 See
✅ Acceptance criteria
Testing RefParam
createBacking
mutation, which should show arefParam
input field a value (ex.discovery_home
,recommendations
).