-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Fix a regression whereby payment details are not saved from the AdditionalPayment form #15537
Conversation
(Standard links)
|
ab1552f
to
366d2f5
Compare
@eileenmcnaughton test fails look related - they're all returning
|
@@ -390,6 +390,9 @@ function _civicrm_api3_get_BAO($name) { | |||
// not the other cache info like search results (which could in fact be in Redis or another cache engine) | |||
$name = 'PrevNextCache'; | |||
} | |||
if ($name === 'Payment') { | |||
$name = 'FinancialTrxn'; | |||
} |
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.
@eileenmcnaughton Is this change required for this PR? As I understand it Payment does not map directly to FinancialTrxn but wraps the financial entities.
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 yes - otherwise the pseudoconstant doesn't work.
Payment is a psuedo-api that represents one specific type of FinancialTrxn - hence the presence of 'is_payment' as a fixed parameter when creating a financial_trxn from the payment api.
Ie it's a subset of the FinancialTrxn entity
api/v3/Payment.php
Outdated
'order_reference' => [ | ||
'name' => 'order_reference', | ||
'type' => CRM_Utils_Type::T_STRING, | ||
'title' => ts('Order Reference'), | ||
'description' => ts('Payment Processor external order reference'), | ||
'maxlength' => 255, | ||
'size' => 25, | ||
'where' => 'civicrm_financial_trxn.order_reference', | ||
'table_name' => 'civicrm_financial_trxn', | ||
'entity' => 'FinancialTrxn', | ||
'bao' => 'CRM_Financial_DAO_FinancialTrxn', | ||
'localizable' => 0, | ||
'html' => [ | ||
'type' => 'Text', | ||
], | ||
], |
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.
@eileenmcnaughton order_reference
was only added in 5.20 - will this cause problems on 5.19 as the column won't exist in the DB?
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.
Yeah - I think it's the cause of the test fails - I just pulled it out again
api/v3/Payment.php
Outdated
'type' => CRM_Utils_Type::T_INT, | ||
'description' => ts('Payment processor ID - required for payment processor payments'), | ||
'title' => ts('Payment Processor'), | ||
'description' => ts('Payment Processor for this financial 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 we use Payment processor for this payment
. As the payment API will be creating one or more financial transactions depending on the action.
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.
Yes - good point
CRM/Financial/BAO/Payment.php
Outdated
@@ -59,27 +59,36 @@ public static function create($params) { | |||
|
|||
$isPaymentCompletesContribution = self::isPaymentCompletesContribution($params['contribution_id'], $params['total_amount']); | |||
|
|||
$whiteList = ['check_number', 'payment_processor_id', 'fee_amount', 'total_amount', 'contribution_id', 'net_amount', 'card_type_id', 'pan_truncation', 'trxn_result_code', 'payment_instrument_id', 'order_reference', 'trxn_id']; |
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.
@eileenmcnaughton See comment on order_reference
which is only available from 5.20 - though I don't think it will cause problems in this list.
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.
yep - removed
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.
@eileenmcnaughton I've added a couple of comments. The main concern is around order_reference
which did not exist in 5.19.
Is there a minimum version of this PR without the variable rename that could be merged for 5.19 and then do the rest for 5.20?
As this is modifying the internals of CRM_Financial_BAO_Payment::create
it has the potential to break badly if we've missed anything!
72b09f5
to
275b4c9
Compare
@mattwire I've fixed the order_reference part. To be honest I started working on 5.20 & then moved back to 5.19 once I realised I'd hit a regression. The variable rename is 'safe' & hopefully my comments on the other PR address your concerns. If so we can merge that to sync this with current master & rebase this to be cleaner |
test this please |
275b4c9
to
3085d15
Compare
@eileenmcnaughton Please rebase and I'll take another look |
3085d15
to
cab89cc
Compare
@mattwire done - also FYI - the reason I moved the param gathering outside the IF is that the same params are actually required if total_amount < 0 - that code is for historical reasons in it's own function but over a few refactors it would start to share that paymentParams array |
69c028d
to
3643945
Compare
Hopefully that sorts the test. Along with #15561 we should aim for 5.18 |
d4cbc42
to
7d628f4
Compare
test this please |
I've tested this on contribution, event payments and confirm that the params are correctly set after the submission. The payment.create api call can also set these values in the record. Failing test is SyntaxConformanceTest.php::testLimit for Payment Entity. Should this entity be added to |
On some digging I found that various payment related fields like pan_truncation & card_type_id were being quietly ignored rather than saved by Payment.create The additional payment form now uses this api so it is a regression on that form. This fixes the metadata, tests & support for payment-related trxn fields
7d628f4
to
a494d7a
Compare
Agreed elsewhere that the param name change is fine
merging as per the collective reviews |
Overview
I discovered the Payment.create api is not respecting a bunch of parameters - since this is now called from the AdditionalPaymentForm they are not being saved.
payment_instrument_id, card_type_id, pan_truncation & other field were not being passed through - resulting in incorrect payment saves
Before
Add a pending contribution & then submit a credit card payment using the additional payment form
After
Technical Details
This looks worse than it is because I also had to pull in my upstream param renaming commit #15535
Comments
@monishdeb @jitendrapurohit can one of you check