Skip to content

Commit

Permalink
Merge pull request #168 from roodjong/change-bank-account
Browse files Browse the repository at this point in the history
Mogelijkheid om incasso in te stellen op andere bankrekening
  • Loading branch information
Nowa-Ammerlaan authored Apr 14, 2024
2 parents ff0d75c + 9d3f255 commit f2292c3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Controller/ContributionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use DateTime;
use DateInterval;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Throwable;
use Symfony\Component\Yaml\Yaml;

class ContributionController extends AbstractController
Expand All @@ -40,6 +41,43 @@ public function preferences(Request $request): Response {
]);
}

/**
* @Route("/contribute-instellingen/verander-bankrekening", name="member_contribution_preferences_change_bank_account")
*/
public function changeBankAccount(MollieApiClient $mollieApiClient): Response
{
/** @var Member */
$member = $this->getUser();

if ($member->getMollieCustomerId() !== null)
{
$customer = $mollieApiClient->customers->get($member->getMollieCustomerId());

if ($member->getMollieSubscriptionId() !== null)
{
$subscription = $mollieApiClient->subscriptions->getFor($customer, $member->getMollieSubscriptionId());
$subscription->cancel();
$member->setMollieSubscriptionId(null);
$this->getDoctrine()->getManager()->flush();
}

foreach ($customer->mandates()->getIterator() as $mandate)
{
try
{
$mandate->revoke();
}
catch (Throwable $throwable)
{}
}
}

$member->setCreateSubscriptionAfterPayment(true);
$this->getDoctrine()->getManager()->flush();

return $this->redirectToRoute('member_contribution_pay');
}

/**
* @Route("/contributie-betalen", name="member_contribution_pay")
*/
Expand Down
2 changes: 2 additions & 0 deletions templates/user/contribution/automatic-collection.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
<p>
Wil je de automatische incasso stopzetten, en in plaats daarvan je contributie handmatig betalen? Klik dan op deze knop.
</p>

<a href="{{ url('member_contribution_automatic_collection_disable') }}" class="button">Automatische incasso stopzetten</a>
<a href="{{ url('member_contribution_preferences_change_bank_account') }}" class="button">Instellen met andere bankrekening</a>
{% else %}
<p>
Contributie zal elk kwartaal automatisch van je rekening afgeschreven worden via automatisch incasso.
Expand Down
1 change: 1 addition & 0 deletions templates/user/details.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
</p>

<a class="action-link" href="{{ url('member_contribution_automatic_collection') }}">Automatische incasso stopzetten</a>
<a class="action-link" href="{{ url('member_contribution_preferences_change_bank_account') }}" class="button">Instellen met andere bankrekening</a>
{% else %}
{% if app.user.contributionCompleted(date()) %}
<p>
Expand Down

0 comments on commit f2292c3

Please sign in to comment.