Skip to content

Commit 7f9edd4

Browse files
author
Kristófer R
committed
Fix duplicate charge issue
The problem was that an extra gateway class was instantiated that caused payments to be processed twice. By removing the extra instance of the payment gateway the problem has been fixed.
1 parent 9459297 commit 7f9edd4

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

includes/admin/class-wc-stripe-inbox-notes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static function create_upe_notes() {
5555
WC_Stripe_UPE_Availability_Note::init();
5656

5757
require_once WC_STRIPE_PLUGIN_PATH . '/includes/notes/class-wc-stripe-upe-stripelink-note.php';
58-
WC_Stripe_UPE_StripeLink_Note::init( new WC_Stripe_UPE_Payment_Gateway() );
58+
WC_Stripe_UPE_StripeLink_Note::init( WC_Stripe::get_instance()->get_main_stripe_gateway() );
5959
}
6060

6161
public static function get_campaign_2020_cutoff() {

includes/notes/class-wc-stripe-upe-stripelink-note.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ private static function get_note_class() {
6767
/**
6868
* Init Link payment method notification
6969
*
70-
* @param WC_Stripe_UPE_Payment_Gateway $gateway
70+
* @param WC_Stripe_Payment_Gateway $gateway
7171
*
7272
* @return void
7373
* @throws \Automattic\WooCommerce\Admin\Notes\NotesUnavailableException
7474
*/
75-
public static function init( WC_Stripe_UPE_Payment_Gateway $gateway ) {
75+
public static function init( WC_Stripe_Payment_Gateway $gateway ) {
7676
if ( ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
7777
return;
7878
}
@@ -84,6 +84,10 @@ public static function init( WC_Stripe_UPE_Payment_Gateway $gateway ) {
8484
return;
8585
}
8686

87+
if ( ! is_a( $gateway, 'WC_Stripe_UPE_Payment_Gateway' ) ) {
88+
return;
89+
}
90+
8791
// If store currency is not USD, skip
8892
if ( 'USD' !== get_woocommerce_currency() ) {
8993
return;

woocommerce-gateway-stripe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ class WC_Stripe {
6363
/**
6464
* The *Singleton* instance of this class
6565
*
66-
* @var Singleton
66+
* @var WC_Stripe
6767
*/
6868
private static $instance;
6969

7070
/**
7171
* Returns the *Singleton* instance of this class.
7272
*
73-
* @return Singleton The *Singleton* instance.
73+
* @return WC_Stripe The *Singleton* instance.
7474
*/
7575
public static function get_instance() {
7676
if ( null === self::$instance ) {

0 commit comments

Comments
 (0)