From 3e843f9eeb323625f7d50592554f5beacfca5139 Mon Sep 17 00:00:00 2001 From: woutse Date: Mon, 1 May 2023 12:12:29 +0200 Subject: [PATCH] Removed legacy --- Model/Paymentmethod/PaymentMethod.php | 339 -------------------------- 1 file changed, 339 deletions(-) diff --git a/Model/Paymentmethod/PaymentMethod.php b/Model/Paymentmethod/PaymentMethod.php index 41fe6e77..6bbfc043 100644 --- a/Model/Paymentmethod/PaymentMethod.php +++ b/Model/Paymentmethod/PaymentMethod.php @@ -465,345 +465,6 @@ public function startTransaction(Order $order) return $transaction->getRedirectUrl(); } - /** - * @param Order $order - * @param integer $multipleOrderAmount - * @param string $finishUrl - * @return \Paynl\Result\Transaction\Start - * @throws \Paynl\Error\Api - * @throws \Paynl\Error\Error - * @throws \Paynl\Error\Required\ApiToken - * @throws \Paynl\Error\Required\ServiceId - */ - protected function doStartTransactionOld(Order $order, $multipleOrderAmount = null, $finishUrl = null) - { - $this->paynlConfig->setStore($order->getStore()); - $this->paynlConfig->configureSDK(); - $additionalData = $order->getPayment()->getAdditionalInformation(); - $paymentOption = null; - $expireDate = null; - - if (isset($additionalData['kvknummer']) && is_numeric($additionalData['kvknummer'])) { - $kvknummer = $additionalData['kvknummer']; - } - if (isset($additionalData['vatnumber'])) { - $vatnumber = $additionalData['vatnumber']; - } - if (isset($additionalData['payment_option']) && is_numeric($additionalData['payment_option'])) { - $paymentOption = $additionalData['payment_option']; - } - if (isset($additionalData['valid_days']) && is_numeric($additionalData['valid_days'])) { - $expireDate = new \DateTime('+' . $additionalData['valid_days'] . ' days'); - } - - if ($this->paynlConfig->isAlwaysBaseCurrency()) { - $total = $order->getBaseGrandTotal(); - $currency = $order->getBaseCurrencyCode(); - } else { - $total = $order->getGrandTotal(); - $currency = $order->getOrderCurrencyCode(); - } - - if (!is_null($multipleOrderAmount)) { - $total = $multipleOrderAmount; - } - - $orderId = $order->getIncrementId(); - $quoteId = $order->getQuoteId(); - - $store = $order->getStore(); - $baseUrl = $store->getBaseUrl(); - - $returnUrl = $additionalData['returnUrl'] ?? $baseUrl . 'paynl/checkout/finish/?entityid=' . $order->getEntityId(); - $exchangeUrl = $additionalData['exchangeUrl'] ?? $baseUrl . 'paynl/checkout/exchange/'; - - if (!empty($finishUrl)) { - $returnUrl = $finishUrl; - } - - $paymentOptionId = $this->getPaymentOptionId(); - - $arrBillingAddress = $order->getBillingAddress(); - if ($arrBillingAddress) { - $arrBillingAddress = $arrBillingAddress->toArray(); - - $enduser = [ - 'initials' => $arrBillingAddress['firstname'], - 'lastName' => $arrBillingAddress['lastname'], - 'phoneNumber' => $arrBillingAddress['telephone'], - 'emailAddress' => $arrBillingAddress['email'], - ]; - - if (isset($additionalData['dob'])) { - $enduser['dob'] = $additionalData['dob']; - } - - if (isset($additionalData['gender'])) { - $enduser['gender'] = $additionalData['gender']; - } - $enduser['gender'] = $this->genderConversion((empty($enduser['gender'])) ? $order->getCustomerGender($order) : $enduser['gender']); - - if (!empty($arrBillingAddress['company'])) { - $enduser['company']['name'] = $arrBillingAddress['company']; - } - - if (!empty($arrBillingAddress['country_id'])) { - $enduser['company']['countryCode'] = $arrBillingAddress['country_id']; - } - - if (!empty($kvknummer)) { - $enduser['company']['cocNumber'] = $kvknummer; - } - - if (!empty($arrBillingAddress['vat_id'])) { - $enduser['company']['vatNumber'] = $arrBillingAddress['vat_id']; - } elseif (!empty($vatnumber)) { - $enduser['company']['vatNumber'] = $vatnumber; - } - - $invoiceAddress = [ - 'initials' => $arrBillingAddress['firstname'], - 'lastName' => $arrBillingAddress['lastname'], - ]; - - $arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']); - $invoiceAddress['streetName'] = $arrAddress[0]; - $invoiceAddress['houseNumber'] = $arrAddress[1]; - $invoiceAddress['zipCode'] = $arrBillingAddress['postcode']; - $invoiceAddress['city'] = $arrBillingAddress['city']; - $invoiceAddress['country'] = $arrBillingAddress['country_id']; - - if (!empty($arrShippingAddress['vat_id'])) { - $enduser['company']['vatNumber'] = $arrShippingAddress['vat_id']; - } - } - - $arrShippingAddress = $order->getShippingAddress(); - if (!empty($arrShippingAddress)) { - $arrShippingAddress = $arrShippingAddress->toArray(); - - if ($this->useBillingAddressInstorePickup() && class_exists('InStorePickup')) { - if ($order->getShippingMethod() === InStorePickup::DELIVERY_METHOD) { - $arrBillingAddress = $order->getBillingAddress(); - if (!empty($arrBillingAddress)) { - $arrShippingAddress = $arrBillingAddress->toArray(); - } - } - } - - $shippingAddress = [ - 'initials' => $arrShippingAddress['firstname'], - 'lastName' => $arrShippingAddress['lastname'], - ]; - $arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']); - $shippingAddress['streetName'] = $arrAddress2[0]; - $shippingAddress['houseNumber'] = $arrAddress2[1]; - $shippingAddress['zipCode'] = $arrShippingAddress['postcode']; - $shippingAddress['city'] = $arrShippingAddress['city']; - $shippingAddress['country'] = $arrShippingAddress['country_id']; - } - - $prefix = $this->_scopeConfig->getValue('payment/paynl/order_description_prefix', 'store'); - $description = !empty($prefix) ? $prefix . $orderId : $orderId; - - $data = [ - 'amount' => $total, - 'returnUrl' => $returnUrl, - 'paymentMethod' => $paymentOptionId, - 'language' => $this->paynlConfig->getLanguage(), - 'bank' => $paymentOption, - 'expireDate' => $expireDate, - 'orderNumber' => $orderId, - 'description' => $description, - 'extra1' => $orderId, - 'extra2' => $quoteId, - 'extra3' => $order->getEntityId(), - 'transferData' => $this->getTransferData(), - 'exchangeUrl' => $exchangeUrl, - 'currency' => $currency, - 'object' => $this->getVersion(), - ]; - if (isset($shippingAddress)) { - $data['address'] = $shippingAddress; - } - if (isset($invoiceAddress)) { - $data['invoiceAddress'] = $invoiceAddress; - } - if (isset($enduser)) { - $data['enduser'] = $enduser; - } - $arrProducts = []; - $arrWEEETax = []; - $items = $order->getAllVisibleItems(); - foreach ($items as $item) { - $arrItem = $item->toArray(); - if ($arrItem['price_incl_tax'] != null) { - // taxamount is not valid, because on discount it returns the taxamount after discount - $taxAmount = $arrItem['price_incl_tax'] - $arrItem['price']; - $price = $arrItem['price_incl_tax']; - - if ($this->paynlConfig->isAlwaysBaseCurrency()) { - $taxAmount = $arrItem['base_price_incl_tax'] - $arrItem['base_price']; - $price = $arrItem['base_price_incl_tax']; - } - - $productId = $arrItem['product_id']; - if ($this->paynlConfig->useSkuId()) { - $productId = $arrItem['sku']; - } - - $product = [ - 'id' => $productId, - 'name' => $arrItem['name'], - 'price' => $price, - 'qty' => $arrItem['qty_ordered'], - 'tax' => $taxAmount, - 'type' => \Paynl\Transaction::PRODUCT_TYPE_ARTICLE, - ]; - - # Product id's must be unique. Combinations of a "Configurable products" share the same product id. - # Each combination of a "configurable product" can be represented by a "simple product". - # The first and only child of the "configurable product" is the "simple product", or combination, chosen by the customer. - # Grab it and replace the product id to guarantee product id uniqueness. - if (isset($arrItem['product_type']) && $arrItem['product_type'] === Configurable::TYPE_CODE) { - $children = $item->getChildrenItems(); - $child = array_shift($children); - - if (!empty($child) && $child instanceof \Magento\Sales\Model\Order\Item && method_exists($child, 'getProductId')) { - $productIdChild = $child->getProductId(); - if ($this->paynlConfig->useSkuId() && method_exists($child, 'getSku')) { - $productIdChild = $child->getSku(); - } - $product['id'] = $productIdChild; - } - } - - $arrProducts[] = $product; - - # WEEE - if (!empty($arrItem['weee_tax_applied'])) { - $weeeArr = json_decode($arrItem['weee_tax_applied']); - if (is_array($weeeArr)) { - foreach ($weeeArr as $weee) { - if (!empty($weee) && is_object($weee)) { - $weee_title = $weee->title; - $weee_price = $weee->row_amount_incl_tax; - $weee_taxAmount = $weee->row_amount_incl_tax - $weee->row_amount; - - if ($this->paynlConfig->isAlwaysBaseCurrency()) { - $weee_price = $weee->base_row_amount_incl_tax; - $weee_taxAmount = $weee->base_row_amount_incl_tax - $weee->base_row_amount; - } - - if (isset($arrWEEETax[$weee_title])) { - $arrWEEETax[$weee_title]['price'] += $weee_price; - $arrWEEETax[$weee_title]['tax'] += $weee_taxAmount; - } else { - $arrWEEETax[$weee_title] = array( - 'id' => 'weee', - 'name' => $weee_title, - 'price' => $weee_price, - 'tax' => $weee_taxAmount, - 'qty' => 1, - 'type' => \Paynl\Transaction::PRODUCT_TYPE_HANDLING, - ); - } - } - } - } - } - } - } - - //shipping - $shippingCost = $order->getShippingInclTax(); - $shippingTax = $order->getShippingTaxAmount(); - - if ($this->paynlConfig->isAlwaysBaseCurrency()) { - $shippingCost = $order->getBaseShippingInclTax(); - $shippingTax = $order->getBaseShippingTaxAmount(); - } - - $shippingDescription = $order->getShippingDescription(); - - if ($shippingCost != 0) { - $arrProducts[] = [ - 'id' => 'shipping', - 'name' => empty($shippingDescription) ? 'Shipping' : $shippingDescription, - 'price' => $shippingCost, - 'qty' => 1, - 'tax' => $shippingTax, - 'type' => \Paynl\Transaction::PRODUCT_TYPE_SHIPPING, - ]; - } - - // Gift Wrapping - $gwCost = $order->getGwPriceInclTax(); - $gwTax = $order->getGwTaxAmount(); - - if ($this->paynlConfig->isAlwaysBaseCurrency()) { - $gwCost = $order->getGwBasePriceInclTax(); - $gwTax = $order->getGwBaseTaxAmount(); - } - - if ($gwCost != 0) { - $arrProducts[] = [ - 'id' => $order->getGwId(), - 'name' => 'Gift Wrapping', - 'price' => $gwCost, - 'qty' => 1, - 'tax' => $gwTax, - 'type' => \Paynl\Transaction::PRODUCT_TYPE_HANDLING, - ]; - } - - // kortingen - $discount = $order->getDiscountAmount(); - $discountTax = $order->getDiscountTaxCompensationAmount() * -1; - - if ($this->paynlConfig->isAlwaysBaseCurrency()) { - $discount = $order->getBaseDiscountAmount(); - $discountTax = $order->getBaseDiscountTaxCompensationAmount() * -1; - } - - if ($this->paynlConfig->isSendDiscountTax() == 0) { - $discountTax = 0; - } - - $discountDescription = __('Discount'); - - if ($discount != 0) { - $arrProducts[] = [ - 'id' => 'discount', - 'name' => $discountDescription, - 'price' => $discount, - 'qty' => 1, - 'tax' => $discountTax, - 'type' => \Paynl\Transaction::PRODUCT_TYPE_DISCOUNT, - ]; - } - - if (!empty($arrWEEETax)) { - $arrProducts = array_merge($arrProducts, $arrWEEETax); - } - - $data['products'] = $arrProducts; - - if ($this->paynlConfig->isTestMode()) { - $data['testmode'] = 1; - } - $ipAddress = $order->getRemoteIp(); - //The ip address field in magento is too short, if the ip is invalid or ip is localhost get the ip myself - if (!filter_var($ipAddress, FILTER_VALIDATE_IP) || $ipAddress == '127.0.0.1') { - $ipAddress = \Paynl\Helper::getIp(); - } - $data['ipaddress'] = $ipAddress; - - $transaction = \Paynl\Transaction::start($data); - - return $transaction; - } - /** * @return integer */