Title: Set Authorize/Capture Programatically?
Last modified: September 26, 2019

---

# Set Authorize/Capture Programatically?

 *  Resolved [Joe](https://wordpress.org/support/users/joecole1/)
 * (@joecole1)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/)
 * I am using the latest version, 3.0.6
 * Is there an option available to programatically set the authorize/capture setting?
 * My use case is this:
 * I would like to only authorize a charge if the cart contains a certain product.
   If it does not contain that product, it should capture automatically.
 * I am familiar with woocommerce hooks/functions, just not finding any action or
   filter available in your plugin.
 * Thanks,
    Joe

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

 *  Plugin Author [Clayton R](https://wordpress.org/support/users/mrclayton/)
 * (@mrclayton)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973041)
 * Hi [@joecole1](https://wordpress.org/support/users/joecole1/),
 * Our developer docs display the entire plugin’s code base along with all the hooks
   available in the plugin. Here is a link to the exact filter you can use to change
   the `submitForSettlement` property before the transaction is processed.
 * [https://docs.paymentplugins.com/wc-braintree/api/source-class-WC_Braintree_Payment_Gateway.html#622](https://docs.paymentplugins.com/wc-braintree/api/source-class-WC_Braintree_Payment_Gateway.html#622)
 * Kind Regards
 *  Thread Starter [Joe](https://wordpress.org/support/users/joecole1/)
 * (@joecole1)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973045)
 * I swear I searched for that!
 * Sorry for wasting your time, but thank you for the quick response.
 *  Plugin Author [Clayton R](https://wordpress.org/support/users/mrclayton/)
 * (@mrclayton)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973068)
 * [@joecole1](https://wordpress.org/support/users/joecole1/),
 * No worries. Here is an example of how to pull items from the cart.
 * [https://docs.paymentplugins.com/wc-braintree/config/#/code_examples](https://docs.paymentplugins.com/wc-braintree/config/#/code_examples)
 *  Thread Starter [Joe](https://wordpress.org/support/users/joecole1/)
 * (@joecole1)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973147)
 * Oh I guess I misunderstood the filter. It’s not enough to just add a filter? 
   I already have an action that runs on wp_loaded that runs a bunch of other filters
   if this product is in the cart, so I’d prefer to simply set it there.
 * add_filter( ‘wc_braintree_transaction_submit_for_settlement’, ‘__return_false’);
 * From my quick look at the code, it looks like if get_option is ‘capture’, it’s
   just setting that filter to true. So if I set to false it should authorize?
 * I tested it with PayPal, and it says authorized in the order notes, but it still
   captured the payment in PayPal.
 *  Plugin Author [Clayton R](https://wordpress.org/support/users/mrclayton/)
 * (@mrclayton)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973169)
 * [@joecole1](https://wordpress.org/support/users/joecole1/),
 * What is the status of the transaction in the Braintree control panel?
 * It should be authorized.
 *  Thread Starter [Joe](https://wordpress.org/support/users/joecole1/)
 * (@joecole1)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973172)
 * That’s what was confusing to me.
 * In Woocommerce the order note says: Order authorized in Braintree: Transaction
   ID: ********. Payment method: PayPal – *********@gmail.com
 * In Braintree and in PayPal, the payment is authorized, submitted for settlement,
   and settled all at the same time.
    -  This reply was modified 6 years, 8 months ago by [Joe](https://wordpress.org/support/users/joecole1/).
 *  Plugin Author [Clayton R](https://wordpress.org/support/users/mrclayton/)
 * (@mrclayton)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973189)
 * [@joecole1](https://wordpress.org/support/users/joecole1/),
 * Do the same test but with the credit card gateway. I think there’s one extra 
   field that has to be changed with PayPal.
 * Once you confirm it works with the cc gateway I’ll show you where to change the
   extra paypal attribute.
 * Kind regards,
 *  Thread Starter [Joe](https://wordpress.org/support/users/joecole1/)
 * (@joecole1)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973206)
 * Woocommerce: Order authorized in Braintree: Transaction ID: ********. Payment
   method: American Express ending in ****
 * Braintree Authorized!
 * So yes, it is an issue of CC vs PayPal Gateways.
 * My intent is to use the PayPal gateway because I can have an authorization that
   lasts up to 29 days versus credit cards that are only good for 3 days (Amex) 
   up to 2 weeks (others). So it’d be great to figure this out!
 *  Plugin Author [Clayton R](https://wordpress.org/support/users/mrclayton/)
 * (@mrclayton)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11973691)
 * Hi [@joecole1](https://wordpress.org/support/users/joecole1/),
 * PayPal is a little different than the other gateways and requires that you change
   one extra parameter. Please review the code at the following link:
 * [https://docs.paymentplugins.com/wc-braintree/api/source-class-WC_Braintree_PayPal_Payment_Gateway.html#130](https://docs.paymentplugins.com/wc-braintree/api/source-class-WC_Braintree_PayPal_Payment_Gateway.html#130)
 * You can use filter `wc_braintree_localized_paypal_params` to change `$data['options']['
   intent'] = authorize`.
 * Valid values for intent are:
    `authorize` `capture`
 * Kind regards,
 *  Thread Starter [Joe](https://wordpress.org/support/users/joecole1/)
 * (@joecole1)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11976790)
 * Fixed with this filter, run on wp_loaded
 *     ```
       add_filter( 'wc_braintree_localized_paypal_params', function($data) {
       	$data['options']['intent'] = 'authorize';
       	return $data;
       });
       ```
   

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

The topic ‘Set Authorize/Capture Programatically?’ is closed to new replies.

 * ![](https://ps.w.org/woo-payment-gateway/assets/icon-256x256.png?rev=2142799)
 * [Payment Plugins Braintree For WooCommerce](https://wordpress.org/plugins/woo-payment-gateway/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-payment-gateway/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-payment-gateway/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-payment-gateway/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-payment-gateway/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-payment-gateway/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [Joe](https://wordpress.org/support/users/joecole1/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/set-authorize-capture-programatically/#post-11976790)
 * Status: resolved