Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order does not contain intent. (3DS ACDC renewal) (4116) #3098

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions modules/ppcp-wc-subscriptions/src/Helper/SubscriptionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use WC_Subscriptions_Product;
use WCS_Manual_Renewal_Manager;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;

/**
* Class SubscriptionHelper
Expand Down Expand Up @@ -295,18 +293,19 @@ public function previous_transaction( WC_Subscription $subscription ): string {
return '';
}

// Sort orders by key descending.
krsort( $orders );

// Removes first order (the current processing order).
unset( $orders[ array_key_first( $orders ) ] );
// Sort orders by oder ID descending.
rsort( $orders );
$current_order = wc_get_order( array_shift( $orders ) );
if ( ! $current_order instanceof WC_Order ) {
return '';
}

foreach ( $orders as $order_id ) {
$order = wc_get_order( $order_id );
if (
is_a( $order, WC_Order::class )
&& in_array( $order->get_status(), array( 'processing', 'completed' ), true )
&& in_array( $order->get_payment_method(), array( PayPalGateway::ID, CreditCardGateway::ID ), true )
&& $current_order->get_payment_method() === $order->get_payment_method()
) {
$transaction_id = $order->get_transaction_id();
if ( $transaction_id ) {
Expand Down
4 changes: 4 additions & 0 deletions modules/ppcp-wc-subscriptions/src/RenewalHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ private function card_payment_source( string $token, WC_Order $wc_order ): Payme
'usage' => 'SUBSEQUENT',
'previous_transaction_reference' => $transaction,
);
} else {
$this->logger->debug( sprintf( 'Previous transaction not found for subscription %s', $subscription->get_id() ) );
}
} else {
$this->logger->debug( sprintf( 'Subscription not found for renewal order %s', $wc_order->get_id() ) );
}

return new PaymentSource(
Expand Down
Loading