@@ -582,11 +582,12 @@ public function process_response( $response, $order ) {
582582 */
583583 do_action ( 'wc_gateway_stripe_process_payment_charge ' , $ response , $ order );
584584
585- $ order_id = $ order ->get_id ();
586- $ captured = ( isset ( $ response ->captured ) && $ response ->captured ) ? 'yes ' : 'no ' ;
585+ $ order_id = $ order ->get_id ();
586+ $ order_helper = WC_Stripe_Order_Helper::get_instance ();
587+ $ captured = isset ( $ response ->captured ) && $ response ->captured ;
587588
588589 // Store charge data.
589- $ order -> update_meta_data ( ' _stripe_charge_captured ' , $ captured );
590+ $ order_helper -> set_stripe_charge_captured ( $ order , $ captured );
590591
591592 if ( isset ( $ response ->balance_transaction ) ) {
592593 $ this ->update_fees ( $ order , is_string ( $ response ->balance_transaction ) ? $ response ->balance_transaction : $ response ->balance_transaction ->id );
@@ -596,16 +597,16 @@ public function process_response( $response, $order ) {
596597 // The mandate ID is not available for the intent object, so we need to fetch the charge.
597598 // Mandate ID is necessary for renewal payments for certain payment methods and Indian cards.
598599 if ( isset ( $ response ->payment_method_details ->card ->mandate ) ) {
599- $ order -> update_meta_data ( ' _stripe_mandate_id ' , $ response ->payment_method_details ->card ->mandate );
600+ $ order_helper -> update_stripe_mandate_id ( $ order , $ response ->payment_method_details ->card ->mandate );
600601 } elseif ( isset ( $ response ->payment_method_details ->acss_debit ->mandate ) ) {
601- $ order -> update_meta_data ( ' _stripe_mandate_id ' , $ response ->payment_method_details ->acss_debit ->mandate );
602+ $ order_helper -> update_stripe_mandate_id ( $ order , $ response ->payment_method_details ->acss_debit ->mandate );
602603 }
603604
604605 if ( isset ( $ response ->payment_method , $ response ->payment_method_details ) ) {
605606 WC_Stripe_Payment_Tokens::update_token_from_method_details ( $ order ->get_customer_id (), $ response ->payment_method , $ response ->payment_method_details );
606607 }
607608
608- if ( ' yes ' === $ captured ) {
609+ if ( $ captured ) {
609610 /**
610611 * Charge can be captured but in a pending state. Payment methods
611612 * that are asynchronous may take couple days to clear. Webhook will
@@ -1179,8 +1180,9 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
11791180
11801181 $ request = [];
11811182
1183+ $ order_helper = WC_Stripe_Order_Helper::get_instance ();
11821184 $ order_currency = $ order ->get_currency ();
1183- $ captured = $ order -> get_meta ( ' _stripe_charge_captured ' , true );
1185+ $ captured = $ order_helper -> is_stripe_charge_captured ( $ order );
11841186 $ charge_id = $ order ->get_transaction_id ();
11851187
11861188 if ( ! $ charge_id ) {
@@ -1192,7 +1194,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
11921194 }
11931195
11941196 // If order is only authorized, don't pass amount.
1195- if ( ' yes ' !== $ captured ) {
1197+ if ( ! $ captured ) {
11961198 unset( $ request ['amount ' ] );
11971199 }
11981200
@@ -1210,12 +1212,10 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
12101212 }
12111213
12121214 // Only treat zero-amount as a no-op for captured charges (real refunds), not for voiding pre-auths.
1213- if ( ' yes ' === $ captured && '0.00 ' === sprintf ( '%0.2f ' , $ amount ?? 0 ) ) {
1215+ if ( $ captured && '0.00 ' === sprintf ( '%0.2f ' , $ amount ?? 0 ) ) {
12141216 return true ;
12151217 }
12161218
1217- $ order_helper = WC_Stripe_Order_Helper::get_instance ();
1218-
12191219 $ request ['charge ' ] = $ charge_id ;
12201220 WC_Stripe_Logger::log ( "Info: Beginning refund for order {$ charge_id } for the amount of {$ amount }" );
12211221 $ response = new stdClass ();
@@ -1248,7 +1248,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
12481248 }
12491249 }
12501250
1251- if ( ! $ intent_cancelled && ' yes ' === $ captured ) {
1251+ if ( ! $ intent_cancelled && $ captured ) {
12521252 $ order_helper ->lock_order_refund ( $ order );
12531253 $ response = WC_Stripe_API::request ( $ request , 'refunds ' );
12541254 }
@@ -1286,7 +1286,7 @@ public function process_refund( $order_id, $amount = null, $reason = '' ) {
12861286 }
12871287
12881288 // If charge wasn't captured, skip creating a refund and cancel order.
1289- if ( ' yes ' !== $ captured ) {
1289+ if ( ! $ captured ) {
12901290 /* translators: amount (including currency symbol) */
12911291 $ order ->add_order_note ( sprintf ( __ ( 'Pre-Authorization for %s voided. ' , 'woocommerce-gateway-stripe ' ), $ formatted_amount ) );
12921292 $ order ->update_status ( OrderStatus::CANCELLED );
@@ -1718,16 +1718,16 @@ public function save_intent_to_order( $order, $intent ) {
17181718 $ charge = $ this ->get_latest_charge_from_intent ( $ intent );
17191719
17201720 if ( isset ( $ charge ->payment_method_details ->card ->mandate ) ) {
1721- $ order -> update_meta_data ( ' _stripe_mandate_id ' , $ charge ->payment_method_details ->card ->mandate );
1721+ $ order_helper -> update_stripe_mandate_id ( $ order , $ charge ->payment_method_details ->card ->mandate );
17221722 } elseif ( isset ( $ charge ->payment_method_details ->acss_debit ->mandate ) ) {
1723- $ order -> update_meta_data ( ' _stripe_mandate_id ' , $ charge ->payment_method_details ->acss_debit ->mandate );
1723+ $ order_helper -> update_stripe_mandate_id ( $ order , $ charge ->payment_method_details ->acss_debit ->mandate );
17241724 }
17251725 } elseif ( 'setup_intent ' === $ intent ->object ) {
17261726 $ order_helper ->update_stripe_setup_intent_id ( $ order , $ intent ->id );
17271727
17281728 // Add mandate for free trial subscriptions.
17291729 if ( isset ( $ intent ->mandate ) ) {
1730- $ order -> update_meta_data ( ' _stripe_mandate_id ' , $ intent ->mandate );
1730+ $ order_helper -> update_stripe_mandate_id ( $ order , $ intent ->mandate );
17311731 }
17321732 }
17331733
@@ -1990,7 +1990,7 @@ public function create_and_confirm_intent_for_off_session( $order, $prepared_sou
19901990 }
19911991
19921992 // Add mandate if it exists.
1993- $ mandate = $ order -> get_meta ( ' _stripe_mandate_id ' , true );
1993+ $ mandate = WC_Stripe_Order_Helper:: get_instance ()-> get_stripe_mandate_id ( $ order );
19941994 if ( ! empty ( $ mandate ) ) {
19951995 $ request ['mandate ' ] = $ mandate ;
19961996 }
0 commit comments