1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8class Services_Payment_Controller
9{
10
11	function setUp()
12	{
13		Services_Exception_Disabled::check('payment_feature', 'wikiplugin_addtocart');
14	}
15
16	function action_addtocart($input)
17	{
18		$cartlib = TikiLib::lib('cart');
19
20		$params = $input->asArray('params');
21
22		return $cartlib->add_to_cart($params, $input);
23	}
24
25	function action_addalltocart($input)
26	{
27		$cartlib = TikiLib::lib('cart');
28
29		$items = $input->asArray('items');
30		$ret = [];
31
32		foreach ($items as $item) {
33			$ret[] = $cartlib->add_to_cart($item['params'], new jitFilter($item));
34		}
35
36		return $ret;
37	}
38
39	function action_capture($input)
40	{
41		$perms = Perms::get();
42		if (! $perms->payment_admin) {
43			throw new Services_Exception_Denied(tr('Reserved for payment administrators'));
44		}
45
46		$paymentlib = TikiLib::lib('payment');
47		$paymentlib->capture_payment($input->paymentId->int());
48
49		$access = TikiLib::lib('access');
50		$access->redirect($input->next->url());
51	}
52}
53