mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Get latest payment token for subscription renewal
This commit is contained in:
parent
ea23200de6
commit
bb5a04c4b3
2 changed files with 5 additions and 5 deletions
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue