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
0f103473
Commit
0f103473
authored
5 years ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Add basic support for PaymentProcessor.refund API
parent
a0cab58e
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/Stripe.php
+41
-0
41 additions, 0 deletions
CRM/Core/Payment/Stripe.php
with
41 additions
and
0 deletions
CRM/Core/Payment/Stripe.php
+
41
−
0
View file @
0f103473
...
...
@@ -141,6 +141,15 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return
FALSE
;
}
/**
* Does this payment processor support refund?
*
* @return bool
*/
public
function
supportsRefund
()
{
return
TRUE
;
}
/**
* We can configure a start date for a smartdebit mandate
* @return bool
...
...
@@ -558,6 +567,38 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return
$params
;
}
/**
* Submit a refund payment
*
* @param array $params
* Assoc array of input parameters for this transaction.
*
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public
function
doRefund
(
&
$params
)
{
$requiredParams
=
[
'charge_id'
,
'payment_processor_id'
];
foreach
(
$requiredParams
as
$required
)
{
if
(
!
isset
(
$params
[
$required
]))
{
$message
=
'Stripe doRefund: Missing mandatory parameter: '
.
$required
;
Civi
::
log
()
->
error
(
$message
);
Throw
new
\Civi\Payment\Exception\PaymentProcessorException
(
$message
);
}
}
$refundParams
=
[
'charge'
=>
$params
[
'charge_id'
],
];
if
(
!
empty
(
$params
[
'amount'
]))
{
$refundParams
[
'amount'
]
=
$this
->
getAmount
(
$params
);
}
try
{
$refund
=
\Stripe\Refund
::
create
(
$refundParams
);
}
catch
(
Exception
$e
)
{
$this
->
handleError
(
$e
->
getCode
(),
$e
->
getMessage
());
Throw
new
\Civi\Payment\Exception\PaymentProcessorException
(
$e
->
getMessage
());
}
}
/**
* Calculate the end_date for a recurring contribution based on the number of installments
* @param $params
...
...
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