Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release branch for 6.5.0 #7228

Merged
merged 87 commits into from
Sep 21, 2023
Merged
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
f6fad59
Disputes: Add dispute notice to transactions page (#6998)
brucealdridge Aug 28, 2023
98b6f79
Update multi currency documentation links (#7072)
eduardoumpierre Aug 28, 2023
e9baed0
Fix Currency Switcher Block flag rendering on Windows platform (#6832)
eduardoumpierre Aug 28, 2023
9d5e3e3
Update Base_Constant to return the singleton object for same static c…
htdat Aug 29, 2023
7b5c7f9
RPP - Payment request class for loading, sanitizing, and escaping dat…
htdat Aug 29, 2023
ba94ddd
Update inline notice component (#7078)
ismaeldcom Aug 29, 2023
900146c
Fix Multi-currency exchange rate date formatting when using custom da…
eduardoumpierre Aug 29, 2023
605e329
Migrate link-item and woopay-item to typescript (#7080)
naman03malhotra Aug 29, 2023
17c86d9
Fix the way request constants are traversed (#7095)
RadoslavGeorgiev Aug 30, 2023
71b9423
Modify title in task to continue with onboarding (#7101)
daquinons Aug 30, 2023
4e37352
Remove reference to the v1 experiment from the code. (#7096)
dmallory42 Aug 30, 2023
e6e7c3b
Fix AED and SAR currencies format (#7083)
allie500 Aug 30, 2023
1ba4330
Merge trunk v6.4.0 into develop
botwoo Aug 31, 2023
b5bfc76
Add support for kanji and kana statement descriptors (#7051)
dpaun1985 Aug 31, 2023
6b10aec
Fix deprecation warnings on blocks checkout (#7070)
alefesouza Aug 31, 2023
8ea5c5f
Add/5669 add further payment metadata (#7091)
zmaglica Aug 31, 2023
1a5af35
Fall back to site logo when no custom WooPay logo defined (#7103)
reykjalin Aug 31, 2023
d0db2a3
Schedule individual subscription migrations and add manual migration …
mattallan Aug 31, 2023
51879ea
Migrate DetailsLink component to TS to improve code quality (#7086)
Jinksi Aug 31, 2023
e00a4af
Use client-side routing for the transaction details `ch_` → `pi_` red…
Jinksi Aug 31, 2023
39a70c0
RPP - Load payment methods through the request class (#7100)
htdat Sep 1, 2023
ce50c7a
RPP: Factor flags (#7035)
RadoslavGeorgiev Sep 1, 2023
379bf0a
Temporarily disable saving SEPA (#7107)
gpressutto5 Sep 1, 2023
f9d55c6
Provide fallback for email payment method title (#7108)
mdmoore Sep 1, 2023
635e386
Allow requests to be extended by multiple classes in parallel (#7099)
RadoslavGeorgiev Sep 4, 2023
861de2a
Disable refund button when transaction disputed (#7043)
shendy-a8c Sep 5, 2023
fc451c5
Update Transaction Details → HorizontalList label styles to uppercase…
Jinksi Sep 6, 2023
7f796aa
Add onboarding task incentive badge (#7132)
ismaeldcom Sep 6, 2023
a2a6885
Refactor Woo Subscriptions compatibility to fix currency being able t…
jessepearson Sep 6, 2023
ec31559
Merge trunk v6.4.1 into develop
botwoo Sep 6, 2023
ef54b3b
Remove unused import `NoticeOutlineIcon` to fix JS linter warning (#7…
Jinksi Sep 7, 2023
12ac12d
Add Transaction Details notice when a dispute has staged evidence (#7…
Jinksi Sep 7, 2023
18192c3
Implement `BannerNotice` component (#7097)
ismaeldcom Sep 7, 2023
bfb391c
Add cli npm command (#7111)
vladolaru Sep 7, 2023
a4bc69a
Fix multicurrency widget error on post/page edit screen (#7141)
tpaksu Sep 7, 2023
9ea339b
Session compatible fix for WooPay multi-currency (#7055)
bborman22 Sep 8, 2023
69a25f7
Fix incorrect payment intent status check in cancel authorization API…
zmaglica Sep 8, 2023
122d739
Add Horizontal list of dispute details to the transaction page (#7077)
brucealdridge Sep 11, 2023
b2602b4
Avoid redirects on docs links (#7155)
aheckler Sep 11, 2023
78ed2d6
Update subscriptions-core to 6.2 (#6976)
james-allan Sep 11, 2023
9ccdab9
Add Woo Subscription Stripe Billing settings and migration status not…
james-allan Sep 11, 2023
7e61084
Updates to the Inbox Note logic. (#7136)
dmallory42 Sep 11, 2023
f86b08e
Add New Task to Enable Payment Methods (#7129)
dmallory42 Sep 11, 2023
83c0c4c
Implement a retry system to the WCPay Subscription migration process …
mattallan Sep 12, 2023
16d8da6
Update Subscriptions with WooPayments eligibility as we move to depre…
mattallan Sep 12, 2023
b0c0e79
Improve: has_multi_currency_orders query improvement and unit tests (…
ovidiul Sep 12, 2023
ed190bc
Improvement: Query optimisation for get_all_customer_currencies metho…
ovidiul Sep 12, 2023
8aa1e68
Avoid empty fields in new onboarding flow (#7180)
daquinons Sep 12, 2023
384ca6d
Extract minimum supported PHP version from plugin file for GH actions…
deepakpathania Sep 12, 2023
5f75b8f
Update new onboarding flow components to use admin color schema (#7177)
ismaeldcom Sep 12, 2023
ca7929f
Warn about dev mode enabled on new onboarding flow choice (#7082)
oaratovskyi Sep 12, 2023
b31489f
Add the WooPay Express button to the Pay for order page (#5903)
hsingyuc Sep 13, 2023
904a8da
Follow up of Warn about dev mode (#7188)
oaratovskyi Sep 13, 2023
31175a8
Update the links used in the migrate option and automatically notice …
james-allan Sep 13, 2023
7328668
Revert "Update Subscriptions with WooPayments eligibility as we move …
james-allan Sep 13, 2023
5e89beb
fix: remove max width on WooPay checkout appearance (#7184)
frosso Sep 13, 2023
152be9b
Change ConvertedAmount component to use an updated Tooltip (#7137)
eduardoumpierre Sep 13, 2023
a23c791
Bump WC and PHP versions (#7134)
ricardo Sep 13, 2023
88d45eb
Update occurence of all ubuntu versions to `ubuntu-latest` (#7209)
deepakpathania Sep 14, 2023
37bbac3
Increase admin enqueue scripts priority (#7197)
ismaeldcom Sep 14, 2023
4fa9b05
Notices for deferred UPE rollout (#7210)
timur27 Sep 14, 2023
68d8c64
Verify the migrated subscription has a valid WooPayments payment toke…
mattallan Sep 14, 2023
343cd67
Fix single currency settings saving manual rate (#7208)
tpaksu Sep 14, 2023
0c2de49
Disable tracking on Stripe disconnected accounts (#7160)
malithsen Sep 14, 2023
502d50c
fix: express checkouts links consistency (#7198)
frosso Sep 14, 2023
d5ec63c
Add Reference to V3 Experiment (#7168)
dmallory42 Sep 14, 2023
4986288
chore: add checkout appearance documentation link (#7185)
frosso Sep 14, 2023
c1a3d9d
Merge trunk v6.4.2 into develop
cesarcosta99 Sep 14, 2023
6b65491
Fix changing Stripe Billing payment method which wasn't cancelling at…
james-allan Sep 14, 2023
c05aaf3
Adds environment metadata to Stripe Billing subscription and invoice …
james-allan Sep 14, 2023
cda8ef4
Use fallback methods for updating the next payment date after migrati…
james-allan Sep 14, 2023
7ce30b4
Allow merchants to see dispute evidence (#7192)
brucealdridge Sep 15, 2023
f930e7f
Improve the logging in the Stripe Billing migration of token data (#…
james-allan Sep 15, 2023
e2df30f
Transaction Details → fix typo in staged dispute challenge notice (#7…
Jinksi Sep 15, 2023
c4a7445
Revert "Bump WC and PHP versions (#7134)" (#7213)
ricardo Sep 15, 2023
c8f19ec
Redirect back to the pay-for-order page when it's pay-for-order order…
hsingyuc Sep 15, 2023
6ba6fab
Fix deprecated string interpolation in Analytics.php (#7170)
ridonibishi Sep 16, 2023
3695514
Fix double indicators showing under Payments tab (#7201)
oaratovskyi Sep 16, 2023
2001034
Update version and add changelog entries for release 6.5.0
github-actions[bot] Sep 17, 2023
37d3017
Fix issues when the Stripe Billing `is_migrating()` function would re…
james-allan Sep 17, 2023
e4f764f
Remove changelog file
james-allan Sep 17, 2023
724b940
Amend changelog entries for release 6.5.0
botwoo Sep 18, 2023
7f31adc
Disable automatic currency switching and switcher widgets on pay_for_…
jessepearson Sep 18, 2023
2a5c644
Prevent WooPay from modifying non-WooPay Webhooks (#7235)
timur27 Sep 19, 2023
8c1e3ca
fix: save platform checkout info on blocks (#7204)
frosso Sep 20, 2023
954d10a
Squashed merge of improve block attribute escaping
rafaelzaleski Sep 19, 2023
654a7a9
Amend changelog entries for release 6.5.0
botwoo Sep 21, 2023
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
Prev Previous commit
Next Next commit
Use fallback methods for updating the next payment date after migrati…
…ng a stripe billing subscription (#7176)

Co-authored-by: mattallan <[email protected]>
  • Loading branch information
james-allan and mattallan authored Sep 14, 2023
commit cda8ef404e296ed4671ebf70c86e7467ee9d5515
5 changes: 5 additions & 0 deletions changelog/update-subscription-next-payment-on-migrate
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: The migrator is unreleased code and improvements to it pre-release don't need a changelog entry.


84 changes: 70 additions & 14 deletions includes/subscriptions/class-wc-payments-subscriptions-migrator.php
Original file line number Diff line number Diff line change
@@ -125,18 +125,8 @@ public function migrate_wcpay_subscription( $subscription_id, $attempt = 0 ) {

$this->maybe_cancel_wcpay_subscription( $wcpay_subscription );

/**
* There's a scenario where a WCPay subscription is active but has no pending renewal scheduled action.
* Once migrated, this results in an active subscription that will remain active forever, without processing a renewal order.
*
* To ensure that all migrated subscriptions have a pending scheduled action, we need to reschedule the next payment date by
* updating the date on the subscription.
*/
if ( $subscription->has_status( 'active' ) && $subscription->get_time( 'next_payment' ) > time() ) {
$new_next_payment = gmdate( 'Y-m-d H:i:s', $subscription->get_time( 'next_payment' ) + 1 );
$subscription->update_dates( [ 'next_payment' => $new_next_payment ] );

$this->logger->log( sprintf( '---- Next payment date updated to %1$s to ensure subscription #%2$d has a pending scheduled payment.', $new_next_payment, $subscription_id ) );
if ( $subscription->has_status( 'active' ) ) {
$this->update_next_payment_date( $subscription, $wcpay_subscription );
}

// If the subscription is active or on-hold, verify the payment method is valid and set correctly that it continues to renew.
@@ -146,9 +136,11 @@ public function migrate_wcpay_subscription( $subscription_id, $attempt = 0 ) {

$this->update_wcpay_subscription_meta( $subscription );

$subscription->add_order_note( __( 'This subscription has been successfully migrated to a WooPayments tokenized subscription.', 'woocommerce-payments' ) );
if ( WC_Payment_Gateway_WCPay::GATEWAY_ID === $subscription->get_payment_method() ) {
$subscription->add_order_note( __( 'This subscription has been successfully migrated to a WooPayments tokenized subscription.', 'woocommerce-payments' ) );
}

$this->logger->log( sprintf( '---- SUCCESS: Subscription #%d migrated.', $subscription_id ) );
$this->logger->log( sprintf( '---- Subscription #%d migration complete.', $subscription_id ) );
} catch ( \Exception $e ) {
$this->logger->log( $e->getMessage() );

@@ -295,6 +287,70 @@ private function update_wcpay_subscription_meta( $subscription ) {
}
}

/**
* Updates the subscription's next payment date in WooCommerce to ensure a smooth transition to on-site billing.
*
* There's a scenario where a WCPay subscription is active but has no pending renewal scheduled action.
* Once migrated, this results in an active subscription that will remain active forever, without processing a renewal order.
*
* To ensure that all migrated subscriptions have a pending scheduled action, we need to reschedule the next payment date by
* updating the date on the subscription.
*
* In priority order the new next payment date will be:
* - The existing WooCommerce next payment date if it's in the future.
* - The Stripe subscription's current_period_end if it's in the future.
* - A newly calculated next payment date using the WC_Subscription::calculate_date() method.
*
* @param WC_Subscription $subscription The WC Subscription being migrated.
* @param array $wcpay_subscription The subscription data from Stripe.
*/
private function update_next_payment_date( $subscription, $wcpay_subscription ) {
try {
// Just update the existing WC Subscription's next payment date if it's in the future.
if ( $subscription->get_time( 'next_payment' ) > time() ) {
$new_next_payment = gmdate( 'Y-m-d H:i:s', $subscription->get_time( 'next_payment' ) + 1 );

$subscription->update_dates( [ 'next_payment' => $new_next_payment ] );
$this->logger->log( sprintf( '---- Next payment date updated to %1$s to ensure subscription #%2$d has a pending scheduled payment.', $new_next_payment, $subscription->get_id() ) );

return;
}

// If the subscription was still using WooPayments, use the Stripe subscription's next payment time (current_period_end) if it's in the future.
if ( WC_Payment_Gateway_WCPay::GATEWAY_ID === $subscription->get_payment_method() && isset( $wcpay_subscription['current_period_end'] ) && absint( $wcpay_subscription['current_period_end'] ) > time() ) {
$new_next_payment = gmdate( 'Y-m-d H:i:s', absint( $wcpay_subscription['current_period_end'] ) );

$subscription->update_dates( [ 'next_payment' => $new_next_payment ] );
$this->logger->log( sprintf( '---- Next payment date updated to %1$s to match Stripe subscription record and to ensure subscription #%2$d has a pending scheduled payment.', $new_next_payment, $subscription->get_id() ) );

return;
}

// Lastly calculate the next payment date.
$new_next_payment = $subscription->calculate_date( 'next_payment' );

if ( wcs_date_to_time( $new_next_payment ) > time() ) {
$subscription->update_dates( [ 'next_payment' => $new_next_payment ] );
$this->logger->log( sprintf( '---- Calculated a new next payment date (%1$s) to ensure subscription #%2$d has a pending scheduled payment in the future.', $new_next_payment, $subscription->get_id() ) );

return;
}

// If we got here the next payment date is in the past, the Stripe subscription is missing a "current_period_end" or it's in the past, and calculating a new date also failed. Log an error.
$this->logger->log(
sprintf(
'---- ERROR: Failed to update subscription #%1$d next payment date. Current next payment date (%2$s) is in the past, Stripe "current_period_end" data is invalid (%3$s) and an attempt to calculate a new date also failed (%4$s).',
$subscription->get_id(),
gmdate( 'Y-m-d H:i:s', $subscription->get_time( 'next_payment' ) ),
isset( $wcpay_subscription['current_period_end'] ) ? gmdate( 'Y-m-d H:i:s', absint( $wcpay_subscription['current_period_end'] ) ) : 'no data',
$new_next_payment
)
);
} catch ( \Exception $e ) {
$this->logger->log( sprintf( '---- ERROR: Failed to update subscription #%1$d next payment date. %2$s', $subscription->get_id(), $e->getMessage() ) );
}
}

/**
* Returns the subscription status from the WCPay subscription data for logging purposes.
*