Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
capo
smartdebit
Commits
ca4e19a9
Commit
ca4e19a9
authored
Jun 11, 2021
by
capo
Browse files
Fix #8: can't change billing details
parent
3e1ec15e
Changes
4
Hide whitespace changes
Inline
Side-by-side
CRM/Core/Payment/Smartdebit.php
View file @
ca4e19a9
...
...
@@ -1152,7 +1152,7 @@ UPDATE " . CRM_Smartdebit_Base::TABLENAME . " SET
// Update the cached mandate
$params
=
[
'trxn_id'
=>
$smartDebitParams
[
'reference_number'
],
'trxn_id'
=>
$smartDebitParams
[
'
variable_ddi[
reference_number
]
'
],
'refresh'
=>
TRUE
,
];
CRM_Smartdebit_Mandates
::
getbyReference
(
$params
);
...
...
CRM/Smartdebit/Api.php
View file @
ca4e19a9
...
...
@@ -211,7 +211,7 @@ class CRM_Smartdebit_Api {
case
'PUT'
:
$options
[
CURLOPT_CUSTOMREQUEST
]
=
'PUT'
;
$
url
.
=
'?'
.
$data
;
$
options
[
CURLOPT_POSTFIELDS
]
=
$data
;
// curl_setopt($curlSession, CURLOPT_POSTFIELDS, http_build_query($data));
break
;
}
...
...
api/v3/Smartdebit.php
View file @
ca4e19a9
...
...
@@ -239,3 +239,64 @@ function _civicrm_api3_smartdebit_clearcache_spec(&$spec) {
$spec
[
'collections'
][
'title'
]
=
'Clear cached collections'
;
$spec
[
'collections'
][
'type'
]
=
CRM_Utils_Type
::
T_BOOLEAN
;
}
/**
* Populates the processor_id field if its empty. It fills the field
* with the value of the trxn_id.
*
* @see https://lab.civicrm.org/extensions/smartdebit/-/issues/8
*/
function
civicrm_api3_smartdebit_populate_processor_id
(
$params
)
{
$processors
=
civicrm_api3
(
'PaymentProcessor'
,
'get'
,
[
'payment_processor_type_id'
=>
'Smart_Debit'
,
'return'
=>
[
'id'
],
]);
$paymentProcessorIds
=
array_column
(
$processors
[
'values'
],
'id'
);
$contributions
=
civicrm_api3
(
'ContributionRecur'
,
'get'
,
[
'payment_processor_id'
=>
$paymentProcessorIds
,
'processor_id'
=>
[
'IS NULL'
=>
1
],
'trxn_id'
=>
[
'IS NOT NULL'
=>
1
],
'return'
=>
[
'trxn_id'
],
]);
if
(
$contributions
[
'count'
]
==
0
)
{
return
civicrm_api3_create_success
(
[
'payment_processor_ids'
=>
$paymentProcessorIds
,
'fixable_count'
=>
0
,
'fixed_ids'
=>
[],
'fixed_count'
=>
0
,
],
$params
,
'Smartdebit'
,
'populate_processor_id'
);
}
$fixedIds
=
[];
foreach
(
$contributions
[
'values'
]
as
$contribution
)
{
$fixed
=
civicrm_api3
(
'ContributionRecur'
,
'create'
,
[
'id'
=>
$contribution
[
'id'
],
'processor_id'
=>
$contribution
[
'trxn_id'
],
]);
if
(
$fixed
[
'is_error'
]
==
0
)
{
$fixedIds
[]
=
$fixed
[
'id'
];
}
}
return
civicrm_api3_create_success
(
[
'payment_processor_ids'
=>
$paymentProcessorIds
,
'fixable_count'
=>
$contributions
[
'count'
],
'fixed_ids'
=>
$fixedIds
,
'fixed_count'
=>
count
(
$fixedIds
),
],
$params
,
'Smartdebit'
,
'populate_processor_id'
);
}
\ No newline at end of file
docs/api.md
View file @
ca4e19a9
...
...
@@ -49,3 +49,10 @@ Get the number of collections in the database.
#### Smartdebit.retrievecollectionreports
Retrieve collection reports from Smartdebit.
#### Smartdebit.populate_processor_id
Populates the processor_id field if its empty. It fills the field
with the value of the trxn_id.
As described in
[
#8
](
https://lab.civicrm.org/extensions/smartdebit/-/issues/8
)
.
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment