Skip to content
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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Conversation

navjot-chahal
Copy link
Collaborator

@navjot-chahal navjot-chahal commented Nov 8, 2021

What this PR does:

  • This PR addressed 3 issues i.e. BE, FE, and IN setup for stripe payment.
  • Creates BE routes for getting payment methods, adding a payment method, and updating default payment method.
  • Add a payments section in the profile edit page to add payment options. Users can choose a default option for payment as well.
  • The process flow for the payment process is as shown below.
    Request from dog owner => Hold captured from dog owner card => Conversation between parties added => if sitter accepts then Option Accept, if not Option Decline.

Option Accept => Charge the dog owner => Set the request state to PAID.
Option Decline => Release the Hold amount => Set the request state to DECLINE.

Screenshots / Videos:

  • See the video 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:

  • This feature requires a stripe API account setup.
  • A temp account for Team Scallops under email: [email protected] and password: hatchwaysteamscallops2021@
  • A public and a private key can be obtained from here to make this payment feature work.

closes #5 , #22 , #34

This was linked to issues Nov 8, 2021
Copy link

@sundayezeilo sundayezeilo left a 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>

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.

Comment on lines +18 to +20
// @route POST /payment/add
// @desc Add a new card to the list of payment methods
// @access Private

Choose a reason for hiding this comment

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

Good documentation

Comment on lines +40 to +42
// @route GET /payment/
// @desc Get list of card for the given user
// @access Private

Choose a reason for hiding this comment

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

👍

Comment on lines +65 to +67
// @route PATCH /payment/:cardId
// @desc Update the default card for payment
// @access Private

Choose a reason for hiding this comment

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

👍

Comment on lines +65 to +67
// @route PATCH /payment/:cardId
// @desc Update the default card for payment
// @access Private

Choose a reason for hiding this comment

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

👍

Comment on lines +107 to +133
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;
}

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.

Comment on lines +12 to +14
router.route("/add").post(protect, addCard);
router.route("/").get(protect, getCards);
router.route("/:cardId").patch(protect, UpdateDefaultCard);

Choose a reason for hiding this comment

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

👍

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.

IN: Payment FE: Profile payment BE: Pay Route
2 participants