mirror of
https://github.com/itflow-org/itflow
synced 2026-03-28 08:15:38 +00:00
Fix Recurring Payment Migration for stripe
This commit is contained in:
@@ -3900,24 +3900,30 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Recurring payment method with Stripe to the new saved_payment_id and update the method to Credit Card
|
// Look up the Stripe provider id we just inserted (or most recent one)
|
||||||
$sql_recurring_payments = mysqli_query($mysqli, "SELECT * FROM recurring_payments
|
$result = mysqli_query($mysqli, "
|
||||||
LEFT JOIN invoices ON recurring_payment_recurring_invoice_id = invoice_id
|
SELECT payment_provider_id
|
||||||
LEFT JOIN client_saved_payment_methods ON saved_payment_client_id = invoice_client_id
|
FROM payment_providers
|
||||||
WHERE recurring_payment_method = 'Stripe'"
|
WHERE payment_provider_name = 'Stripe'
|
||||||
);
|
ORDER BY payment_provider_id DESC
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
|
$stripe = mysqli_fetch_assoc($result);
|
||||||
|
$stripe_provider_id = intval($stripe['payment_provider_id']);
|
||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql_recurring_payments)) {
|
// Update all Stripe recurring payments to use the single saved method per client
|
||||||
$recurring_payment_id = intval($row['recurring_payment_id']);
|
mysqli_query($mysqli, "
|
||||||
$client_id = intval($row['invoice_client_id']);
|
UPDATE recurring_payments rp
|
||||||
$saved_payment_id = intval($row['saved_payment_id']);
|
INNER JOIN invoices i
|
||||||
|
ON rp.recurring_payment_recurring_invoice_id = i.invoice_id
|
||||||
mysqli_query($mysqli,"UPDATE recurring_payments SET
|
INNER JOIN client_saved_payment_methods spm
|
||||||
recurring_payment_method = 'Credit Card',
|
ON spm.saved_payment_client_id = i.invoice_client_id
|
||||||
recurring_payment_saved_payment_id = $saved_payment_id
|
AND spm.saved_payment_provider_id = $stripe_provider_id
|
||||||
WHERE recurring_payment_id = $recurring_payment_id"
|
SET
|
||||||
);
|
rp.recurring_payment_method = 'Credit Card',
|
||||||
}
|
rp.recurring_payment_saved_payment_id = spm.saved_payment_id
|
||||||
|
WHERE rp.recurring_payment_method = 'Stripe'
|
||||||
|
");
|
||||||
|
|
||||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.3.0'");
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.3.0'");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user