Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created August 24, 2018 15:15
Show Gist options
  • Save cgi-caesar/3ac65101fc896aceb33b2c1f46822915 to your computer and use it in GitHub Desktop.
Save cgi-caesar/3ac65101fc896aceb33b2c1f46822915 to your computer and use it in GitHub Desktop.
aMember (site.php): Allow to switch payment system on resume subscription
<?php
/**
* Allow to switch payment system on resume subscription
*/
Am_Di::getInstance()->hook->add(Am_Event::INVOICE_BEFORE_PAYMENT, function(Am_Event $e) {
$invoice = $e->getInvoice();
if ($invoice->data()->get(Invoice::ORIG_ID) && !$invoice->data()->get('skip-me')) {
$invoice->data()->set('skip-me', 1);
$invoice->paysys_id = null;
$invoice->save();
Am_Mvc_Response::redirectLocation($e->getDi()->url("pay/{$invoice->getSecureId('payment-link')}", false));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment