'preapproval-charged' ), admin_url( 'edit.php?post_type=download&page=edd-payment-history' ) ) ) ); exit; } else { wp_redirect( esc_url_raw( add_query_arg( array( 'edd-message' => 'preapproval-failed' ), admin_url( 'edit.php?post_type=download&page=edd-payment-history' ) ) ) ); exit; } } add_action( 'edd_charge_stripe_preapproval', 'edds_process_preapproved_charge' ); /** * Cancel a preapproved payment * * @since 1.6 * @return void */ function edds_process_preapproved_cancel() { global $edd_options; if( empty( $_GET['nonce'] ) ) return; if( ! wp_verify_nonce( $_GET['nonce'], 'edds-process-preapproval' ) ) return; $payment_id = absint( $_GET['payment_id'] ); if ( empty( $payment_id ) ) { return; } $payment = edd_get_payment( $payment_id ); $customer_id = $payment->get_meta( '_edds_stripe_customer_id', true ); $status = $payment->status; if ( empty( $customer_id ) ) { return; } if ( 'preapproval' !== $status ) { return; } edd_insert_payment_note( $payment_id, __( 'Preapproval cancelled', 'easy-digital-downloads' ) ); edd_update_payment_status( $payment_id, 'cancelled' ); $payment->delete_meta( '_edds_stripe_customer_id' ); wp_redirect( esc_url_raw( add_query_arg( array( 'edd-message' => 'preapproval-cancelled' ), admin_url( 'edit.php?post_type=download&page=edd-payment-history' ) ) ) ); exit; } add_action( 'edd_cancel_stripe_preapproval', 'edds_process_preapproved_cancel' ); /** * Adds a JS confirmation to check whether a preapproved payment should really be cancelled. * * @since 2.8.10 * @return void */ add_action( 'admin_print_footer_scripts-download_page_edd-payment-history', function () { ?>

' . sprintf( __( 'There was an error connecting your Stripe account. Message: %1$s. Please try again.', 'easy-digital-downloads' ), esc_html( urldecode( $_GET['edd-message'] ) ), esc_url( admin_url( 'edit.php?post_type=download&page=edd-settings&tab=gateways§ion=edd-stripe' ) ) ) . '

'; add_filter( 'wp_parse_str', function( $ar ) { if( isset( $ar['edd_gateway_connect_error'] ) ) { unset( $ar['edd_gateway_connect_error'] ); } if( isset( $ar['edd-message'] ) ) { unset( $ar['edd-message'] ); } return $ar; }); } settings_errors( 'edds-notices' ); } add_action( 'admin_notices', 'edds_admin_messages' ); /** * Add payment meta item to payments that used an existing card * * @since 2.6 * @param $payment_id * @return void */ function edds_show_existing_card_meta( $payment_id ) { $payment = new EDD_Payment( $payment_id ); $existing_card = $payment->get_meta( '_edds_used_existing_card' ); if ( ! empty( $existing_card ) ) { ?>

 

'connect-to-stripe', ), $location ); } return $location; } ); } add_action( 'admin_init', 'edds_stripe_connect_test_mode_toggle_redirect' ); /** * Adds a "Refund Charge in Stripe" checkbox to the refund UI. * * @param \EDD\Orders\Order $order * * @since 2.8.7 */ function edds_show_refund_checkbox( \EDD\Orders\Order $order ) { if ( 'stripe' !== $order->gateway ) { return; } ?>
'edd-settings', 'tab' => 'gateways', 'section' => 'edd-stripe', ) ) ); exit; } add_action( 'admin_init', 'edds_process_settings_flags', 1 );