Skip to content
Snippets Groups Projects
Commit 52b5f69b authored by mattwire's avatar mattwire
Browse files

Check for existing recur

parent 69ad564c
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,17 @@ class Subscription extends Base {
// Make sure we have a Contact ID
$this->deriveContactIDFromCustomer($stripeSubscription);
// Check if we already have a recurring contribution
if (!$this->hasContributionRecurID()) {
$contributionRecur = \Civi\Api4\ContributionRecur::get(FALSE)
->addWhere('processor_id', '=', $this->getStripeSubscriptionID())
->addWhere('is_test', '=', $this->paymentProcessor->getPaymentProcessor()['is_test'])
->execute()
->first();
if (!empty($contributionRecur)) {
$this->setContributionRecurID($contributionRecur['id']);
}
}
if (!$this->hasContributionRecurID()) {
// No existing recurring contribution - create one
$contributionRecurParams = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment