| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function init() |
||
| 28 | { |
||
| 29 | parent::init(); |
||
| 30 | $reservation = $this->getReservation(); |
||
| 31 | |||
| 32 | // If we get to the success controller form any state except PENDING or PAID |
||
| 33 | // This would mean someone would be clever and change the url from summary to success bypassing the payment |
||
| 34 | // End the session, thus removing the reservation, and redirect back |
||
| 35 | if (!in_array($reservation->Status, array('PENDING', 'PAID'))) { |
||
| 36 | ReservationSession::end(); |
||
| 37 | $this->redirect($this->Link('/')); |
||
| 38 | } elseif ($reservation->Status !== 'PAID' && $reservation->changeState('PAID')) { |
||
| 39 | $reservation->send(); |
||
| 40 | $this->extend('afterPaymentComplete', $reservation); |
||
| 41 | $reservation->write(); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 |