Skip to content

PROD 2450 pay and redirect to thank you page -> Intake form #204

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

Conversation

hentrymartin
Copy link
Collaborator

What's in this PR?

  • Payment logic
  • Create customer payment
  • Confirm customer payment
  • Activate challenge
  • Redirect to thank you page
  • Populate payment form with name and email address
  • Show error in payment form when payment failed

Screenshots

Screenshot 2022-07-22 at 00 43 59

@mmattlin
Copy link

Something small I noticed, the Country input field says Date instead of Country or Region

createAsync as workStoreCreateAsync,
confirmCustomerPayment as workStoreConfirmCustomerPaymentAsync,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not about this PR, but about the discussion below about single imports - this is an example of why I think the current structure is a bit obfuscated - we are not only masking where code lives, but renaming it along the way, which means finding the actual source of a function is a multi-step search throughout the codebase.

It is fine for the PR - I did it myself in an earlier PR. Just a discussion worth having at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I agree 👍🏻. I just followed the existing convention here. Personally, the function name aliasing is definitely confusing.

const [isPaymentFailed, setPaymentFailed]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
const navigate: NavigateFunction = useNavigate()

const stripe: Stripe | null = useStripe()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious - Does the ' | null' imply that useStripe is async and might not have a value immediately?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik, it is not async. The stripe type definition define it in a way it can be a Stripe object or null. Possibly the function would return null if the stripe configs are incorrect. If this is an async function they would have made the return type as Promise.

return workBugHuntConfig.priceConfig.getPrice(workBugHuntConfig.priceConfig, packageType)
}

function renderWorkServicePrice(): JSX.Element {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pull this into a function instead of just wrapping the basicInfo check around the JSX tag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dave-armstrong-topcoder I had to do this to resolve cyclomatic complexity error :(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was afraid that was going to be the answer. @casey-tc and I discussed that rule a bit - I believe it is set too low. If we are actually making our code more complex to reduce complexity... something ain't right. 🤣

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dave-armstrong-topcoder - yup, we will be changing the level in PTC so we are not blocked by errors like this.

}

async function onPay(): Promise<any> {
if (!stripe || !elements || !challenge) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets back to why I asked if useStripe was async above - if it can be null, and someone pays while it is still null, it will bail here - but to the user it would look like a button did nothing.
This feels like it would be an extreme edge case for someone to submit that quickly, so it is probably fine. But if there is a realistic chance of it being null, we might want a message to the user of some kind.

Copy link

@dave-armstrong-topcoder dave-armstrong-topcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I posed a few questions - if there are quick updates to resolve them, cool. But as we're trying to finish up today, I believe it is also fine if we just log the concerns as TODOs in the code, or new cards in Jira, too.

@hentrymartin hentrymartin merged commit 66ec3ce into PROD-2321_bug-hunt-intake-form Jul 22, 2022
@hentrymartin hentrymartin deleted the PROD-2450_pay-and-complete branch July 22, 2022 16:03
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.

4 participants