Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
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
Stripe
Commits
7792120c
Commit
7792120c
authored
2 years ago
by
mattwire
Committed by
mattwire
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Stripe does not refund fees
parent
f8ae05a2
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!188
Refund fixes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Payment/Stripe.php
+3
-3
3 additions, 3 deletions
CRM/Core/Payment/Stripe.php
CRM/Core/Payment/StripeIPN.php
+12
-11
12 additions, 11 deletions
CRM/Core/Payment/StripeIPN.php
with
15 additions
and
14 deletions
CRM/Core/Payment/Stripe.php
+
3
−
3
View file @
7792120c
...
...
@@ -928,7 +928,8 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$refundParams
[
'amount'
]
=
$this
->
getAmount
(
$params
);
try
{
$refund
=
$this
->
stripeClient
->
refunds
->
create
(
$refundParams
);
$fee
=
$this
->
getFeeFromBalanceTransaction
(
$refund
[
'balance_transaction'
],
$refund
[
'currency'
]);
// Stripe does not refund fees - see https://support.stripe.com/questions/understanding-fees-for-refunded-payments
// $fee = $this->getFeeFromBalanceTransaction($refund['balance_transaction'], $refund['currency']);
}
catch
(
Exception
$e
)
{
$this
->
handleError
(
$e
->
getCode
(),
$e
->
getMessage
());
...
...
@@ -960,8 +961,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'refund_trxn_id'
=>
$refund
->
id
,
'refund_status_id'
=>
$refundStatus
,
'refund_status'
=>
$refundStatusName
,
'processor_result'
=>
$refund
->
jsonSerialize
(),
'fee_amount'
=>
$fee
??
NULL
,
'fee_amount'
=>
0
,
];
return
$refundParams
;
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Core/Payment/StripeIPN.php
+
12
−
11
View file @
7792120c
...
...
@@ -602,7 +602,7 @@ class CRM_Core_Payment_StripeIPN {
}
/**
* Process the
received event in CiviCRM
* Process the
charge.refunded event from Stripe
*
* @return bool
* @throws \CRM_Core_Exception
...
...
@@ -614,15 +614,21 @@ class CRM_Core_Payment_StripeIPN {
// Cancelling an uncaptured paymentIntent triggers charge.refunded but we don't want to process that
if
(
empty
(
CRM_Stripe_Api
::
getObjectParam
(
'captured'
,
$this
->
getData
()
->
object
)))
{
return
TRUE
;
};
// This charge was actually captured, so record the refund in CiviCRM
if
(
!
$this
->
setInfo
())
{
return
TRUE
;
}
// This gives us the refund date + reason code
$refunds
=
$this
->
_paymentProcessor
->
stripeClient
->
refunds
->
all
([
'charge'
=>
$this
->
charge_id
,
'limit'
=>
1
]);
$refund
=
$refunds
->
data
[
0
];
// Stripe does not refund fees - see https://support.stripe.com/questions/understanding-fees-for-refunded-payments
// This gets the fee refunded
// $this->fee = $this->getPaymentProcessor()->getFeeFromBalanceTransaction($refund->balance_transaction, $this->retrieve('currency', 'String', FALSE));
// This gives us the actual amount refunded
$amountRefunded
=
CRM_Stripe_Api
::
getObjectParam
(
'amount_refunded'
,
$this
->
getData
()
->
object
);
// Get the CiviCRM contribution that matches the Stripe metadata we have from the event
$this
->
getContribution
();
if
(
isset
(
$this
->
contribution
[
'payments'
]))
{
foreach
(
$this
->
contribution
[
'payments'
]
as
$payment
)
{
if
(
$payment
[
'trxn_id'
]
===
$refund
->
id
)
{
...
...
@@ -635,17 +641,12 @@ class CRM_Core_Payment_StripeIPN {
}
}
// This gets the fee refunded
$this
->
fee
=
$this
->
getPaymentProcessor
()
->
getFeeFromBalanceTransaction
(
$refund
->
balance_transaction
,
$this
->
retrieve
(
'currency'
,
'String'
,
FALSE
));
// This gives us the actual amount refunded
$amountRefunded
=
CRM_Stripe_Api
::
getObjectParam
(
'amount_refunded'
,
$this
->
getData
()
->
object
);
$refundParams
=
[
'contribution_id'
=>
$this
->
contribution
[
'id'
],
'total_amount'
=>
0
-
abs
(
$amountRefunded
),
'trxn_date'
=>
date
(
'YmdHis'
,
$refund
->
created
),
'trxn_result_code'
=>
$refund
->
reason
,
'fee_amount'
=>
0
-
abs
(
$this
->
fee
)
,
'fee_amount'
=>
0
,
'trxn_id'
=>
$refund
->
id
,
'order_reference'
=>
$this
->
invoice_id
??
NULL
,
];
...
...
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