Merge branch 'PCP-591-save-and-display-vaulted-payment-methods-in-woo-commerce-native-endpoint' into PCP-991-detach-vaulting-from-wc-subscriptions-support

This commit is contained in:
emilicastells 2022-12-20 11:56:20 +01:00
commit 95695dabab
No known key found for this signature in database
GPG key ID: 1520C07081754570
2 changed files with 14 additions and 1 deletions

View file

@ -22,10 +22,20 @@ class PaymentTokenPayPal extends WC_Payment_Token {
*/
protected $type = 'PayPal';
/**
* Get PayPal account email.
*
* @return string PayPal account email.
*/
public function get_email() {
return $this->get_meta( 'email' );
}
/**
* Set PayPal account email.
*
* @param string $email PayPal account email.
*/
public function set_email( $email ) {
$this->add_meta_data( 'email', $email, true );
}

View file

@ -117,7 +117,7 @@ class VaultingModule implements ModuleInterface {
}
assert( $payment_token instanceof PaymentTokenPayPal );
$item['method']['brand'] = $payment_token->get_email() ?? 'PayPal';
$item['method']['brand'] = $payment_token->get_email();
return $item;
},
@ -168,6 +168,8 @@ class VaultingModule implements ModuleInterface {
add_action(
'woocommerce_paypal_payments_gateway_migrate_on_update',
function () use ( $container ) {
// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key
// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_query
$customers = new WP_User_Query(
array(
'fields' => 'ID',
@ -181,6 +183,7 @@ class VaultingModule implements ModuleInterface {
),
)
);
// phpcs:enable
$migrate = $container->get( 'vaulting.payment-tokens-migration' );
assert( $migrate instanceof PaymentTokensMigration );