Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter zackmac26

    (@zackmac26)

    For those that are looking for this information, you can use the following code to hook the stripe payment intent to change the description:

    function give_stripe_custom_payment_meta( $charge_args ) {
        $charge_args['description'] = 'Custom Description';
    
        return $charge_args;
    }
    
    add_filter( 'give_stripe_create_intent_args', 'give_stripe_custom_payment_meta', 10 );
    

    You can also combine this with some code to set the description based on on the fund defined:

    function give_stripe_custom_payment_meta( $charge_args ) {
    
        // Sanitize the input posted data to the form.
        $posted_data = give_clean( filter_input_array( INPUT_POST ) );
    
        // Check the selected fund and set the description accordingly
        if( isset( $posted_data['give-selected-fund'] ) ){
            switch( $posted_data['give-selected-fund'] ){
                case 1:
                    $charge_args['description'] = 'Donations - General Fund';
                    break;
                case 2:
                    $charge_args['description'] = 'Donations - Other Fund';
                    break;
                default:
                    $charge_args['description'] = 'Donations - Other Designation'; // default description in case neither 1 nor 2 is selected
            }
        } else {
            $charge_args['description'] = 'Donations - General Fund'; // default description in case 'give-selected-fund' isn't set
        }
    
        return $charge_args;
    }
    add_filter( 'give_stripe_create_intent_args', 'give_stripe_custom_payment_meta', 10 );
    
    Thread Starter zackmac26

    (@zackmac26)

    I just figured it out. The reason I thought the filter was depriciated was because I could not find it in my includes folder. So I knew the filter was never being called… It was totally my bad: I guess we were trying to use the WooCommerce Stripe Gateway, and not the Payment Plugins for Stripe WooCommerce.

    Updated our implementation for the proper plugin and now the correct description is being sent to stripe.

    Thanks so much for the help.

    Thread Starter zackmac26

    (@zackmac26)

    Maybe I am just being dumb… Below is the code I am testing with. I have tried at a priority of 1, 10, 99, even 12345 to try and ensure there is no conflict with anything else. I have disabled all plugins related to WooCommerce with the exception of WooCommerce and Stripe.

    add_filter('wc_stripe_payment_intent_args', function($args, $order){
    	error_log('Filter WC Stripe is executed!');
        $args['description'] = 'My custom description';
        return $args;
    }, 10, 2);

    The description is still “Site Name – Order Number” and I never get anything written to the error log. WP Debug and Debug Log are both on.

    Any thoughts?

Viewing 3 replies - 1 through 3 (of 3 total)