Fix token check on listener

This commit is contained in:
dinamiko 2022-10-19 11:50:15 +02:00
parent 68cf4ecda3
commit a77078a372
2 changed files with 6 additions and 6 deletions

View file

@ -216,7 +216,7 @@ class SubscriptionModule implements ModuleInterface {
&& PayPalGateway::ID === $id
&& $subscription_helper->is_subscription_change_payment()
) {
$tokens = $payment_token_repository->all_for_user_id( get_current_user_id() );
$tokens = $payment_token_repository->all_for_user_id( get_current_user_id() );
if ( ! $tokens || ! $payment_token_repository->tokens_contains_paypal( $tokens ) ) {
return esc_html__(
'No PayPal payments saved, in order to use a saved payment you first need to create it through a purchase.',
@ -224,10 +224,10 @@ class SubscriptionModule implements ModuleInterface {
);
}
$output = sprintf(
'<p class="form-row form-row-wide"><label>%1$s</label><select id="saved-paypal-payment" name="saved_paypal_payment">',
esc_html__( 'Select a saved PayPal payment', 'woocommerce-paypal-payments' )
);
$output = sprintf(
'<p class="form-row form-row-wide"><label>%1$s</label><select id="saved-paypal-payment" name="saved_paypal_payment">',
esc_html__( 'Select a saved PayPal payment', 'woocommerce-paypal-payments' )
);
foreach ( $tokens as $token ) {
if ( isset( $token->source()->paypal ) ) {
$output .= sprintf(

View file

@ -54,7 +54,7 @@ class CustomerApprovalListener {
*/
public function listen(): void {
$token = wc_clean( wp_unslash( $_GET['approval_token_id'] ?? '' ) );
if ( ! is_string( $token ) ) {
if ( ! $token ) {
return;
}