diff --git a/modules/ppcp-subscription/src/Repository/class-paymenttokenrepository.php b/modules/ppcp-subscription/src/Repository/class-paymenttokenrepository.php index a0419e22f..8d2b47351 100644 --- a/modules/ppcp-subscription/src/Repository/class-paymenttokenrepository.php +++ b/modules/ppcp-subscription/src/Repository/class-paymenttokenrepository.php @@ -79,7 +79,6 @@ class PaymentTokenRepository { * @return PaymentToken[] */ public function all_for_user_id( int $id ) { - $tokens_array = array(); try { $tokens = $this->endpoint->for_user( $id ); update_user_meta( $id, self::USER_META, $tokens ); diff --git a/modules/ppcp-subscription/src/class-renewalhandler.php b/modules/ppcp-subscription/src/class-renewalhandler.php index 4758bcad7..341c11ff0 100644 --- a/modules/ppcp-subscription/src/class-renewalhandler.php +++ b/modules/ppcp-subscription/src/class-renewalhandler.php @@ -176,14 +176,14 @@ class RenewalHandler { */ private function get_token_for_customer( \WC_Customer $customer, \WC_Order $wc_order ) { - $token = $this->repository->for_user_id( (int) $customer->get_id() ); - if ( ! $token ) { + $tokens = $this->repository->all_for_user_id( (int) $customer->get_id() ); + if ( ! $tokens ) { $this->logger->log( 'error', sprintf( // translators: %d is the customer id. __( - 'No payment token found for customer %d', + 'No payment tokens found for customer %d', 'woocommerce-paypal-payments' ), (int) $customer->get_id() @@ -194,7 +194,8 @@ class RenewalHandler { ) ); } - return $token; + + return current( $tokens ); } /**