-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature add be pay route #114
base: develop
Are you sure you want to change the base?
Conversation
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.
This one looks good 👍 Just take look at the few minor comments I left you.
Happy coding!
const classes = useStyles(); | ||
|
||
return ( | ||
<label> |
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 MUI has FormLabel
component you can use. Not sure though, but you can find out.
// @route POST /payment/add | ||
// @desc Add a new card to the list of payment methods | ||
// @access Private |
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 documentation
// @route GET /payment/ | ||
// @desc Get list of card for the given user | ||
// @access Private |
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.
👍
// @route PATCH /payment/:cardId | ||
// @desc Update the default card for payment | ||
// @access Private |
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.
👍
// @route PATCH /payment/:cardId | ||
// @desc Update the default card for payment | ||
// @access Private |
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.
👍
await Promise.all( | ||
Object.entries(input).map(async ([key, value]) => { | ||
if (value) { | ||
if (key === "status" && value === "PAID") return; | ||
else if (key === "status" && value === "ACCEPTED") { | ||
const charge = await stripe.charges.capture(request.chargeId); | ||
if (charge.status === "failed") { | ||
res.status(400); | ||
} else { | ||
request.status = "PAID"; | ||
} | ||
} else if (key === "status" && value === "DECLINED") { | ||
if (!request.chargeId) { | ||
res.status(400); | ||
} | ||
await stripe.refunds.create({ | ||
charge: request.chargeId, | ||
}); | ||
request.status = "DECLINED"; | ||
request.chargeId = null; | ||
} else if (key === "startDate") { | ||
request.startDate = new Date(value); | ||
} else if (key === "endDate") { | ||
request.endDate = new Date(value); | ||
} else { | ||
request[key] = value; | ||
} |
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.
It would be a cleaner code to first map all the Promises and assign them to a variable, then pass the variable to Promise.all
.
router.route("/add").post(protect, addCard); | ||
router.route("/").get(protect, getCards); | ||
router.route("/:cardId").patch(protect, UpdateDefaultCard); |
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.
👍
What this PR does:
profile edit
page to add payment options. Users can choose a default option for payment as well.Request from
dog owner
=> Hold captured fromdog owner
card => Conversation between parties added => if sitter accepts thenOption Accept
, if notOption Decline
.Option Accept
=> Charge thedog owner
=> Set the request state toPAID
.Option Decline
=> Release the Hold amount => Set the request state toDECLINE
.Screenshots / Videos:
Demo
below for the complete payment process.Screen.Recording.2021-11-08.at.12.34.48.AM.mov
Any information needed to test this feature:
Team Scallops
under email:[email protected]
and password:hatchwaysteamscallops2021@
closes #5 , #22 , #34