Skip to content

Commit 0fefb0a

Browse files
committed
Replacing additional references
1 parent e76ccdd commit 0fefb0a

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

includes/abstracts/abstract-wc-stripe-payment-gateway.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ public function prepare_order_source( $order = null ) {
10201020

10211021
// Since 4.0.0, we changed card to source so we need to account for that.
10221022
if ( empty( $source_id ) ) {
1023-
$source_id = $order->get_meta( '_stripe_card_id', true );
1023+
$source_id = $order->get_meta( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID, true );
10241024

10251025
// Take this opportunity to update the key name.
10261026
$order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID, $source_id );
@@ -1688,12 +1688,12 @@ public function save_intent_to_order( $order, $intent ) {
16881688
$charge = $this->get_latest_charge_from_intent( $intent );
16891689

16901690
if ( isset( $charge->payment_method_details->card->mandate ) ) {
1691-
$order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_MANDATE_ID, $charge->payment_method_details->card->mandate );
1691+
$order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_MANDATE_ID, $charge->payment_method_details->card->mandate );
16921692
} elseif ( isset( $charge->payment_method_details->acss_debit->mandate ) ) {
16931693
$order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_MANDATE_ID, $charge->payment_method_details->acss_debit->mandate );
16941694
}
16951695
} elseif ( 'setup_intent' === $intent->object ) {
1696-
$order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SETUP_INTENT, $intent->id );
1696+
$order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SETUP_INTENT, $intent->id );
16971697

16981698
// Add mandate for free trial subscriptions.
16991699
if ( isset( $intent->mandate ) ) {

includes/admin/class-wc-stripe-admin-notices.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ public function subscription_check_detachment() {
490490
);
491491
$customer_stripe_page = sprintf(
492492
'<a href="%s">%s</a>',
493-
esc_url( WC_Stripe_Subscriptions_Helper::STRIPE_CUSTOMER_PAGE_BASE_URL . $subscription->get_meta( '_stripe_customer_id' ) ),
493+
esc_url( WC_Stripe_Subscriptions_Helper::STRIPE_CUSTOMER_PAGE_BASE_URL . $subscription->get_meta( WC_Stripe_Order_Metas::META_STRIPE_CUSTOMER_ID ) ),
494494
esc_html(
495495
/* translators: this is a text for a link pointing to the customer's page on Stripe */
496496
__( 'Stripe customer page &rarr;', 'woocommerce-gateway-stripe' )

includes/compat/class-wc-stripe-subscriptions-helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static function is_subscription_payment_method_detached( $subscription )
151151
return false;
152152
}
153153

154-
$source_id = $subscription->get_meta( '_stripe_source_id' );
154+
$source_id = $subscription->get_meta( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID );
155155
if ( ! $source_id ) {
156156
return false;
157157
}
@@ -220,7 +220,7 @@ public static function is_manual_renewal_enabled() {
220220
public static function get_detached_payment_data_from_subscription( $subscription ) {
221221
return [
222222
'id' => $subscription->get_id(),
223-
'customer_id' => $subscription->get_meta( '_stripe_customer_id' ),
223+
'customer_id' => $subscription->get_meta( WC_Stripe_Order_Metas::META_STRIPE_CUSTOMER_ID ),
224224
'change_payment_method_url' => $subscription->get_change_payment_method_url(),
225225
];
226226
}

includes/compat/trait-wc-stripe-pre-orders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class_exists( 'WC_Pre_Orders_Order' ) &&
174174
*/
175175
public function remove_order_source_before_retry( $order ) {
176176
$order->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID );
177-
$order->delete_meta_data( '_stripe_card_id' );
177+
$order->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID );
178178
$order->save();
179179
}
180180

includes/compat/trait-wc-stripe-subscriptions.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ public function delete_resubscribe_meta( $resubscribe_order ) {
644644
$resubscribe_order->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_CUSTOMER_ID );
645645
$resubscribe_order->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID );
646646
// For BW compat will remove in future.
647-
$resubscribe_order->delete_meta_data( '_stripe_card_id' );
647+
$resubscribe_order->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID );
648648
// Delete payment intent ID.
649649
$resubscribe_order->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_INTENT_ID );
650650
$this->delete_renewal_meta( $resubscribe_order );
@@ -696,11 +696,11 @@ public function add_subscription_payment_meta( $payment_meta, $subscription ) {
696696

697697
// For BW compat will remove in future.
698698
if ( empty( $source_id ) ) {
699-
$source_id = $subscription->get_meta( '_stripe_card_id', true );
699+
$source_id = $subscription->get_meta( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID, true );
700700

701701
// Take this opportunity to update the key name.
702702
$subscription->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID, $source_id );
703-
$subscription->delete_meta_data( '_stripe_card_id' );
703+
$subscription->delete_meta_data( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID );
704704
$subscription->save();
705705
}
706706

@@ -744,10 +744,10 @@ public function validate_subscription_payment_meta( $payment_method_id, $payment
744744
}
745745

746746
if (
747-
! empty( $payment_meta['post_meta'][WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID]['value'] ) && (
748-
0 !== strpos( $payment_meta['post_meta'][WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID]['value'], 'card_' )
749-
&& 0 !== strpos( $payment_meta['post_meta'][WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID]['value'], 'src_' )
750-
&& 0 !== strpos( $payment_meta['post_meta'][WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID]['value'], 'pm_' )
747+
! empty( $payment_meta['post_meta'][ WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID ]['value'] ) && (
748+
0 !== strpos( $payment_meta['post_meta'][ WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID ]['value'], 'card_' )
749+
&& 0 !== strpos( $payment_meta['post_meta'][ WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID ]['value'], 'src_' )
750+
&& 0 !== strpos( $payment_meta['post_meta'][ WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID ]['value'], 'pm_' )
751751
)
752752
) {
753753
throw new Exception( __( 'Invalid payment method ID. A valid "Stripe Payment Method ID" must begin with "src_", "pm_", or "card_".', 'woocommerce-gateway-stripe' ) );
@@ -970,7 +970,7 @@ public function maybe_render_subscription_payment_method( $payment_method_to_dis
970970

971971
// For BW compat will remove in future.
972972
if ( empty( $stripe_source_id ) ) {
973-
$stripe_source_id = $subscription->get_meta( '_stripe_card_id', true );
973+
$stripe_source_id = $subscription->get_meta( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID, true );
974974

975975
// Take this opportunity to update the key name.
976976
$subscription->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID, $stripe_source_id );
@@ -988,7 +988,7 @@ public function maybe_render_subscription_payment_method( $payment_method_to_dis
988988

989989
// For BW compat will remove in future.
990990
if ( empty( $stripe_source_id ) ) {
991-
$stripe_source_id = get_user_option( '_stripe_card_id', $user_id );
991+
$stripe_source_id = get_user_option( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID, $user_id );
992992

993993
// Take this opportunity to update the key name.
994994
update_user_option( $user_id, WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID, $stripe_source_id, false );
@@ -1003,7 +1003,7 @@ public function maybe_render_subscription_payment_method( $payment_method_to_dis
10031003

10041004
// For BW compat will remove in future.
10051005
if ( empty( $stripe_source_id ) ) {
1006-
$stripe_source_id = $parent_order->get_meta( '_stripe_card_id', true );
1006+
$stripe_source_id = $parent_order->get_meta( WC_Stripe_Order_Metas::META_STRIPE_CARD_ID, true );
10071007

10081008
// Take this opportunity to update the key name.
10091009
$parent_order->update_meta_data( WC_Stripe_Order_Metas::META_STRIPE_SOURCE_ID, $stripe_source_id );

includes/constants/class-wc-stripe-order-metas.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ class WC_Stripe_Order_Metas {
6969
*/
7070
const META_STRIPE_PAYMENT_AWAITING_ACTION = '_stripe_payment_awaiting_action';
7171

72+
/**
73+
* Meta key for the Stripe card ID.
74+
*
75+
* @var string
76+
*/
77+
const META_STRIPE_CARD_ID = '_stripe_card_id';
78+
7279
/**
7380
* Meta key for the Stripe card brand.
7481
*

0 commit comments

Comments
 (0)