public function PayflowLink::canVoidPayment in Commerce PayPal 8
Checks whether the given payment can be voided.
Parameters
\Drupal\commerce_payment\Entity\PaymentInterface $payment: The payment to void.
Return value
bool TRUE if the payment can be voided, FALSE otherwise.
Overrides PaymentGatewayBase::canVoidPayment
1 call to PayflowLink::canVoidPayment()
- PayflowLink::canCapturePayment in src/
Plugin/ Commerce/ PaymentGateway/ PayflowLink.php - Checks whether the given payment can be captured.
File
- src/
Plugin/ Commerce/ PaymentGateway/ PayflowLink.php, line 332
Class
- PayflowLink
- Provides the PayPal Payflow Link payment gateway.
Namespace
Drupal\commerce_paypal\Plugin\Commerce\PaymentGatewayCode
public function canVoidPayment(PaymentInterface $payment) {
$valid_types = [
'A',
'Pending',
];
// Return FALSE if payment isn't awaiting capture.
if (!in_array($payment
->getRemoteState(), $valid_types)) {
return FALSE;
}
// Return FALSE if the payment is not pending.
if ($payment
->getState()
->getId() !== 'pending') {
return FALSE;
}
// Return FALSE if it is more than 29 days past the original authorization.
if ($payment
->getCompletedTime() && $payment
->getCompletedTime() < strtotime('-29 days')) {
return FALSE;
}
return TRUE;
}