Add liability shift check

This commit is contained in:
Emili Castells Guasch 2025-04-02 18:07:22 +02:00
parent e4252ebbf7
commit e0ca70f7b6
3 changed files with 57 additions and 24 deletions

View file

@ -25,13 +25,23 @@ class CardCaptureValidator {
* @return bool
*/
public function is_valid( Order $order ): bool {
$order_status = $order->status();
if ( $order_status->name() === OrderStatus::APPROVED ) {
return true;
}
$payment_source = $order->payment_source();
if ( $payment_source && $payment_source->name() !== 'card' ) {
return true;
}
$order_status = $order->status();
if ( $order_status->name() === OrderStatus::APPROVED ) {
/**
* The LiabilityShift response determines how you might proceed with authentication.
*
* @link https://developer.paypal.com/docs/checkout/advanced/customize/3d-secure/response-parameters/
*/
$liability_shift = $payment_source->properties()->authentication_result->liability_shift ?? '';
if ( in_array( $liability_shift, array( 'POSSIBLE', 'YES' ), true ) ) {
return true;
}