|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Magium\Magento\Actions\Checkout\PaymentInformation; |
|
4
|
|
|
|
|
5
|
|
|
use Magium\Magento\AbstractMagentoTestCase; |
|
6
|
|
|
use Magium\Magento\Actions\Checkout\PaymentInformation; |
|
7
|
|
|
|
|
8
|
|
|
class AuthorizeNet extends PaymentInformation |
|
9
|
|
|
{ |
|
10
|
|
|
const ACTION = 'Checkout\PaymentInformation\AuthorizeNet'; |
|
11
|
|
|
|
|
12
|
|
|
const TYPE_UNKNOWN = 'UNKNOWN'; |
|
13
|
|
|
const TYPE_VISA = 'VI'; |
|
14
|
|
|
const TYPE_AMERICAN_EXPRESS = 'AE'; |
|
15
|
|
|
const TYPE_DISCOVER = 'DI'; |
|
16
|
|
|
const TYPE_MASTERCARD = 'MC'; |
|
17
|
|
|
|
|
18
|
|
|
protected $ccNums = [ |
|
19
|
|
|
self::TYPE_VISA => '4007000000027', |
|
20
|
|
|
self::TYPE_AMERICAN_EXPRESS => '370000000000002', |
|
21
|
|
|
self::TYPE_DISCOVER => '6011000000000012', |
|
22
|
|
|
self::TYPE_MASTERCARD => '5424000000000015', |
|
23
|
|
|
self::TYPE_UNKNOWN => '0000000000000000' |
|
24
|
|
|
]; |
|
25
|
|
|
|
|
26
|
|
|
protected function setDefaults() |
|
27
|
|
|
{ |
|
28
|
|
|
parent::setDefaults(); |
|
29
|
|
|
$defaultCC = current($this->ccNums); |
|
30
|
|
|
$defaultType = key($this->ccNums); |
|
31
|
|
|
$this->setCreditCardNumber($defaultCC); |
|
32
|
|
|
$this->setType($defaultType); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
protected function configureType($type) |
|
36
|
|
|
{ |
|
37
|
|
|
if (!isset($this->ccNums[$type])) { |
|
38
|
|
|
throw new InvalidPaymentInformationException('Unknown payment type: ' . $type); |
|
39
|
|
|
} |
|
40
|
|
|
$this->setCreditCardNumber($this->ccNums[$type]); |
|
41
|
|
|
$this->setType($type); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function configureTest(AbstractMagentoTestCase $testCase) |
|
45
|
|
|
{ |
|
46
|
|
|
$testCase->setPaymentMethod('AuthorizeNet'); |
|
47
|
|
|
$testCase->setTypePreference('Magium\Magento\Actions\Checkout\PaymentInformation', get_class($this)); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function setUseVisa() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->configureType(self::TYPE_VISA); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function setUseAmericanExpress() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->configureType(self::TYPE_AMERICAN_EXPRESS); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function setUseDiscover() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->configureType(self::TYPE_DISCOVER); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function setUseMastercard() |
|
66
|
|
|
{ |
|
67
|
|
|
$this->configureType(self::TYPE_MASTERCARD); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
} |