Skip to content

Commit

Permalink
fix(stripe): handle WC-originating Stripe transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek committed Aug 25, 2022
1 parent 8b8607a commit 674b278
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions includes/reader-revenue/class-stripe-connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ public static function receive_webhook( $request ) {

$payload = $request['data']['object'];

// If order_id is set in the metadata, this was not created by this integration.
// This can happen when WC Subscriptions w/ Stripe Gateway was active before using this integration.
// In such a situation, WCS continues to charge subscribers, but since the platform is set to this integration,
// the webhook will still be exectuted for these payments, resulting in duplicate WC orders.
if ( isset( $payload['metadata']['order_id'] ) ) {
return;
}

switch ( $request['type'] ) {
case 'charge.succeeded':
$payment = $payload;
Expand Down

0 comments on commit 674b278

Please sign in to comment.