|
1
|
|
|
<?php |
|
2
|
|
|
namespace Paranoia\Builder; |
|
3
|
|
|
|
|
4
|
|
|
use Paranoia\Builder\NestPay\CancelRequestBuilder; |
|
5
|
|
|
use Paranoia\Builder\NestPay\PostAuthorizationRequestBuilder; |
|
6
|
|
|
use Paranoia\Builder\NestPay\PreAuthorizationRequestBuilder; |
|
7
|
|
|
use Paranoia\Builder\NestPay\RefundRequestBuilder; |
|
8
|
|
|
use Paranoia\Builder\NestPay\SaleRequestBuilder; |
|
9
|
|
|
use Paranoia\Exception\NotImplementedError; |
|
10
|
|
|
use Paranoia\Formatter\DecimalFormatter; |
|
11
|
|
|
use Paranoia\Formatter\IsoNumericCurrencyCodeFormatter; |
|
12
|
|
|
use Paranoia\Formatter\NestPay\ExpireDateFormatter; |
|
13
|
|
|
use Paranoia\Formatter\SingleDigitInstallmentFormatter; |
|
14
|
|
|
use Paranoia\TransactionType; |
|
15
|
|
|
|
|
16
|
|
|
class NestPayBuilderFactory extends AbstractBuilderFactory |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @param $transactionType |
|
20
|
|
|
* @return AbstractRequestBuilder |
|
21
|
|
|
* @throws NotImplementedError |
|
22
|
|
|
*/ |
|
23
|
|
|
public function createBuilder($transactionType) |
|
24
|
|
|
{ |
|
25
|
|
|
switch ($transactionType) { |
|
26
|
|
|
case TransactionType::SALE: |
|
27
|
|
|
return new SaleRequestBuilder( |
|
28
|
|
|
$this->configuration, |
|
29
|
|
|
new IsoNumericCurrencyCodeFormatter(), |
|
30
|
|
|
new DecimalFormatter(), |
|
31
|
|
|
new SingleDigitInstallmentFormatter(), |
|
32
|
|
|
new ExpireDateFormatter() |
|
33
|
|
|
); |
|
34
|
|
|
case TransactionType::CANCEL: |
|
35
|
|
|
return new CancelRequestBuilder( |
|
36
|
|
|
$this->configuration, |
|
37
|
|
|
new IsoNumericCurrencyCodeFormatter(), |
|
38
|
|
|
new DecimalFormatter(), |
|
39
|
|
|
new SingleDigitInstallmentFormatter(), |
|
40
|
|
|
new ExpireDateFormatter() |
|
41
|
|
|
); |
|
42
|
|
|
case TransactionType::REFUND: |
|
43
|
|
|
return new RefundRequestBuilder( |
|
44
|
|
|
$this->configuration, |
|
45
|
|
|
new IsoNumericCurrencyCodeFormatter(), |
|
46
|
|
|
new DecimalFormatter(), |
|
47
|
|
|
new SingleDigitInstallmentFormatter(), |
|
48
|
|
|
new ExpireDateFormatter() |
|
49
|
|
|
); |
|
50
|
|
|
case TransactionType::PRE_AUTHORIZATION: |
|
51
|
|
|
return new PreAuthorizationRequestBuilder( |
|
52
|
|
|
$this->configuration, |
|
53
|
|
|
new IsoNumericCurrencyCodeFormatter(), |
|
54
|
|
|
new DecimalFormatter(), |
|
55
|
|
|
new SingleDigitInstallmentFormatter(), |
|
56
|
|
|
new ExpireDateFormatter() |
|
57
|
|
|
); |
|
58
|
|
|
case TransactionType::POST_AUTHORIZATION: |
|
59
|
|
|
return new PostAuthorizationRequestBuilder( |
|
60
|
|
|
$this->configuration, |
|
61
|
|
|
new IsoNumericCurrencyCodeFormatter(), |
|
62
|
|
|
new DecimalFormatter(), |
|
63
|
|
|
new SingleDigitInstallmentFormatter(), |
|
64
|
|
|
new ExpireDateFormatter() |
|
65
|
|
|
); |
|
66
|
|
|
default: |
|
67
|
|
|
throw new NotImplementedError('Not implemented transaction type: ' . $transactionType); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|