Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Missing file doc comment

Check failure on line 1 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Class file names should be based on the class name with "class-" prepended. Expected class-stripeservice.php, but found StripeService.php.

Check failure on line 1 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Filenames should be all lowercase with hyphens as word separators. Expected stripeservice.php, but found StripeService.php.

namespace WPEverest\URMembership\Admin\Services\Stripe;

Expand Down Expand Up @@ -50,7 +50,7 @@

/**
* Construct.
*/

Check failure on line 53 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Missing @throws tag in function comment
public function __construct() {

// Initialize necessary repositories.
Expand Down Expand Up @@ -534,7 +534,7 @@
'type' => $membership_type,
);

if ( isset( $payment_data['upgrade'] ) && $payment_data['upgrade'] ) {

Check failure on line 537 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Empty IF statement detected
// $amount already holds the resolved (and converted) chargeable_amount β€” nothing to do.
} elseif ( isset( $payment_data['coupon'] ) && ! empty( $payment_data['coupon'] ) && ur_check_module_activation( 'coupon' ) ) {
$coupon_service = new CouponService();
Expand Down Expand Up @@ -749,13 +749,13 @@
* @param array $response Base response array.
* @param string $message User-facing error message.
* @param string|null $log_message Optional. Message for PaymentGatewayLogging::log_error.
* @param array $log_context Optional. Context for log

Check failure on line 752 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Parameter comment must end with a full stop
* @return array
*/
private function update_order_error( array $response, $message, $log_message = null, $log_context = array() ) {
$response['status'] = false;
$response['message'] = $message;
if ( $log_message !== null && $log_message !== '' ) {

Check failure on line 758 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Use Yoda Condition checks, you must.

Check failure on line 758 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Use Yoda Condition checks, you must.
PaymentGatewayLogging::log_error( 'stripe', $log_message, $log_context );
}
return $response;
Expand Down Expand Up @@ -923,9 +923,9 @@
'payment_method' => $latest_order['payment_method'],
)
);
$response['status'] = false;

Check warning on line 926 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Code after the RETURN statement on line 915 cannot be executed
$response['message'] = __( 'Invalid payment method for this order.', 'user-registration' );

Check warning on line 927 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Code after the RETURN statement on line 915 cannot be executed
return $response;

Check warning on line 928 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Code after the RETURN statement on line 915 cannot be executed
}

// Exclude the order that actually owns this transaction (already fetched above), not the
Expand Down Expand Up @@ -1015,6 +1015,25 @@
} elseif ( 'succeeded' === $payment_status ) {
$member_order = $this->members_orders_repository->get_member_orders( $member_id );

// The retrieved PaymentIntent must belong to the order being completed. Verification runs
// against the order that owns the transaction while completion applies to the member's newest
// order; without this guard a succeeded PaymentIntent from an earlier order can be replayed to
// complete a newer pending order, renewing/extending a membership with no new payment.
if ( empty( $member_order ) || (int) $latest_order['ID'] !== (int) $member_order['ID'] ) {
return $this->update_order_error(
$response,
__( 'Payment verification failed.', 'user-registration' ),
'Payment confirmation rejected: PaymentIntent does not belong to the order being completed',
array(
'error_code' => 'PAYMENT_INTENT_ORDER_MISMATCH',
'member_id' => $member_id,
'payment_intent_id' => $pi_id,
'verified_order_id' => $latest_order['ID'],
'target_order_id' => $member_order['ID'] ?? 0,
)
Comment on lines +1027 to +1033
);
}

if ( 'completed' === $member_order['status'] ) {
$response['message'] = $is_upgrading ? __( 'Membership upgraded successfully.', 'user-registration' ) : get_option( 'user_registration_successful_membership_creation_message', esc_html__( 'New member has been successfully created.', 'user-registration' ) );
$response['status'] = true;
Expand All @@ -1039,7 +1058,7 @@
$member_subscription['ID'],
array(
'status' => 'active',
'start_date' => date( 'Y-m-d 00:00:00' ),

Check failure on line 1061 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

date() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. Use gmdate() instead.
)
);

Expand Down Expand Up @@ -1103,7 +1122,7 @@
return $response;
}

/**

Check failure on line 1125 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Doc comment for parameter "$ID" missing
* Sends an email.
*
* @param int $id The ID of the order.
Expand Down Expand Up @@ -1377,7 +1396,7 @@
&& ( 0.0 === round( max( 0, $plan_amount - $discount ), 2 ) );

if ( $is_zeroed ) {
$start_ts = ( new \DateTime( "+ {$subscription_value} {$subscription_duration}" ) )->getTimestamp();

Check warning on line 1399 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Equals sign not aligned correctly; expected 1 space but found 6 spaces

// UR-4386: the price above came from the discounted order total (0) => a $0 recurring
// price for local-currency / missing-price subs. Re-resolve against the FULL amount.
Expand Down Expand Up @@ -1411,7 +1430,7 @@

// Single open-ended phase starting one billing period in the future: nothing is
// charged until start_date, then the plan bills at full price indefinitely.
$phase = array(

Check warning on line 1433 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Equals sign not aligned correctly; expected 1 space but found 9 spaces
'items' => array(
array( 'price' => $effective_price_id ),
),
Expand Down Expand Up @@ -1459,8 +1478,8 @@
'status' => 'pending',
'latest_invoice' => array( 'payment_intent' => null ),
);
$response['message'] = __( 'Registration complete, but the subscription could not be scheduled yet. Your membership is pending.', 'user-registration' );

Check warning on line 1481 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
$response['status'] = true;

Check warning on line 1482 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 2 spaces

return $response;
}
Expand Down Expand Up @@ -1506,8 +1525,8 @@
'schedule' => $schedule->id,
'latest_invoice' => array( 'payment_intent' => null ),
);
$response['message'] = __( 'New member has been successfully created. The subscription is scheduled to start after the free coupon period.', 'user-registration' );

Check warning on line 1528 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
$response['status'] = true;

Check warning on line 1529 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 2 spaces

return $response;
}
Expand Down Expand Up @@ -3460,7 +3479,7 @@
'orders_meta_data' => array(
array(
'meta_key' => 'is_admin_created',
'meta_value' => false,

Check warning on line 3482 in modules/membership/includes/Admin/Services/Stripe/StripeService.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4, WP Latest)

Detected usage of meta_value, possible slow query.
),
),
);
Expand Down
Loading