mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
Refactor payment source to handle arbitrary types
This commit is contained in:
parent
99d05ca44d
commit
518a1f4e4e
13 changed files with 59 additions and 287 deletions
|
@ -144,10 +144,10 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|||
|
||||
$order = $this->api_endpoint->order( $data['order_id'] );
|
||||
|
||||
if ( $order->payment_source() && $order->payment_source()->card() ) {
|
||||
if ( $order->payment_source() && $order->payment_source()->name() === 'card' ) {
|
||||
if ( $this->settings->has( 'disable_cards' ) ) {
|
||||
$disabled_cards = (array) $this->settings->get( 'disable_cards' );
|
||||
$card = strtolower( $order->payment_source()->card()->brand() );
|
||||
$card = strtolower( $order->payment_source()->properties()->brand ?? '' );
|
||||
if ( 'master_card' === $card ) {
|
||||
$card = 'mastercard';
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ trait ContextTrait {
|
|||
}
|
||||
|
||||
$source = $order->payment_source();
|
||||
if ( $source && $source->card() ) {
|
||||
if ( $source && $source->name() === 'card' ) {
|
||||
return false; // Ignore for DCC.
|
||||
}
|
||||
|
||||
|
|
|
@ -52,14 +52,14 @@ class ThreeDSecure {
|
|||
if ( ! $order->payment_source() ) {
|
||||
return self::NO_DECISION;
|
||||
}
|
||||
if ( ! $order->payment_source()->card() ) {
|
||||
if ( ! $order->payment_source()->properties()->brand ?? '' ) {
|
||||
return self::NO_DECISION;
|
||||
}
|
||||
if ( ! $order->payment_source()->card()->authentication_result() ) {
|
||||
if ( ! $order->payment_source()->properties()->authentication_result ?? '' ) {
|
||||
return self::NO_DECISION;
|
||||
}
|
||||
|
||||
$result = $order->payment_source()->card()->authentication_result();
|
||||
$result = $order->payment_source()->properties()->authentication_result;
|
||||
$this->logger->info( '3DS authentication result: ' . wc_print_r( $result->to_array(), true ) );
|
||||
|
||||
if ( $result->liability_shift() === AuthResult::LIABILITY_SHIFT_POSSIBLE ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue