|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the Marlon Ogone package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Marlon BVBA <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Ogone\DirectLink; |
|
12
|
|
|
|
|
13
|
|
|
use Ogone\AbstractPaymentRequest; |
|
14
|
|
|
use Ogone\ShaComposer\ShaComposer; |
|
15
|
|
|
use InvalidArgumentException; |
|
16
|
|
|
|
|
17
|
|
|
class DirectLinkPaymentRequest extends AbstractPaymentRequest |
|
18
|
|
|
{ |
|
19
|
|
|
|
|
20
|
|
|
const TEST = "https://secure.ogone.com/ncol/test/orderdirect.asp"; |
|
21
|
|
|
const PRODUCTION = "https://secure.ogone.com/ncol/prod/orderdirect.asp"; |
|
22
|
|
|
|
|
23
|
8 |
|
public function __construct(ShaComposer $shaComposer) |
|
24
|
|
|
{ |
|
25
|
8 |
|
$this->shaComposer = $shaComposer; |
|
26
|
8 |
|
$this->ogoneUri = self::TEST; |
|
27
|
8 |
|
} |
|
28
|
|
|
|
|
29
|
5 |
|
public function getRequiredFields() |
|
30
|
|
|
{ |
|
31
|
|
|
return array( |
|
32
|
5 |
|
'pspid', 'currency', 'amount', 'orderid', 'userid', 'pswd' |
|
33
|
|
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
2 |
|
public function getValidOgoneUris() |
|
37
|
|
|
{ |
|
38
|
2 |
|
return array(self::TEST, self::PRODUCTION); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
6 |
|
public function setUserId($userid) |
|
42
|
|
|
{ |
|
43
|
6 |
|
if (strlen($userid) < 2) { |
|
44
|
1 |
|
throw new InvalidArgumentException("User ID is too short"); |
|
45
|
|
|
} |
|
46
|
5 |
|
$this->parameters['userid'] = $userid; |
|
47
|
5 |
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** Alias for setPswd() */ |
|
50
|
5 |
|
public function setPassword($password) |
|
51
|
|
|
{ |
|
52
|
5 |
|
$this->setPswd($password); |
|
53
|
5 |
|
} |
|
54
|
|
|
|
|
55
|
6 |
|
public function setPswd($password) |
|
56
|
|
|
{ |
|
57
|
6 |
|
if (strlen($password) < 8) { |
|
58
|
1 |
|
throw new InvalidArgumentException("Password is too short"); |
|
59
|
|
|
} |
|
60
|
5 |
|
$this->parameters['pswd'] = $password; |
|
61
|
5 |
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
public function setAlias(Alias $alias) |
|
64
|
|
|
{ |
|
65
|
1 |
|
$this->parameters['alias'] = $alias->__toString(); |
|
66
|
1 |
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function setEci(Eci $eci) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->parameters['eci'] = (string) $eci; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function setCvc($cvc) |
|
74
|
|
|
{ |
|
75
|
|
|
$this->parameters['cvc'] = $cvc; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
protected function getValidOperations() |
|
79
|
|
|
{ |
|
80
|
|
|
return array( |
|
81
|
|
|
PaymentOperation::REQUEST_FOR_AUTHORISATION, |
|
82
|
|
|
PaymentOperation::REQUEST_FOR_DIRECT_SALE, |
|
83
|
|
|
PaymentOperation::REFUND, |
|
84
|
|
|
PaymentOperation::REQUEST_FOR_PRE_AUTHORISATION, |
|
85
|
|
|
); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|