• Resolved zackmac26

    (@zackmac26)


    We are considering GiveWP for our donations for a startup nonprofit.

    I need to know if there is a filter for the stripe payment gateway that would allow us to customize the description sent to stripe.

    By default, the plugin is sending “Donation Form Name – Donor (donor email)” for our accounting platform, I need the plugin to pass just the fund or designation name.

    Thanks.

Viewing 1 replies (of 1 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 );
    
Viewing 1 replies (of 1 total)

The topic ‘Stripe Description – Custom’ is closed to new replies.