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
return transaction after donate #810
Conversation
.then(subscription => models.Donation.create({ | ||
// create a new subscription | ||
// (this needs to happen first, because of hook on Donation model) | ||
.then(() => { |
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.
in many places, your indentation is wrong @asood123. You should check your editor.
it makes it difficult to see in the diff what really changed.
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.
thanks for fixing. Need to figure out how to reenable linting in editor.
server/controllers/donations.js
Outdated
@@ -46,7 +46,7 @@ const stripeDonation = (req, res, next) => { | |||
interval | |||
} | |||
}) | |||
.then(() => res.send({success: true, user: req.user.info })) | |||
.then((transaction) => res.send({success: true, user: req.user.info, transaction })) |
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.
Can you put a comment above this explaining why we are returning transaction
and a TODO that it needs to be reworked when we split the flow? Or add a test that will break if we split the flow.
Longer term, since this will be async, sending redirect link via email (that already goes out to confirm the donation) would be better.
server/lib/payments.js
Outdated
@@ -94,37 +95,39 @@ export const createPayment = (payload) => { | |||
PaymentMethodId: paymentMethod.id, | |||
SubscriptionId: subscription && subscription.id, | |||
ResponseId: response && response.id | |||
})); | |||
})) | |||
.then(processPayment); |
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.
processPayment needs two parameters, see afterCreate hook.
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 used to be processPayment(Sequelize, donation)
but there is no need to pass the Sequelize
object.
It doesn't seem that the stub cares about the number of arguments, so not sure where it's failing
In progress.
Needed for #769