/**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\ItemTransfer $currentItemTransfer
  * @param \Generated\Shared\Transfer\ClauseTransfer $clauseTransfer
  *
  * @return bool
  */
 public function isSatisfiedBy(QuoteTransfer $quoteTransfer, ItemTransfer $currentItemTransfer, ClauseTransfer $clauseTransfer)
 {
     if (!$quoteTransfer->getTotals()) {
         return false;
     }
     $this->moneyValueConverter->convertDecimalToCent($clauseTransfer);
     return $this->comparators->compare($clauseTransfer, $quoteTransfer->getTotals()->getSubtotal());
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  *
  * @return void
  */
 public function recalculate(QuoteTransfer $quoteTransfer)
 {
     $quoteTransfer->requireTotals();
     $grandTotal = $quoteTransfer->getTotals()->getGrandTotal();
     $discountTotal = $quoteTransfer->getTotals()->getDiscountTotal();
     $grandTotal = $this->subtractDiscount($discountTotal, $grandTotal);
     $quoteTransfer->getTotals()->setGrandTotal($grandTotal);
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  *
  * @return int
  */
 protected function getCalculatedGrandTotal(QuoteTransfer $quoteTransfer)
 {
     $quoteTransfer->getTotals()->requireSubtotal();
     $subTotal = $quoteTransfer->getTotals()->getSubtotal();
     $expensesTotal = $quoteTransfer->getTotals()->getExpenseTotal();
     $grandTotal = $subTotal + $expensesTotal;
     return $grandTotal;
 }
Exemple #4
0
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param int $taxAmount
  *
  * @return void
  */
 protected function setTaxTotals(QuoteTransfer $quoteTransfer, $taxAmount)
 {
     $taxTotalTransfer = new TaxTotalTransfer();
     $taxAmount = (int) round($taxAmount);
     $taxTotalTransfer->setAmount($taxAmount);
     $quoteTransfer->getTotals()->setTaxTotal($taxTotalTransfer);
 }
Exemple #5
0
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  *
  * @return array
  */
 public function buildPreCheckRequest(QuoteTransfer $quoteTransfer)
 {
     $payolutionTransfer = $quoteTransfer->getPayment()->getPayolution();
     $addressTransfer = $payolutionTransfer->getAddress();
     $requestData = $this->getBaseTransactionRequest($quoteTransfer->getTotals()->getGrandTotal(), $payolutionTransfer->getCurrencyIso3Code());
     $this->addRequestData($requestData, [ApiConstants::PAYMENT_CODE => ApiConstants::PAYMENT_CODE_PRE_CHECK, ApiConstants::TRANSACTION_CHANNEL => $this->config->getTransactionChannelPreCheck(), ApiConstants::NAME_GIVEN => $addressTransfer->getFirstName(), ApiConstants::NAME_FAMILY => $addressTransfer->getLastName(), ApiConstants::NAME_TITLE => $addressTransfer->getSalutation(), ApiConstants::NAME_SEX => $this->mapGender($payolutionTransfer->getGender()), ApiConstants::NAME_BIRTHDATE => $payolutionTransfer->getDateOfBirth(), ApiConstants::ADDRESS_STREET => $this->formatAddress($addressTransfer), ApiConstants::ADDRESS_ZIP => $addressTransfer->getZipCode(), ApiConstants::ADDRESS_CITY => $addressTransfer->getCity(), ApiConstants::ADDRESS_COUNTRY => $addressTransfer->getIso2Code(), ApiConstants::CONTACT_EMAIL => $payolutionTransfer->getEmail(), ApiConstants::CONTACT_PHONE => $addressTransfer->getPhone(), ApiConstants::CONTACT_MOBILE => $addressTransfer->getCellPhone(), ApiConstants::CONTACT_IP => $payolutionTransfer->getClientIp(), ApiConstants::CRITERION_PRE_CHECK => 'TRUE', ApiConstants::CRITERION_CUSTOMER_LANGUAGE => $payolutionTransfer->getLanguageIso2Code(), ApiConstants::CRITERION_CALCULATION_ID => $payolutionTransfer->getInstallmentCalculationId(), ApiConstants::CRITERION_INSTALLMENT_AMOUNT => $this->getCurrencyManager()->convertCentToDecimal($payolutionTransfer->getInstallmentAmount()), ApiConstants::CRITERION_DURATION => $payolutionTransfer->getInstallmentDuration(), ApiConstants::CRITERION_ACCOUNT_HOLDER => $payolutionTransfer->getBankAccountHolder(), ApiConstants::CRITERION_ACCOUNT_BIC => $payolutionTransfer->getBankAccountBic(), ApiConstants::CRITERION_ACCOUNT_IBAN => $payolutionTransfer->getBankAccountIban(), ApiConstants::CRITERION_ACCOUNT_COUNTRY => $addressTransfer->getIso2Code()]);
     return $requestData;
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
  *
  * @return \Generated\Shared\Transfer\CheckoutResponseTransfer
  */
 public function checkCondition(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer)
 {
     if ($quoteTransfer->getTotals()->getGrandTotal() === 0) {
         $quoteTransfer->getPayment()->setPaymentMethod(ZeroPaymentConstants::PAYMENT_METHOD_ZERO_PAYMENT);
         $quoteTransfer->getPayment()->setPaymentSelection(ZeroPaymentConstants::PAYMENT_METHOD_ZERO_PAYMENT);
         $quoteTransfer->getPayment()->setPaymentProvider(ZeroPaymentConstants::PROVIDER_NAME);
     }
     return $checkoutResponseTransfer;
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\CheckoutResponseTransfer $checkoutResponseTransfer
  *
  * @return void
  */
 public function validateCheckoutGrandTotal(QuoteTransfer $quoteTransfer, CheckoutResponseTransfer $checkoutResponseTransfer)
 {
     $totalsBefore = $quoteTransfer->getTotals()->getGrandTotal();
     $this->stackExecutor->recalculate($quoteTransfer);
     $totalsAfter = $quoteTransfer->getTotals()->getGrandTotal();
     if ($totalsBefore !== $totalsAfter) {
         $error = $this->createCheckoutErrorTransfer();
         $error->setErrorCode(CheckoutConstants::ERROR_CODE_CART_AMOUNT_DIFFERENT)->setMessage('Checkout grand total changed.');
         $checkoutResponseTransfer->addError($error);
     }
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\PayolutionCalculationResponseTransfer $calculationResponseTransfer
  *
  * @return bool
  */
 protected function isInstallmentPaymentsStillValid(QuoteTransfer $quoteTransfer, PayolutionCalculationResponseTransfer $calculationResponseTransfer)
 {
     if ($quoteTransfer->getTotals() === null) {
         return false;
     }
     return $quoteTransfer->getTotals()->getHash() === $calculationResponseTransfer->getTotalsAmountHash();
 }
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  *
  * @return void
  */
 public function recalculate(QuoteTransfer $quoteTransfer)
 {
     $quoteTransfer->requireTotals();
     $quoteTransfer->getTotals()->setExpenseTotal($this->getCalculatedExpenseTotalAmount($quoteTransfer));
 }