Completed
Push — master ( ecf987...d377d1 )
by Aimeos
20:09
created

Base::repay()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2017
7
 * @package MShop
8
 * @subpackage Service
9
 */
10
11
12
namespace Aimeos\MShop\Service\Provider\Payment;
13
14
15
/**
16
 * Abstract class for all payment provider implementations.
17
 *
18
 * @package MShop
19
 * @subpackage Service
20
 */
21
abstract class Base
22
	extends \Aimeos\MShop\Service\Provider\Base
23
{
24
	/**
25
	 * Feature constant if querying for status updates for an order is supported.
26
	 */
27
	const FEAT_QUERY = 1;
28
29
	/**
30
	 * Feature constant if canceling authorizations is supported.
31
	 */
32
	const FEAT_CANCEL = 2;
33
34
	/**
35
	 * Feature constant if money authorization and later capture is supported.
36
	 */
37
	const FEAT_CAPTURE = 3;
38
39
	/**
40
	 * Feature constant if refunding payments is supported.
41
	 */
42
	const FEAT_REFUND = 4;
43
44
	/**
45
	 * Feature constant if reoccurring payments is supported.
46
	 */
47
	const FEAT_REPAY = 5;
48
49
50
	/**
51
	 * Checks the backend configuration attributes for validity.
52
	 *
53
	 * @param array $attributes Attributes added by the shop owner in the administraton interface
54
	 * @return array An array with the attribute keys as key and an error message as values for all attributes that are
55
	 * 	known by the provider but aren't valid
56
	 */
57
	public function checkConfigBE( array $attributes )
58
	{
59
		return [];
60
	}
61
62
63
	/**
64
	 * Returns the configuration attribute definitions of the provider to generate a list of available fields and
65
	 * rules for the value of each field in the administration interface.
66
	 *
67
	 * @return array List of attribute definitions implementing \Aimeos\MW\Common\Critera\Attribute\Iface
68
	 */
69
	public function getConfigBE()
70
	{
71
		return [];
72
	}
73
74
75
	/**
76
	 * Cancels the authorization for the given order if supported.
77
	 *
78
	 * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
79
	 */
80
	public function cancel( \Aimeos\MShop\Order\Item\Iface $order )
81
	{
82
		throw new \Aimeos\MShop\Service\Exception( sprintf( 'Method "%1$s" for provider not available', 'cancel' ) );
83
	}
84
85
86
	/**
87
	 * Captures the money later on request for the given order if supported.
88
	 *
89
	 * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
90
	 */
91
	public function capture( \Aimeos\MShop\Order\Item\Iface $order )
92
	{
93
		throw new \Aimeos\MShop\Service\Exception( sprintf( 'Method "%1$s" for provider not available', 'capture' ) );
94
	}
95
96
97
	/**
98
	 * Tries to get an authorization or captures the money immediately for the given order if capturing the money
99
	 * separately isn't supported or not configured by the shop owner.
100
	 *
101
	 * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
102
	 * @param array $params Request parameter if available
103
	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Standard Form object with URL, action and parameters to redirect to
104
	 * 	(e.g. to an external server of the payment provider or to a local success page)
105
	 */
106
	public function process( \Aimeos\MShop\Order\Item\Iface $order, array $params = [] )
107
	{
108
		$url = $this->getConfigValue( array( 'payment.url-success' ) );
109
110
		return new \Aimeos\MShop\Common\Item\Helper\Form\Standard( $url, 'POST', [] );
111
	}
112
113
114
	/**
115
	 * Refunds the money for the given order if supported.
116
	 *
117
	 * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
118
	 */
119
	public function refund( \Aimeos\MShop\Order\Item\Iface $order )
120
	{
121
		throw new \Aimeos\MShop\Service\Exception( sprintf( 'Method "%1$s" for provider not available', 'refund' ) );
122
	}
123
124
125
	/**
126
	 * Executes the payment again for the given order if supported.
127
	 * This requires support of the payment gateway and token based payment
128
	 *
129
	 * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object
130
	 * @return void
131
	 */
132
	public function repay( \Aimeos\MShop\Order\Item\Iface $order )
133
	{
134
		throw new \Aimeos\MShop\Service\Exception( sprintf( 'Method "%1$s" for provider not available', 'repay' ) );
135
	}
136
137
138
	/**
139
	 * Sets the payment attributes in the given service.
140
	 *
141
	 * @param \Aimeos\MShop\Order\Item\Base\Service\Iface $orderServiceItem Order service item that will be added to the basket
142
	 * @param array $attributes Attribute key/value pairs entered by the customer during the checkout process
143
	 */
144
	public function setConfigFE( \Aimeos\MShop\Order\Item\Base\Service\Iface $orderServiceItem, array $attributes )
145
	{
146
		$this->setAttributes( $orderServiceItem, $attributes, 'payment' );
147
	}
148
}