-
Notifications
You must be signed in to change notification settings - Fork 0
CIVIMM-462: Copy payment_instrument_id to instalments #13
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,7 +149,8 @@ public function getDueRecurringContributions(string $processorType, int $batchSi | |
| 'amount', | ||
| 'currency', | ||
| 'financial_type_id', | ||
| 'campaign_id' | ||
| 'campaign_id', | ||
| 'payment_instrument_id' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While adding Please add tests to References
|
||
| ) | ||
| ->addJoin( | ||
| 'PaymentProcessor AS pp', | ||
|
|
@@ -258,6 +259,10 @@ public function createInstalment(RecurringContributionDTO $recur, string $receiv | |
| $createAction->addValue('campaign_id', $recur->getCampaignId()); | ||
| } | ||
|
|
||
| if ($recur->getPaymentInstrumentId() !== NULL) { | ||
| $createAction->addValue('payment_instrument_id', $recur->getPaymentInstrumentId()); | ||
| } | ||
|
|
||
| $result = $createAction->execute()->first(); | ||
|
|
||
| if (!is_array($result)) { | ||
|
|
||
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.
The use of
isset()here could allow apayment_instrument_idof0to be considered valid. In CiviCRM, entity IDs are typically positive integers, so0is not a valid ID. This could lead to incorrect data being propagated.To ensure only valid, positive IDs are processed, it would be safer to use
!empty()which correctly handles0,null, and empty strings as invalid values. This aligns with the principle of failing fast if critical data is missing, rather than masking potential issues with invalid default values.References
strtotime('')evaluating to1970-01-01).