Title: Void missing in process_refund
Last modified: November 28, 2018

---

# Void missing in process_refund

 *  Resolved [creativeround](https://wordpress.org/support/users/creativeround/)
 * (@creativeround)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/void-missing-in-process_refund/)
 * Void for authorization only transactions is missing in the process_refund function.
 * The code below fixes allows for the admin to refund a non-captured transaction
   by doing a void instead of refund in the process_refund.
 * Add this code on line 371 of /includes/abstract/abstract-wc-gateway-ppec.php:
 *     ```
       // Process a void instead of refund if transaction is authorized only
   
       $trans_id = get_post_meta( $order_id, '_transaction_id', true );
       $trans_details = wc_gateway_ppec()->client->get_transaction_details( array( 'TRANSACTIONID' => $trans_id ) );
   
       if ( $trans_id && wc_gateway_ppec()->admin->is_authorized_only( $trans_details ) ) {
   
       	$params['AUTHORIZATIONID'] = $trans_id;
   
       	$result = wc_gateway_ppec()->client->do_express_checkout_void( $params );
   
       	if ( is_wp_error( $result ) ) {
       		$order->add_order_note( __( 'Unable to void charge!', 'woocommerce-gateway-paypal-express-checkout' ) . ' ' . $result->get_error_message() );
       		return new WP_Error( 'paypal_refund_error', "This order cannot be voided, please process this order manually via PayPal." );
       	} else {
       		$order->add_order_note( sprintf( __( 'PayPal Checkout charge voided (Charge ID: %s)', 'woocommerce-gateway-paypal-express-checkout' ), $trans_id ) );
       		return true;
       	}
       }
       ```
   
    -  This topic was modified 7 years, 6 months ago by [creativeround](https://wordpress.org/support/users/creativeround/).
    -  This topic was modified 7 years, 6 months ago by [creativeround](https://wordpress.org/support/users/creativeround/).

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * (@fernashes)
 * Automattic Happiness Engineer
 * [7 years, 6 months ago](https://wordpress.org/support/topic/void-missing-in-process_refund/#post-10933937)
 * Hey there,
 * Thanks so much for the code!
 * Can you please go ahead and do a pull request for this on the plugin’s repo, 
   or add it as an issue?
    [https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout](https://github.com/woocommerce/woocommerce-gateway-paypal-express-checkout)

Viewing 1 replies (of 1 total)

The topic ‘Void missing in process_refund’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/woocommerce-gateway-paypal-express-
   checkout_b298d1.svg)
 * [WooCommerce PayPal Checkout Payment Gateway](https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-gateway-paypal-express-checkout/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-gateway-paypal-express-checkout/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-gateway-paypal-express-checkout/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-gateway-paypal-express-checkout/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/void-missing-in-process_refund/#post-10933937)
 * Status: resolved