mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Do not return stored tokens in meta but call the endpoint each time
This commit is contained in:
parent
179b1b2b81
commit
5afbfb0e3b
4 changed files with 3911 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,5 +5,6 @@ node_modules
|
||||||
composer.lock
|
composer.lock
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
modules/ppcp-button/assets/*
|
modules/ppcp-button/assets/*
|
||||||
|
modules/ppcp-wc-gateway/assets/*
|
||||||
.idea/
|
.idea/
|
||||||
*.zip
|
*.zip
|
||||||
|
|
|
@ -223,9 +223,8 @@ class SmartButton implements SmartButtonInterface {
|
||||||
|
|
||||||
$tokens = $payment_token_repository->all_for_user_id( 1 );
|
$tokens = $payment_token_repository->all_for_user_id( 1 );
|
||||||
if ( $tokens && $this->tokens_contains_card( $tokens ) ) {
|
if ( $tokens && $this->tokens_contains_card( $tokens ) ) {
|
||||||
|
|
||||||
$output = sprintf(
|
$output = sprintf(
|
||||||
'<select id="saved-credit-card" name="saved_credit_card"><option value="">%s</option>',
|
'<p class="form-row form-row-wide"><label>Or select a saved Credit Card payment</label><select id="saved-credit-card" name="saved_credit_card"><option value="">%s</option>',
|
||||||
esc_html__( 'Choose a saved payment', 'woocommerce-paypal-payments' )
|
esc_html__( 'Choose a saved payment', 'woocommerce-paypal-payments' )
|
||||||
);
|
);
|
||||||
foreach ( $tokens as $token ) {
|
foreach ( $tokens as $token ) {
|
||||||
|
@ -238,7 +237,7 @@ class SmartButton implements SmartButtonInterface {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output .= '</select>';
|
$output .= '</select></p>';
|
||||||
|
|
||||||
$default_fields['saved-credit-card'] = $output;
|
$default_fields['saved-credit-card'] = $output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,11 +79,6 @@ class PaymentTokenRepository {
|
||||||
* @return PaymentToken[]
|
* @return PaymentToken[]
|
||||||
*/
|
*/
|
||||||
public function all_for_user_id( int $id ) {
|
public function all_for_user_id( int $id ) {
|
||||||
$tokens = get_user_meta( $id, self::USER_META, true );
|
|
||||||
if ( $tokens ) {
|
|
||||||
return (array) $tokens;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tokens_array = array();
|
$tokens_array = array();
|
||||||
try {
|
try {
|
||||||
$tokens = $this->endpoint->for_user( $id );
|
$tokens = $this->endpoint->for_user( $id );
|
||||||
|
|
3908
modules/ppcp-wc-gateway/yarn.lock
Normal file
3908
modules/ppcp-wc-gateway/yarn.lock
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue