mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Disable phpcs when nonce check not needed
This commit is contained in:
parent
a77078a372
commit
4e248a815e
10 changed files with 19 additions and 14 deletions
|
@ -87,8 +87,10 @@ class SettingsPageAssets {
|
|||
return false;
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
$tab = wc_clean( wp_unslash( $_GET['tab'] ?? '' ) );
|
||||
$section = wc_clean( wp_unslash( $_GET['section'] ?? '' ) );
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
return 'checkout' === $tab && 'ppcp-gateway' === $section;
|
||||
}
|
||||
|
|
|
@ -275,6 +275,7 @@ class CardButtonGateway extends \WC_Payment_Gateway {
|
|||
* If customer has chosen change Subscription payment.
|
||||
*/
|
||||
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$saved_paypal_payment = wc_clean( wp_unslash( $_POST['saved_paypal_payment'] ?? '' ) );
|
||||
if ( $saved_paypal_payment ) {
|
||||
update_post_meta( $order_id, 'payment_token_id', $saved_paypal_payment );
|
||||
|
|
|
@ -360,6 +360,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|||
/**
|
||||
* If customer has chosen a saved credit card payment.
|
||||
*/
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$saved_credit_card = wc_clean( wp_unslash( $_POST['saved_credit_card'] ?? '' ) );
|
||||
if ( $saved_credit_card ) {
|
||||
try {
|
||||
|
|
|
@ -138,6 +138,7 @@ class OXXO {
|
|||
'add_meta_boxes',
|
||||
function( string $post_type ) {
|
||||
if ( $post_type === 'shop_order' ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$post_id = wc_clean( wp_unslash( $_GET['post'] ?? '' ) );
|
||||
$order = wc_get_order( $post_id );
|
||||
if ( is_a( $order, WC_Order::class ) && $order->get_payment_method() === OXXOGateway::ID ) {
|
||||
|
@ -182,6 +183,7 @@ class OXXO {
|
|||
return false;
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$billing_country = wc_clean( wp_unslash( $_POST['country'] ?? '' ) );
|
||||
if ( $billing_country && 'MX' !== $billing_country ) {
|
||||
return false;
|
||||
|
|
|
@ -400,8 +400,8 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
);
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$funding_source = wc_clean( wp_unslash( $_POST['ppcp-funding-source'] ?? '' ) );
|
||||
|
||||
if ( 'card' !== $funding_source && $this->is_free_trial_order( $wc_order ) ) {
|
||||
$user_id = (int) $wc_order->get_customer_id();
|
||||
$tokens = $this->payment_token_repository->all_for_user_id( $user_id );
|
||||
|
@ -423,6 +423,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
* If customer has chosen change Subscription payment.
|
||||
*/
|
||||
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$saved_paypal_payment = wc_clean( wp_unslash( $_POST['saved_paypal_payment'] ?? '' ) );
|
||||
if ( $saved_paypal_payment ) {
|
||||
update_post_meta( $order_id, 'payment_token_id', $saved_paypal_payment );
|
||||
|
|
|
@ -409,6 +409,7 @@ class PayUponInvoice {
|
|||
add_action(
|
||||
'woocommerce_after_checkout_validation',
|
||||
function( array $fields, WP_Error $errors ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$payment_method = wc_clean( wp_unslash( $_POST['payment_method'] ?? '' ) );
|
||||
if ( PayUponInvoiceGateway::ID !== $payment_method ) {
|
||||
return;
|
||||
|
@ -418,6 +419,7 @@ class PayUponInvoice {
|
|||
$errors->add( 'validation', __( 'Billing country not available.', 'woocommerce-paypal-payments' ) );
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$birth_date = wc_clean( wp_unslash( $_POST['billing_birth_date'] ?? '' ) );
|
||||
if ( ( $birth_date && ! $this->checkout_helper->validate_birth_date( $birth_date ) ) || $birth_date === '' ) {
|
||||
$errors->add( 'validation', __( 'Invalid birth date.', 'woocommerce-paypal-payments' ) );
|
||||
|
@ -484,18 +486,9 @@ class PayUponInvoice {
|
|||
add_action(
|
||||
'woocommerce_update_options_checkout_ppcp-pay-upon-invoice-gateway',
|
||||
function () {
|
||||
$customer_service_instructions = wc_clean( wp_unslash( $_POST['woocommerce_ppcp-pay-upon-invoice-gateway_customer_service_instructions'] ?? '' ) );
|
||||
if ( '' === $customer_service_instructions ) {
|
||||
$gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' );
|
||||
$gateway_enabled = $gateway_settings['enabled'] ?? '';
|
||||
if ( 'yes' === $gateway_enabled ) {
|
||||
$gateway_settings['enabled'] = 'no';
|
||||
update_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings', $gateway_settings );
|
||||
|
||||
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-pay-upon-invoice-gateway' );
|
||||
wp_safe_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
$gateway = WC()->payment_gateways()->payment_gateways()[ PayUponInvoiceGateway::ID ];
|
||||
if ( $gateway && $gateway->get_option( 'customer_service_instructions' ) === '' ) {
|
||||
$gateway->update_option( 'enabled', 'no' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -537,6 +530,7 @@ class PayUponInvoice {
|
|||
'add_meta_boxes',
|
||||
function( string $post_type ) {
|
||||
if ( $post_type === 'shop_order' ) {
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$post_id = wc_clean( wp_unslash( $_GET['post'] ?? 0 ) );
|
||||
$order = wc_get_order( $post_id );
|
||||
if ( is_a( $order, WC_Order::class ) && $order->get_payment_method() === PayUponInvoiceGateway::ID ) {
|
||||
|
|
|
@ -203,8 +203,8 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
|
|||
*/
|
||||
public function process_payment( $order_id ) {
|
||||
$wc_order = wc_get_order( $order_id );
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
$birth_date = wc_clean( wp_unslash( $_POST['billing_birth_date'] ?? '' ) );
|
||||
|
||||
$pay_for_order = wc_clean( wp_unslash( $_GET['pay_for_order'] ?? '' ) );
|
||||
if ( 'true' === $pay_for_order ) {
|
||||
if ( ! $this->checkout_helper->validate_birth_date( $birth_date ) ) {
|
||||
|
@ -216,6 +216,7 @@ class PayUponInvoiceGateway extends WC_Payment_Gateway {
|
|||
}
|
||||
|
||||
$phone_number = wc_clean( wp_unslash( $_POST['billing_phone'] ?? '' ) );
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
if ( $phone_number ) {
|
||||
$wc_order->set_billing_phone( $phone_number );
|
||||
$wc_order->save();
|
||||
|
|
|
@ -54,6 +54,7 @@ class PayUponInvoiceHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$billing_country = wc_clean( wp_unslash( $_POST['country'] ?? '' ) );
|
||||
if ( $billing_country && 'DE' !== $billing_country ) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue