wpcf7_stripe_before_send_mail()
Creates Stripe's Payment Intent.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
wpcf7_stripe_before_send_mail( $contact_form, $abort, $submission );
- $contact_form (обязательный)
- -
- $abort (обязательный) (передается по ссылке — &)
- -
- $submission (обязательный)
- -
Код wpcf7_stripe_before_send_mail() wpcf7 stripe before send mail CF7 5.9.8
function wpcf7_stripe_before_send_mail( $contact_form, &$abort, $submission ) { $service = WPCF7_Stripe::get_instance(); if ( ! $service->is_active() ) { return; } $tags = $contact_form->scan_form_tags( array( 'type' => 'stripe' ) ); if ( ! $tags ) { return; } if ( ! empty( $submission->pull( 'payment_intent' ) ) ) { return; } $tag = $tags[0]; $amount = $tag->get_option( 'amount', 'int', true ); $currency = $tag->get_option( 'currency', '[a-zA-Z]{3}', true ); $payment_intent_params = apply_filters( 'wpcf7_stripe_payment_intent_parameters', array( 'amount' => $amount ? absint( $amount ) : null, 'currency' => $currency ? strtolower( $currency ) : null, 'receipt_email' => $submission->get_posted_data( 'your-email' ), ) ); $payment_intent = $service->api()->create_payment_intent( $payment_intent_params ); if ( $payment_intent ) { $submission->add_result_props( array( 'stripe' => array( 'payment_intent' => array( 'id' => $payment_intent['id'], 'client_secret' => $payment_intent['client_secret'], ), ), ) ); $submission->set_status( 'payment_required' ); $submission->set_response( __( "Payment is required. Please pay by credit card.", 'contact-form-7' ) ); } $abort = true; }