Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mjwshared
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Extensions
mjwshared
Commits
f6ef9827
Commit
f6ef9827
authored
2 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Support cancelling memberships when issuing refunds
parent
0888c2c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Mjwshared/Form/PaymentRefund.php
+30
-0
30 additions, 0 deletions
CRM/Mjwshared/Form/PaymentRefund.php
templates/CRM/Mjwshared/Form/PaymentRefund.tpl
+39
-21
39 additions, 21 deletions
templates/CRM/Mjwshared/Form/PaymentRefund.tpl
with
69 additions
and
21 deletions
CRM/Mjwshared/Form/PaymentRefund.php
+
30
−
0
View file @
f6ef9827
<?php
use
Civi\Api4\LineItem
;
use
Civi\Api4\Membership
;
use
Civi\Api4\Participant
;
use
Civi\Api4\PaymentProcessor
;
use
Civi\Payment\Exception\PaymentProcessorException
;
...
...
@@ -84,6 +85,7 @@ class CRM_Mjwshared_Form_PaymentRefund extends CRM_Core_Form {
case
'civicrm_membership'
:
$membershipIDs
[]
=
$lineItemDetails
[
'entity_id'
];
break
;
}
}
if
(
!
empty
(
$participantIDs
))
{
...
...
@@ -103,6 +105,23 @@ class CRM_Mjwshared_Form_PaymentRefund extends CRM_Core_Form {
}
$this
->
assign
(
'participants'
,
$participantsForAssign
??
NULL
);
if
(
!
empty
(
$membershipIDs
))
{
$membershipsForAssign
=
[];
$this
->
set
(
'membership_ids'
,
$membershipIDs
);
$memberships
=
Membership
::
get
(
FALSE
)
->
addSelect
(
'*'
,
'membership_type_id:label'
,
'status_id:label'
,
'contact_id.display_name'
)
->
addWhere
(
'id'
,
'IN'
,
$membershipIDs
)
->
execute
();
foreach
(
$memberships
->
getArrayCopy
()
as
$membership
)
{
$membership
[
'status'
]
=
$membership
[
'status_id:label'
];
$membership
[
'type'
]
=
$membership
[
'membership_type_id:label'
];
$membership
[
'display_name'
]
=
$membership
[
'contact_id.display_name'
];
$membershipsForAssign
[]
=
$membership
;
}
$this
->
addYesNo
(
'cancel_memberships'
,
E
::
ts
(
'Do you want to cancel these memberships when you refund the payment?'
),
NULL
,
TRUE
);
}
$this
->
assign
(
'memberships'
,
$membershipsForAssign
??
NULL
);
$this
->
addMoney
(
'refund_amount'
,
ts
(
'Refund Amount'
),
TRUE
,
...
...
@@ -173,6 +192,8 @@ class CRM_Mjwshared_Form_PaymentRefund extends CRM_Core_Form {
$paymentID
=
$this
->
get
(
'payment_id'
);
$participantIDs
=
$this
->
get
(
'participant_ids'
);
$cancelParticipants
=
$formValues
[
'cancel_participants'
]
??
FALSE
;
$membershipIDs
=
$this
->
get
(
'membership_ids'
);
$cancelMemberships
=
$formValues
[
'cancel_memberships'
]
??
FALSE
;
try
{
$payment
=
reset
(
civicrm_api3
(
'Mjwpayment'
,
'get_payment'
,
[
'id'
=>
$paymentID
])[
'values'
]);
...
...
@@ -230,6 +251,15 @@ class CRM_Mjwshared_Form_PaymentRefund extends CRM_Core_Form {
}
$message
.
=
' '
.
E
::
ts
(
'Cancelled %1 participant registration(s).'
,
[
1
=>
count
(
$participantIDs
)]);
}
if
(
$cancelMemberships
&&
!
empty
(
$membershipIDs
))
{
Membership
::
update
(
FALSE
)
->
addValue
(
'status_id.name'
,
'Cancelled'
)
->
addWhere
(
'id'
,
'IN'
,
$membershipIDs
)
->
execute
();
$message
.
=
' '
.
E
::
ts
(
'Cancelled %1 membership(s).'
,
[
1
=>
count
(
$membershipIDs
)]);
}
CRM_Core_Session
::
setStatus
(
$message
,
'Refund processed'
,
'success'
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
templates/CRM/Mjwshared/Form/PaymentRefund.tpl
+
39
−
21
View file @
f6ef9827
...
...
@@ -3,38 +3,56 @@
<div
class=
"crm-section crm-mjwshared-paymentrefund-paymentinfo"
>
<div
class=
"label"
>
{
ts
}
Amount
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.total_amount
|
crmMoney
:
$paymentInfo.currency
}
</div>
<div
class=
"label"
>
{
ts
}
Payment date
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.trxn_date
|
crmDate
}
</div>
{
if
$paymentInfo.trxn_id
}
<div
class=
"label"
>
{
ts
}
Transaction ID
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.trxn_id
}
</div>
{/
if
}
{
if
$paymentInfo.order_reference
}
<div
class=
"label"
>
{
ts
}
Order Reference
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.order_reference
}
</div>
{/
if
}
{
if
$paymentInfo.payment_processor_title
}
<div
class=
"label"
>
{
ts
}
Payment Processor
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.payment_processor_title
}
</div>
{/
if
}
{
if
$paymentInfo.trxn_id
}
<div
class=
"label"
>
{
ts
}
Transaction ID
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.trxn_id
}
</div>
{/
if
}
{
if
$paymentInfo.order_reference
}
<div
class=
"label"
>
{
ts
}
Order Reference
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.order_reference
}
</div>
{/
if
}
{
if
$paymentInfo.payment_processor_title
}
<div
class=
"label"
>
{
ts
}
Payment Processor
{/
ts
}
</div><div
class=
"content"
>
{
$paymentInfo.payment_processor_title
}
</div>
{/
if
}
</div>
{
if
$participants
}
<h3>
{
ts
}
This payment was used to register the following participants:
{/
ts
}
</h3>
<div
class=
"crm-section crm-mjwshared-paymentrefund-participants"
>
<br
/>
<ul>
{
foreach
from
=
$participants
item
=
participant
}
<li>
{
$participant.display_name
}
:
{
$participant.event_title
}
(
<em>
{
$participant.status
}
</em>
)
</li>
{/
foreach
}
</ul>
<ul>
{
foreach
from
=
$participants
item
=
participant
}
<li>
{
$participant.display_name
}
:
{
$participant.event_title
}
(
<em>
{
$participant.status
}
</em>
)
</li>
{/
foreach
}
</ul>
</div>
<br
/>
<div
class=
"crm-section crm-mjwshared-paymentrefund-canceloption"
>
<div
class=
"label"
>
{
$form.cancel_participants.label
}
</div>
<div
class=
"content"
>
{
$form.cancel_participants.html
}
</div>
<div
class=
"clear"
></div>
</div>
<div
class=
"crm-section crm-mjwshared-paymentrefund-
participant-
canceloption"
>
<div
class=
"label"
>
{
$form.cancel_participants.label
}
</div>
<div
class=
"content"
>
{
$form.cancel_participants.html
}
</div>
<div
class=
"clear"
></div>
</div>
{/
if
}
<div
class=
"crm-section crm-mjwshared-paymentrefund-canceloption"
>
<div
class=
"label"
>
{
$form.refund_amount.label
}
</div>
<div
class=
"content"
>
<span
id=
'totalAmount'
>
{
$form.currency.html
|
crmAddClass
:
eight
}
{
$form.refund_amount.html
|
crmAddClass
:
eight
}
</span>
{
if
$memberships
}
<h3>
{
ts
}
This payment was used for the following memberships:
{/
ts
}
</h3>
<div
class=
"crm-section crm-mjwshared-paymentrefund-memberships"
>
<br
/>
<ul>
{
foreach
from
=
$memberships
item
=
membership
}
<li>
{
$membership.display_name
}
:
{
$membership.type
}
(
<em>
{
$membership.status
}
</em>
)
</li>
{/
foreach
}
</ul>
</div>
<div
class=
"clear"
></div>
<br
/>
<div
class=
"crm-section crm-mjwshared-paymentrefund-membership-canceloption"
>
<div
class=
"label"
>
{
$form.cancel_memberships.label
}
</div>
<div
class=
"content"
>
{
$form.cancel_memberships.html
}
</div>
<div
class=
"clear"
></div>
</div>
{/
if
}
<div
class=
"crm-section crm-mjwshared-paymentrefund-refundamount"
>
<div
class=
"label"
>
{
$form.refund_amount.label
}
</div>
<div
class=
"content"
>
<span
id=
'totalAmount'
>
{
$form.currency.html
|
crmAddClass
:
eight
}
{
$form.refund_amount.html
|
crmAddClass
:
eight
}
</span>
</div>
<div
class=
"clear"
></div>
</div>
<div
class=
"help"
>
{
ts
}
Click "refund" to refund this payment
{/
ts
}
</div>
<div
class=
"crm-submit-buttons"
>
{
include
file
=
"CRM/common/formButtons.tpl"
location
=
"bottom"
}
</div>
<div
class=
"crm-submit-buttons"
>
{
include
file
=
"CRM/common/formButtons.tpl"
location
=
"bottom"
}
</div>
{/
crmScope
}
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