Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
capo
Stripe
Commits
5659c61e
Commit
5659c61e
authored
Oct 19, 2019
by
mattwire
Browse files
Extract description generation into it's own function
parent
459131e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
CRM/Core/Payment/Stripe.php
View file @
5659c61e
...
...
@@ -509,10 +509,10 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$contactContribution
=
$this
->
getContactId
(
$params
)
.
'-'
.
(
$this
->
getContributionId
(
$params
)
?:
'XX'
);
$intentParams
=
[
'customer'
=>
$stripeCustomer
->
id
,
'description'
=>
"
{
$params
[
'description'
]
}
{
$contactContribution
}
#"
.
CRM_Utils_Array
::
value
(
'invoiceID'
,
$params
),
'description'
=>
$this
->
getDescription
(
$params
,
'description'
),
];
$intentParams
[
'statement_descriptor_suffix'
]
=
"
{
$contactContribution
}
"
.
substr
(
$params
[
'description'
],
0
,
7
);
$intentParams
[
'statement_descriptor'
]
=
substr
(
"
{
$contactContribution
}
"
.
$params
[
'description'
],
0
,
22
);
$intentParams
[
'statement_descriptor_suffix'
]
=
$this
->
getDescription
(
$params
,
'statement_descriptor_suffix'
);
$intentParams
[
'statement_descriptor'
]
=
$this
->
getDescription
(
$params
,
'statement_descriptor'
);
// This is where we actually charge the customer
try
{
...
...
@@ -717,6 +717,30 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return
$refundParams
;
}
/**
* Get a description field
* @param array $params
* @param string $type
* One of description, statement_descriptor, statement_descriptor_suffix
*
* @return string
*/
private
function
getDescription
(
$params
,
$type
=
'description'
)
{
if
(
!
isset
(
\
Civi
::
$statics
[
__CLASS__
][
'description'
][
'contact_contribution'
]))
{
\
Civi
::
$statics
[
__CLASS__
][
'description'
][
'contact_contribution'
]
=
$this
->
getContactId
(
$params
)
.
'-'
.
(
$this
->
getContributionId
(
$params
)
?:
'XX'
);
}
switch
(
$type
)
{
case
'statement_descriptor'
:
return
substr
(
\
Civi
::
$statics
[
__CLASS__
][
'description'
][
'contact_contribution'
]
.
" "
.
$params
[
'description'
],
0
,
22
);
case
'statement_descriptor_suffix'
:
return
\
Civi
::
$statics
[
__CLASS__
][
'description'
][
'contact_contribution'
]
.
" "
.
substr
(
$params
[
'description'
],
0
,
7
);
default
:
return
"
{
$params
[
'description'
]
}
"
.
\
Civi
::
$statics
[
__CLASS__
][
'description'
][
'contact_contribution'
]
.
" #"
.
CRM_Utils_Array
::
value
(
'invoiceID'
,
$params
);
}
}
/**
* Calculate the end_date for a recurring contribution based on the number of installments
* @param $params
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment