|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Heidelpay\Hydrator; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
11
|
|
|
use Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface; |
|
12
|
|
|
use SprykerEco\Shared\Heidelpay\HeidelpayConfig; |
|
13
|
|
|
|
|
14
|
|
|
class EasyCreditResponseToQuoteHydrator implements EasyCreditResponseToQuoteHydratorInterface |
|
15
|
|
|
{ |
|
16
|
|
|
protected const EASYCREDIT_IDENTIFICATION_UNIQUE_ID = 'IDENTIFICATION_UNIQUEID'; |
|
17
|
|
|
protected const EASYCREDIT_AMORTISATION_TEXT = 'CRITERION_EASYCREDIT_AMORTISATIONTEXT'; |
|
18
|
|
|
protected const EASYCREDIT_PRECONTRACT_INFORMATION_URL = 'CRITERION_EASYCREDIT_PRECONTRACTINFORMATIONURL'; |
|
19
|
|
|
protected const EASYCREDIT_ACCRUING_INTEREST = 'CRITERION_EASYCREDIT_ACCRUINGINTEREST'; |
|
20
|
|
|
protected const EASYCREDIT_TOTAL_AMOUNT = 'CRITERION_EASYCREDIT_TOTALAMOUNT'; |
|
21
|
|
|
protected const EASYCREDIT_TOTAL_ORDER_AMOUNT = 'CRITERION_EASYCREDIT_TOTALORDERAMOUNT'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var \Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $moneyPlugin; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param \Spryker\Shared\Money\Dependency\Plugin\MoneyPluginInterface $moneyPlugin |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct(MoneyPluginInterface $moneyPlugin) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->moneyPlugin = $moneyPlugin; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param array $responseAsArray |
|
38
|
|
|
* @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
|
39
|
|
|
* |
|
40
|
|
|
* @return void |
|
41
|
|
|
*/ |
|
42
|
|
|
public function hydrateQuoteTransferWithEasyCreditResponse(array $responseAsArray, QuoteTransfer $quoteTransfer): void |
|
43
|
|
|
{ |
|
44
|
|
|
$paymentTransfer = $quoteTransfer->requirePayment()->getPayment(); |
|
45
|
|
|
$paymentTransfer->setPaymentSelection(HeidelpayConfig::PAYMENT_METHOD_EASY_CREDIT); |
|
46
|
|
|
|
|
47
|
|
|
$paymentTransfer |
|
48
|
|
|
->requireHeidelpayEasyCredit() |
|
49
|
|
|
->getHeidelpayEasyCredit() |
|
50
|
|
|
->setIdPaymentReference($responseAsArray[static::EASYCREDIT_IDENTIFICATION_UNIQUE_ID]) |
|
51
|
|
|
->setAmortisationText($responseAsArray[static::EASYCREDIT_AMORTISATION_TEXT]) |
|
52
|
|
|
->setPreContractionInformationUrl($responseAsArray[static::EASYCREDIT_PRECONTRACT_INFORMATION_URL]) |
|
53
|
|
|
->setAccruingInterest( |
|
54
|
|
|
$this->moneyPlugin->convertDecimalToInteger((float)$responseAsArray[static::EASYCREDIT_ACCRUING_INTEREST]) |
|
55
|
|
|
) |
|
56
|
|
|
->setTotalAmount( |
|
57
|
|
|
$this->moneyPlugin->convertDecimalToInteger((float)$responseAsArray[static::EASYCREDIT_TOTAL_AMOUNT]) |
|
58
|
|
|
) |
|
59
|
|
|
->setTotalOrderAmount( |
|
60
|
|
|
$this->moneyPlugin->convertDecimalToInteger((float)$responseAsArray[static::EASYCREDIT_TOTAL_ORDER_AMOUNT]) |
|
61
|
|
|
); |
|
62
|
|
|
|
|
63
|
|
|
$quoteTransfer->setPayment($paymentTransfer); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|