wpcf7_stripe_skip_spam_check()CF7 1.0

Skips the spam check if it is not necessary.

Хуков нет.

Возвращает

true|false. True if the spam check is not necessary.

Использование

wpcf7_stripe_skip_spam_check( $skip_spam_check, $submission );
$skip_spam_check(обязательный)
.
$submission(обязательный)
.

Код wpcf7_stripe_skip_spam_check() CF7 6.1.3

function wpcf7_stripe_skip_spam_check( $skip_spam_check, $submission ) {
	$service = WPCF7_Stripe::get_instance();

	if ( ! $service->is_active() ) {
		return $skip_spam_check;
	}

	$pi_id = (string) wpcf7_superglobal_post( '_wpcf7_stripe_payment_intent' );

	if ( $pi_id ) {
		$payment_intent = $service->api()->retrieve_payment_intent( $pi_id );

		if (
			isset( $payment_intent['metadata']['wpcf7_submission_timestamp'] )
		) {
			// This PI has already been used. Ignore.
			return $skip_spam_check;
		}

		if (
			isset( $payment_intent['status'] ) and
			'succeeded' === $payment_intent['status']
		) {
			$submission->push( 'payment_intent', $pi_id );

			$service->api()->update_payment_intent( $pi_id, array(
				'metadata' => array_merge( $payment_intent['metadata'], array(
					'wpcf7_submission_timestamp' => $submission->get_meta( 'timestamp' ),
				) ),
			) );
		}
	}

	if (
		! empty( $submission->pull( 'payment_intent' ) ) and
		$submission->verify_posted_data_hash()
	) {
		$skip_spam_check = true;
	}

	return $skip_spam_check;
}