Created
August 24, 2018 15:15
-
-
Save cgi-caesar/3ac65101fc896aceb33b2c1f46822915 to your computer and use it in GitHub Desktop.
aMember (site.php): Allow to switch payment system on resume subscription
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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