Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
5562e2e3
Commit
5562e2e3
authored
4 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
[Ref] Readability extraction in Dummy class
parent
1c6b6bb0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Core/Payment/Dummy.php
+20
-16
20 additions, 16 deletions
CRM/Core/Payment/Dummy.php
with
20 additions
and
16 deletions
CRM/Core/Payment/Dummy.php
+
20
−
16
View file @
5562e2e3
...
...
@@ -94,22 +94,9 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment {
$result
[
'trxn_id'
]
=
array_shift
(
$this
->
_doDirectPaymentResult
[
'trxn_id'
]);
return
$result
;
}
if
(
$this
->
_mode
===
'test'
)
{
$query
=
"SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test
\\
_%'"
;
$p
=
[];
$trxn_id
=
(
string
)
CRM_Core_DAO
::
singleValueQuery
(
$query
,
$p
);
$trxn_id
=
str_replace
(
'test_'
,
''
,
$trxn_id
);
$trxn_id
=
(
int
)
$trxn_id
+
1
;
$params
[
'trxn_id'
]
=
'test_'
.
$trxn_id
.
'_'
.
uniqid
();
}
else
{
$query
=
"SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'live_%'"
;
$p
=
[];
$trxn_id
=
(
string
)
CRM_Core_DAO
::
singleValueQuery
(
$query
,
$p
);
$trxn_id
=
str_replace
(
'live_'
,
''
,
$trxn_id
);
$trxn_id
=
(
int
)
$trxn_id
+
1
;
$params
[
'trxn_id'
]
=
'live_'
.
$trxn_id
.
'_'
.
uniqid
();
}
$params
[
'trxn_id'
]
=
$this
->
getTrxnID
();;
$params
[
'gross_amount'
]
=
$propertyBag
->
getAmount
();
// Add a fee_amount so we can make sure fees are handled properly in underlying classes.
$params
[
'fee_amount'
]
=
1.50
;
...
...
@@ -219,4 +206,21 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment {
return
[
'message'
=>
ts
(
'Recurring contribution cancelled'
)];
}
/**
* Get a value for the transaction ID.
*
* Value is made up of the max existing value + a random string.
*
* Note the random string is likely a historical workaround.
*
* @return string
*/
protected
function
getTrxnID
()
{
$string
=
$this
->
_mode
;
$trxn_id
=
CRM_Core_DAO
::
singleValueQuery
(
"SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE '
{
$string
}
_%'"
);
$trxn_id
=
str_replace
(
$string
,
''
,
$trxn_id
);
$trxn_id
=
(
int
)
$trxn_id
+
1
;
return
$string
.
'_'
.
$trxn_id
.
'_'
.
uniqid
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment