PAYONE-GmbH /
magento-2
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Payone\Core\Block\Form; |
||
| 4 | |||
| 5 | use Payone\Core\Model\PayoneConfig; |
||
| 6 | |||
| 7 | class RatepayInvoice extends Base |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var \Magento\Sales\Model\AdminOrder\Create |
||
|
0 ignored issues
–
show
|
|||
| 11 | */ |
||
| 12 | protected $orderCreate; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var \Payone\Core\Helper\Ratepay |
||
| 16 | */ |
||
| 17 | protected $ratepayHelper; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var array|null |
||
| 21 | */ |
||
| 22 | protected $ratepayConfig = null; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param \Magento\Framework\View\Element\Template\Context $context |
||
| 26 | * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate |
||
| 27 | * @param \Payone\Core\Helper\Ratepay $ratepayHelper |
||
| 28 | * @param array $data |
||
| 29 | */ |
||
| 30 | public function __construct( |
||
| 31 | \Magento\Framework\View\Element\Template\Context $context, |
||
|
0 ignored issues
–
show
The type
Magento\Framework\View\Element\Template\Context was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 32 | \Magento\Sales\Model\AdminOrder\Create $orderCreate, |
||
| 33 | \Payone\Core\Helper\Ratepay $ratepayHelper, |
||
| 34 | array $data = [] |
||
| 35 | ) { |
||
| 36 | parent::__construct($context, $data); |
||
| 37 | $this->orderCreate = $orderCreate; |
||
| 38 | $this->ratepayHelper = $ratepayHelper; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Retrieve create order model object |
||
| 43 | * |
||
| 44 | * @return \Magento\Quote\Model\Quote |
||
|
0 ignored issues
–
show
The type
Magento\Quote\Model\Quote was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 45 | */ |
||
| 46 | public function getQuote() |
||
| 47 | { |
||
| 48 | return $this->orderCreate->getQuote(); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Tries to determine a matching ratepay configuration |
||
| 53 | * |
||
| 54 | * @return array |
||
| 55 | */ |
||
| 56 | public function getRatepayConfig() |
||
| 57 | { |
||
| 58 | if ($this->ratepayConfig === null) { |
||
| 59 | $this->ratepayConfig = $this->ratepayHelper->getRatepaySingleConfig(PayoneConfig::METHOD_RATEPAY_INVOICE, $this->getQuote()); |
||
| 60 | } |
||
| 61 | return $this->ratepayConfig; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Returns snippet id from config |
||
| 66 | * |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | public function getDevicefingerprintSnippetId() |
||
| 70 | { |
||
| 71 | return $this->ratepayHelper->getConfigParam('devicefingerprint_snippet_id', 'ratepay', 'payone_misc'); |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Returns token generated by Ratepay helper |
||
| 76 | * |
||
| 77 | * @return string |
||
| 78 | */ |
||
| 79 | public function getDevicefingerprintToken() |
||
| 80 | { |
||
| 81 | return $this->ratepayHelper->getRatepayDeviceFingerprintToken(); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Returns if birthday has to be entered |
||
| 86 | * |
||
| 87 | * @return bool |
||
| 88 | */ |
||
| 89 | public function isBirthdayNeeded() |
||
| 90 | { |
||
| 91 | if ($this->isB2BMode() === true) { |
||
| 92 | return false; |
||
| 93 | } |
||
| 94 | return true; |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Return if customer has entered a company name in his billing address |
||
| 99 | * |
||
| 100 | * @return bool |
||
| 101 | */ |
||
| 102 | public function isB2BMode() |
||
| 103 | { |
||
| 104 | $billingAddress = $this->getQuote()->getBillingAddress(); |
||
| 105 | if ($billingAddress && !empty($billingAddress->getCompany())) { |
||
| 106 | return true; |
||
| 107 | } |
||
| 108 | return false; |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Return if ratepay config allows B2B mode |
||
| 113 | * |
||
| 114 | * @return bool |
||
| 115 | */ |
||
| 116 | public function isB2BModeAllowed() |
||
| 117 | { |
||
| 118 | $aConfig = $this->getRatepayConfig(); |
||
| 119 | if (isset($aConfig['b2bAllowed'])) { |
||
| 120 | return (bool)$aConfig['b2bAllowed']; |
||
| 121 | } |
||
| 122 | return false; |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Return if ratepay config allows differing delivery addresses |
||
| 127 | * |
||
| 128 | * @return bool |
||
| 129 | */ |
||
| 130 | public function isDifferingDeliveryAddressAllowed() |
||
| 131 | { |
||
| 132 | $aConfig = $this->getRatepayConfig(); |
||
| 133 | if (isset($aConfig['differentAddressAllowed'])) { |
||
| 134 | return (bool)$aConfig['differentAddressAllowed']; |
||
| 135 | } |
||
| 136 | return false; |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Returns if billing address is different as shipping address |
||
| 141 | * |
||
| 142 | * @return true |
||
| 143 | */ |
||
| 144 | public function hasDifferingDeliveryAddress() |
||
| 145 | { |
||
| 146 | return !$this->getQuote()->getShippingAddress()->getSameAsBilling(); |
||
|
0 ignored issues
–
show
|
|||
| 147 | } |
||
| 148 | |||
| 149 | /** |
||
| 150 | * Returns the customers birthday if known |
||
| 151 | * |
||
| 152 | * @return string |
||
| 153 | */ |
||
| 154 | public function getBirthday() |
||
| 155 | { |
||
| 156 | return $this->getQuote()->getCustomer()->getDob(); |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Returns a part of the birthday (day, month or year) |
||
| 161 | * |
||
| 162 | * @param string $sPart |
||
| 163 | * @return string |
||
| 164 | */ |
||
| 165 | public function getBirthdayPart($sPart) |
||
| 166 | { |
||
| 167 | $sBirthday = $this->getBirthday(); |
||
| 168 | if (!empty($sBirthday)) { |
||
| 169 | $timestamp = strtotime($sBirthday); |
||
| 170 | return date($sPart, $timestamp); |
||
| 171 | } |
||
| 172 | return ''; |
||
| 173 | } |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Returns if the telephone number has to be entered |
||
| 177 | * |
||
| 178 | * @return bool |
||
| 179 | */ |
||
| 180 | public function isTelephoneNeeded() |
||
| 181 | { |
||
| 182 | $billingAddress = $this->getQuote()->getBillingAddress(); |
||
| 183 | if ($billingAddress && !empty($billingAddress->getTelephone())) { |
||
| 184 | return false; |
||
| 185 | } |
||
| 186 | return true; |
||
| 187 | } |
||
| 188 | } |
||
| 189 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths