File: D:/HostingSpaces/SBogers10/debierbaron.komma.pro/data/app/Komma/Payments/PaymentController.php
<?php
/**
* Short description for the file.
*
* @author Tim Van Samang <timvansamang@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Payments;
class PaymentController extends \BaseController
{
private $paymentService;
/**
* PaymentController constructor.
* @param PaymentService $paymentService
*/
public function __construct(PaymentService $paymentService)
{
$this->paymentService = $paymentService;
}
/**
* This is called by the WebHook of Mollie
* And will handle the payment transaction
*
* @return string
*/
public function updatePayment()
{
//Handle the transaction
$this->paymentService->handlePayment(\Input::get('id'));
return \Response::json(['status' => 'ok']);
}
/**
* This is called by the WebHook of Mollie
* And will handle the subscription payment transaction
*
* @return Json
*/
public function updateSubscriptionPayment()
{
//Handle the transaction
$this->paymentService->handleSubscriptionPayment(\Input::get('id'));
return \Response::json(['status' => 'ok']);
}
/**
* Create a new payment transaction for a subscription
* based on the token given in the request
*/
public function newSubscriptionPayment()
{
//If there is no token, abort
if (!\Request::has('token')) return \App::abort(404, 'No token found');
//Get a active subscription_transaction_request based on the token
if (!$str = $this->paymentService->getOpenSubscriptionTransactionRequest('token', \Request::get('token'))) return \App::abort(404, 'Not a valid token');
//Start a new payment and go to Mollie
return $this->paymentService->startSubscriptionPayment($str->subscription, $str);
}
}