public function PayflowLink::canRefundPayment in Commerce PayPal 8
Checks whether the given payment can be refunded.
Parameters
\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment to refund.
Return value
bool TRUE if the payment can be refunded, FALSE otherwise.
Overrides PaymentGatewayBase::canRefundPayment
File
- src/
Plugin/ Commerce/ PaymentGateway/ PayflowLink.php, line 268
Class
- PayflowLink
- Provides the PayPal Payflow Link payment gateway.
Namespace
Drupal\commerce_paypal\Plugin\Commerce\PaymentGatewayCode
public function canRefundPayment(PaymentInterface $payment) {
// Return FALSE if the transaction isn't valid for credit transactions:
// Sale or Delayed Capture.
$valid_types = [
'S',
'D',
'C',
];
if (!in_array($payment
->getRemoteState(), $valid_types)) {
return FALSE;
}
// Return FALSE if the transaction was not a success.
if (!in_array($payment
->getState()
->getId(), [
'completed',
'partially_refunded',
])) {
return FALSE;
}
// Return FALSE if it is more than 60 days since the original transaction.
if ($payment
->getCompletedTime() && $payment
->getCompletedTime() < strtotime('-60 days')) {
return FALSE;
}
return TRUE;
}