-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
[WIP] Modify backend Record Payment forms to use payment create API. #13330
Conversation
(Standard links)
|
I tested this PR on the RC and the scenario of a 50 euro event fee paid for and changed to 30 extra so the balance is 30.
Note about nr.5 I think when using the backend it would be ideal if one submits a payment that completes the contribution for an event or membership, an option is given to either send an confirmation email or not. Sometimes am administrator just wants to register payments without sending emails to the participants. So either an optional confirmation mail or the current behavior: no mail after backend completion of an event contribution is ok I think. |
This is a partial of civicrm#13330 - trying to separate out the main code move from the changes. My only change was to change the name to addPayment since that is what we are doing but here are some additionaly thoughts. 1) I'm inclined to put the class onto a new pseudo-bao CRM_Finanial_BAO_Payment. We already have this pseudo-entity on the api level & it gives us a way to build up a place for the functions we are migrating towards. 2) I think we should consider changing the input parameters to this function to be - contributionID, total_amount & line_items or in some way limiting the parameters tha t get passed through. We have historically gotten ourselves in trouble by having people hacking in another parameter to go through whereas the strength of the api is clear inputs & outputs. I note the api will need to support 'is_email_receipt' as will this fn & the CRM_Contribute_Form_AdditionalPayment::emailReceipt should be moved off the form layer - possibly to our new BAO 3) I think the exceptions need to be CRM_Core_Exceptions if thrown in the BAO although this is kinda cosmetic
This is a partial of civicrm#13330 - trying to separate out the main code move from the changes. My only change was to change the name to addPayment since that is what we are doing but here are some additionaly thoughts. 1) I'm inclined to put the class onto a new pseudo-bao CRM_Finanial_BAO_Payment. We already have this pseudo-entity on the api level & it gives us a way to build up a place for the functions we are migrating towards. 2) I think we should consider changing the input parameters to this function to be - contributionID, total_amount & line_items or in some way limiting the parameters tha t get passed through. We have historically gotten ourselves in trouble by having people hacking in another parameter to go through whereas the strength of the api is clear inputs & outputs. I note the api will need to support 'is_email_receipt' as will this fn & the CRM_Contribute_Form_AdditionalPayment::emailReceipt should be moved off the form layer - possibly to our new BAO 3) I think the exceptions need to be CRM_Core_Exceptions if thrown in the BAO although this is kinda cosmetic
This is a partial of civicrm#13330 - trying to separate out the main code move from the changes. My only change was to change the name to addPayment since that is what we are doing but here are some additionaly thoughts. 1) I'm inclined to put the class onto a new pseudo-bao CRM_Finanial_BAO_Payment. We already have this pseudo-entity on the api level & it gives us a way to build up a place for the functions we are migrating towards. 2) I think we should consider changing the input parameters to this function to be - contributionID, total_amount & line_items or in some way limiting the parameters tha t get passed through. We have historically gotten ourselves in trouble by having people hacking in another parameter to go through whereas the strength of the api is clear inputs & outputs. I note the api will need to support 'is_email_receipt' as will this fn & the CRM_Contribute_Form_AdditionalPayment::emailReceipt should be moved off the form layer - possibly to our new BAO 3) I think the exceptions need to be CRM_Core_Exceptions if thrown in the BAO although this is kinda cosmetic Change-Id: Ib5caf0d878e9c5cc735cb1a20c640f61da2dbfc6
This is a partial of civicrm#13330 - trying to separate out the main code move from the changes. My only change was to change the name to addPayment since that is what we are doing but here are some additionaly thoughts. 1) I'm inclined to put the class onto a new pseudo-bao CRM_Finanial_BAO_Payment. We already have this pseudo-entity on the api level & it gives us a way to build up a place for the functions we are migrating towards. 2) I think we should consider changing the input parameters to this function to be - contributionID, total_amount & line_items or in some way limiting the parameters tha t get passed through. We have historically gotten ourselves in trouble by having people hacking in another parameter to go through whereas the strength of the api is clear inputs & outputs. I note the api will need to support 'is_email_receipt' as will this fn & the CRM_Contribute_Form_AdditionalPayment::emailReceipt should be moved off the form layer - possibly to our new BAO 3) I think the exceptions need to be CRM_Core_Exceptions if thrown in the BAO although this is kinda cosmetic
Seamus merged my 'move code only' sub-cut of this - so https://github.com/civicrm/civicrm-core/compare/master...eileenmcnaughton:payment_j?expand=1 is the rebased commit from this PR I feel like the 2 things I feel I want clarity on at this stage are
|
@jitendrapurohit can you please rebase your PR |
@jitendrapurohit @monishdeb I actually did a rebase - there was a link to it from the other PR - I didn't open it because I wanted to discuss the question of a new class for these functions first - per the #13370 comments & also the question about the email will affect a lot of things |
cb4345f
to
2678bd4
Compare
… it. This is per discussions coming off civicrm#13330 Note that this ONLY moves the code - that PR does other things as well that still need to be worked through
… it. This is per discussions coming off civicrm#13330 Note that this ONLY moves the code - that PR does other things as well that still need to be worked through
… it. This is per discussions coming off civicrm#13330 Note that this ONLY moves the code - that PR does other things as well that still need to be worked through
4a7cac0
to
69bec4b
Compare
I've rebased the PR with the current status of master. This now contains fixes related to
|
18f934e
to
1e80516
Compare
I like this patch as it moves the code to process refund or owed payment into Payment.create API. Did a quick test with partial and refund payment in UI and it works fine, also with the Send Email reciept. Added UT looks good. @eileenmcnaughton @mattwire @magnolia61 any final thoughts before merging this PR? On a separate note, how about moving CRM_Contribute_BAO_Contribution::recordAdditionalPayment to CRM_Financial_BAO_Payment::recordAdditionalPayment in a separate PR |
if ($sendReceipt) { | ||
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.'); | ||
} | ||
if (empty($payment['is_error']) && !empty($this->_params['is_email_receipt'])) { |
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.
So I think the payment params could be modified by hooks once Payment.create has been called but we are relying on the value of is_email_receipt
from before that function is called. Are we able to use the returned parameters of Payment.create to check if is_email_receipt
stayed TRUE and therefore an email actually got sent?
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.
@mattwire I don't think payment params can be modified by any hooks, as I don't see pre/post hook are invoked inside Payment::create() BAO fn, or is there any at API level which I am unaware of?
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.
ok, then I'm ok with this.
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.
Just one comment about the is_email_receipt
parameter. Apart from that all fine from me - nice cleanup too!
So where I'm at with this in general is that the Payment.create function should send appropriate email receipts parameter dependent & I want to clarify that & get the tests sorted for that . The current blocker for me is clarifying exactly what emails should go out (and getting that separately committed & tested in preparation). The Payment.create api would ideally be called from many forms - ie. we should anticipate that eventually we would replace all the places in the code that call Contribution.completetransaction with Payment.create (with the latter being called if the payment does complete a transaction.) It seems to me we have 3 scenarios
In the latter case do we send out the online invoice receipt as we would when calling Contribution.completeorder or some other one or do they get 2 receipts. What about in case 2? Is the off/on is_email_receipt the right parameter to pass in @JoeMurray I pinged the above question to you somewhere else in the discussions around this but it got lost along the way Note |
@eileenmcnaughton I have a concern in handling both partial and refund payment in a single Payment::create API rather than handling them in Payment::partial and Payment::refund, BAO fns and APIs respectively. Actually as per the refund spec here I suppose to have a separate API but if we I go with this PR fix then I shouldn't need to have separate API. What do you think? Or we should bring the separation in a separate PR ? NOTE: The Payment::create should be restricted to Contribution.completetransaction + handling financial record on Complete payment. |
Re: separate API for refund vs include in existing payment.create as a negative payment. We're moving from merely recording refunds in CiviCRM to actually sending the money out in some current work. Sending money out tends to need a separate permission. I would prefer for refunds to be in a separate BAO / api to facilitate this. |
Eileen wrote:
+1 |
This adds a new api Payment.sendconfirmation intended to be an equivalent of Contribution.sendconfirmation. The key thing this needs to be able to do is to load up all related information to assign to the template - this is not all covered in this PR & until it is functionally equivalent to AdditionalPayment::sendEmail we can't switch over but since it's new functionality we should be able to merge & keep working on it. Note that there is discussion on the PR this relates to (civicrm#13330) about what should happen if 'Payment.create' api accepts 'is_email_receipt'. I think the most logical outcome is that receipts would go out if it caused the contribution to be completed (ie. we pass is_email_receipt into completetransaction api). However, I don't feel like that is 'settled' yet - separating into a second api (Payment.sendnotification) means we will have 2 generic function which can be called from multiple places in the code rather than 2 functions tightly tied to the form layer. I think it's OK if it is 2 not one
This adds a new api Payment.sendconfirmation intended to be an equivalent of Contribution.sendconfirmation. The key thing this needs to be able to do is to load up all related information to assign to the template - this is not all covered in this PR & until it is functionally equivalent to AdditionalPayment::sendEmail we can't switch over but since it's new functionality we should be able to merge & keep working on it. Note that there is discussion on the PR this relates to (civicrm#13330) about what should happen if 'Payment.create' api accepts 'is_email_receipt'. I think the most logical outcome is that receipts would go out if it caused the contribution to be completed (ie. we pass is_email_receipt into completetransaction api). However, I don't feel like that is 'settled' yet - separating into a second api (Payment.sendnotification) means we will have 2 generic function which can be called from multiple places in the code rather than 2 functions tightly tied to the form layer. I think it's OK if it is 2 not one
This adds a new api Payment.sendconfirmation intended to be an equivalent of Contribution.sendconfirmation. The key thing this needs to be able to do is to load up all related information to assign to the template - this is not all covered in this PR & until it is functionally equivalent to AdditionalPayment::sendEmail we can't switch over but since it's new functionality we should be able to merge & keep working on it. Note that there is discussion on the PR this relates to (civicrm#13330) about what should happen if 'Payment.create' api accepts 'is_email_receipt'. I think the most logical outcome is that receipts would go out if it caused the contribution to be completed (ie. we pass is_email_receipt into completetransaction api). However, I don't feel like that is 'settled' yet - separating into a second api (Payment.sendnotification) means we will have 2 generic function which can be called from multiple places in the code rather than 2 functions tightly tied to the form layer. I think it's OK if it is 2 not one
This adds a new api Payment.sendconfirmation intended to be an equivalent of Contribution.sendconfirmation. The key thing this needs to be able to do is to load up all related information to assign to the template - this is not all covered in this PR & until it is functionally equivalent to AdditionalPayment::sendEmail we can't switch over but since it's new functionality we should be able to merge & keep working on it. Note that there is discussion on the PR this relates to (civicrm#13330) about what should happen if 'Payment.create' api accepts 'is_email_receipt'. I think the most logical outcome is that receipts would go out if it caused the contribution to be completed (ie. we pass is_email_receipt into completetransaction api). However, I don't feel like that is 'settled' yet - separating into a second api (Payment.sendnotification) means we will have 2 generic function which can be called from multiple places in the code rather than 2 functions tightly tied to the form layer. I think it's OK if it is 2 not one
This adds a new api Payment.sendconfirmation intended to be an equivalent of Contribution.sendconfirmation. The key thing this needs to be able to do is to load up all related information to assign to the template - this is not all covered in this PR & until it is functionally equivalent to AdditionalPayment::sendEmail we can't switch over but since it's new functionality we should be able to merge & keep working on it. Note that there is discussion on the PR this relates to (civicrm#13330) about what should happen if 'Payment.create' api accepts 'is_email_receipt'. I think the most logical outcome is that receipts would go out if it caused the contribution to be completed (ie. we pass is_email_receipt into completetransaction api). However, I don't feel like that is 'settled' yet - separating into a second api (Payment.sendnotification) means we will have 2 generic function which can be called from multiple places in the code rather than 2 functions tightly tied to the form layer. I think it's OK if it is 2 not one
This adds a new api Payment.sendconfirmation intended to be an equivalent of Contribution.sendconfirmation. The key thing this needs to be able to do is to load up all related information to assign to the template - this is not all covered in this PR & until it is functionally equivalent to AdditionalPayment::sendEmail we can't switch over but since it's new functionality we should be able to merge & keep working on it. Note that there is discussion on the PR this relates to (civicrm#13330) about what should happen if 'Payment.create' api accepts 'is_email_receipt'. I think the most logical outcome is that receipts would go out if it caused the contribution to be completed (ie. we pass is_email_receipt into completetransaction api). However, I don't feel like that is 'settled' yet - separating into a second api (Payment.sendnotification) means we will have 2 generic function which can be called from multiple places in the code rather than 2 functions tightly tied to the form layer. I think it's OK if it is 2 not one
@eileenmcnaughton @jitendrapurohit I have rebased this PR. Can you please indicate what is the outstanding issue remaining in this patch? |
@monishdeb I think we should pull all the email receipt changes out of it - with that last email receipt change I made I think we can simply call the api from the form & then remove all the entire email function - which will simplify this PR a lot |
Hmm seems like I need to flesh out those code in a separate PR which only contains the Payment.create call on forms w/o email receipt changes. And after that PR is merged, we can rebase this PR |
@monishdeb I'm happy to throw up a PR doing the send change - if you merge the pre-requisite PR first |
(that might make what I mean clearer too :-) |
Will do 👍 |
just adding the link for 'the prerequisit one' #13610 |
@eileenmcnaughton submitted a sub-PR #13647 |
Closing this as it has been superceded by later work - currently stalled pending review on #14673 |
Overview
Modify backend Record Payment forms to use payment create API and move API code to BAO layer.
Before
After
Payment create API is used to records payments for pending or partially paid contributions.
Email receipt function is separated so that it can be also used by front-end payments.
Comments
This is a part of #12319 PR and it only contains fix for the backend payment forms. I'll create another PR to fix partial payment in front end contribution pages.
@magnolia61 Can you confirm if this works fine in your testing? Note that front end fix is yet to be created separately. Thanks.
ping @monishdeb @eileenmcnaughton