Charitable Documentation

Learn how to make the most of Charitable with clear, step-by-step instructions.

Hooks & Filters in Braintree

Please note: This documentation is a work in progress and does not yet cover all filters & action hooks available in Charitable Braintree. If you do not see a hook or filter describing what you need to do, please get in touch via our support page and we can help you.

Filters

charitable_braintree_transaction_data

Added in version 1.0.0

Filter the transaction data passed to Braintree when creating a one-time donation.

Return Value

Array

Arguments

  • $transaction_data (array)

    The transaction data.

  • $processor (Charitable_Braintree_Gateway_Processor)

    The instance of the processor class, Charitable_Braintree_Gateway_Processor.

Usage

add_filter(
    'charitable_braintree_transaction_data',
    function( $transaction_data, $processor ) {
        if ( ! isset( $transaction_data['customFields'] ) ) {
            $transaction_data['customFields'] = array();
        }
        
        $transaction_data['customFields']['myBraintreeCustomField'] = $processor->donation->get( 'my_custom_field' );
        
        return $transaction_data;
    },
    10, 
    2
);

charitable_braintree_customer_data

Added in version 1.0.0

Filter customer data passed to Braintree when creating a new customer in the Vault.

Return Value

Array

Arguments

  • $data (array)

    The customer data.

  • $processor (Charitable_Braintree_Gateway_Processor)

    The instance of the processor class, Charitable_Braintree_Gateway_Processor.

Usage

add_filter(
    'charitable_braintree_customer_data',
    function( $data, $processor ) {
        if ( ! isset( $data['customFields'] ) ) {
            $data['customFields'] = array();
        }
        
        $data['customFields']['myBraintreeCustomField'] = $processor->donation->get( 'my_custom_field' );
        
        return $data;
    },
    10, 
    2
);

Still have questions? We’re here to help!

Last Modified: