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
d888076d
Commit
d888076d
authored
Oct 10, 2019
by
mattwire
Browse files
Improve support for refunds per work in CiviCRM core #15476-15479
parent
046b430b
Changes
1
Hide whitespace changes
Inline
Side-by-side
CRM/Core/Payment/Stripe.php
View file @
d888076d
...
...
@@ -606,10 +606,11 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @param array $params
* Assoc array of input parameters for this transaction.
*
* @return array
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public
function
doRefund
(
&
$params
)
{
$requiredParams
=
[
'
charge
_id'
,
'
payment_processor_id
'
];
public
function
doRefund
(
$params
)
{
$requiredParams
=
[
'
trxn
_id'
,
'
amount
'
];
foreach
(
$requiredParams
as
$required
)
{
if
(
!
isset
(
$params
[
$required
]))
{
$message
=
'Stripe doRefund: Missing mandatory parameter: '
.
$required
;
...
...
@@ -618,11 +619,9 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
}
$refundParams
=
[
'charge'
=>
$params
[
'
charge
_id'
],
'charge'
=>
$params
[
'
trxn
_id'
],
];
if
(
!
empty
(
$params
[
'amount'
]))
{
$refundParams
[
'amount'
]
=
$this
->
getAmount
(
$params
);
}
$refundParams
[
'amount'
]
=
$this
->
getAmount
(
$params
);
try
{
$refund
=
\
Stripe\Refund
::
create
(
$refundParams
);
}
...
...
@@ -630,6 +629,31 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$this
->
handleError
(
$e
->
getCode
(),
$e
->
getMessage
());
Throw
new
\
Civi\Payment\Exception\PaymentProcessorException
(
$e
->
getMessage
());
}
switch
(
$refund
->
status
)
{
case
'pending'
:
$refundStatus
=
CRM_Core_PseudoConstant
::
getKey
(
'CRM_Contribute_BAO_Contribution'
,
'contribution_status_id'
,
'Pending'
);
break
;
case
'succeeded'
:
$refundStatus
=
CRM_Core_PseudoConstant
::
getKey
(
'CRM_Contribute_BAO_Contribution'
,
'contribution_status_id'
,
'Completed'
);
break
;
case
'failed'
:
$refundStatus
=
CRM_Core_PseudoConstant
::
getKey
(
'CRM_Contribute_BAO_Contribution'
,
'contribution_status_id'
,
'Failed'
);
break
;
case
'canceled'
:
$refundStatus
=
CRM_Core_PseudoConstant
::
getKey
(
'CRM_Contribute_BAO_Contribution'
,
'contribution_status_id'
,
'Cancelled'
);
break
;
}
$refundParams
=
[
'refund_trxn_id'
=>
$refund
->
id
,
'refund_status_id'
=>
$refundStatus
,
'processor_result'
=>
$refund
->
jsonSerialize
(),
];
return
$refundParams
;
}
/**
...
...
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