public function startTransaction(Order $order, UrlInterface $url) { $config = new Config($this->_scopeConfig); $config->configureSDK(); $total = $order->getGrandTotal(); $items = $order->getAllVisibleItems(); $orderId = $order->getIncrementId(); $quoteId = $order->getQuoteId(); $currency = $order->getOrderCurrencyCode(); $returnUrl = $url->getUrl('paynl/checkout/finish/'); $exchangeUrl = $url->getUrl('paynl/checkout/exchange/'); $paymentOptionId = $this->getPaymentOptionId(); $arrBillingAddress = $order->getBillingAddress()->toArray(); $arrShippingAddress = $order->getShippingAddress()->toArray(); $enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']); $address = array(); $arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']); $address['streetName'] = $arrAddress[0]; $address['houseNumber'] = $arrAddress[1]; $address['zipCode'] = $arrBillingAddress['postcode']; $address['city'] = $arrBillingAddress['city']; $address['country'] = $arrBillingAddress['country_id']; $shippingAddress = array(); $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']; $data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra2' => $quoteId, 'exchangeUrl' => $exchangeUrl, 'currency' => $currency); $data['address'] = $address; $data['shippingAddress'] = $shippingAddress; $data['enduser'] = $enduser; $arrProducts = array(); foreach ($items as $item) { $arrItem = $item->toArray(); if ($arrItem['price_incl_tax'] != null) { $product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty_ordered'], 'tax' => $arrItem['tax_amount']); } $arrProducts[] = $product; } //shipping $shippingCost = $order->getShippingAddress()->getShippingInclTax(); $shippingTax = $order->getShippingAddress()->getShippingTaxAmount(); $shippingDescription = $order->getShippingAddress()->getShippingDescription(); $arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax); // kortingen $discount = $order->getSubtotal() - $order->getSubtotalWithDiscount(); if ($discount > 0) { $arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0); } $data['products'] = $arrProducts; if ($config->isTestMode()) { $data['testmode'] = 1; } $data['ipaddress'] = $order->getRemoteIp(); $transaction = \Paynl\Transaction::start($data); return $transaction->getRedirectUrl(); }
/** * Get RSS feed items * * @return array */ protected function getEntries() { /** @var $resourceModel \Magento\Sales\Model\Resource\Order\Rss\OrderStatus */ $resourceModel = $this->orderResourceFactory->create(); $results = $resourceModel->getAllCommentCollection($this->order->getId()); $entries = []; if ($results) { foreach ($results as $result) { $urlAppend = 'view'; $type = $result['entity_type_code']; if ($type && $type != 'order') { $urlAppend = $type; } $type = __(ucwords($type)); $title = __('Details for %1 #%2', $type, $result['increment_id']); $description = '<p>' . __('Notified Date: %1', $this->localeDate->formatDate($result['created_at'])) . '<br/>' . __('Comment: %1<br/>', $result['comment']) . '</p>'; $url = $this->urlBuilder->getUrl('sales/order/' . $urlAppend, ['order_id' => $this->order->getId()]); $entries[] = ['title' => $title, 'link' => $url, 'description' => $description]; } } $title = __('Order #%1 created at %2', $this->order->getIncrementId(), $this->localeDate->formatDate($this->order->getCreatedAt())); $url = $this->urlBuilder->getUrl('sales/order/view', ['order_id' => $this->order->getId()]); $description = '<p>' . __('Current Status: %1<br/>', $this->order->getStatusLabel()) . __('Total: %1<br/>', $this->order->formatPrice($this->order->getGrandTotal())) . '</p>'; $entries[] = ['title' => $title, 'link' => $url, 'description' => $description]; return ['entries' => $entries]; }
/** * @param \Magento\Sales\Model\Order $order * @return array */ public function getBasicData(\Magento\Sales\Model\Order $order) { $incrementId = $order->getIncrementId(); $billingAddress = $order->getBillingAddress(); $data = ['amount' => $order->getGrandTotal() * 100, 'desc' => __('Order # %1', [$incrementId]), 'first_name' => $billingAddress->getFirstname(), 'last_name' => $billingAddress->getLastname(), 'email' => $order->getCustomerEmail(), 'session_id' => $this->extOrderIdHelper->generate($order), 'order_id' => $incrementId]; $paytype = $this->session->getPaytype(); if ($paytype) { $data['pay_type'] = $paytype; $this->session->setPaytype(null); } return $data; }
/** * @param Order $order * @return array */ public function getCoinGateRequest(Order $order) { $token = substr(md5(rand()), 0, 32); $payment = $order->getPayment(); $payment->setAdditionalInformation('coingate_order_token', $token); $payment->save(); $description = array(); foreach ($order->getAllItems() as $item) { $description[] = number_format($item->getQtyOrdered(), 0) . ' × ' . $item->getName(); } $params = array('order_id' => $order->getIncrementId(), 'price' => number_format($order->getGrandTotal(), 2, '.', ''), 'currency' => $order->getOrderCurrencyCode(), 'receive_currency' => $this->getConfigData('receive_currency'), 'callback_url' => $this->urlBuilder->getUrl('coingate/payment/callback') . '?token=' . $payment->getAdditionalInformation('coingate_order_token'), 'cancel_url' => $this->urlBuilder->getUrl('checkout/onepage/failure'), 'success_url' => $this->urlBuilder->getUrl('checkout/onepage/success'), 'title' => $this->storeManager->getWebsite()->getName(), 'description' => join($description, ', ')); $this->coingate->createOrder($params); if ($this->coingate->success) { return array('status' => true, 'payment_url' => $this->coingate->response['payment_url']); } else { return array('status' => false); } }
/** * @param \Magento\Sales\Model\Order $order * @return array */ public function getBasicData(\Magento\Sales\Model\Order $order) { $incrementId = $order->getIncrementId(); return ['currencyCode' => $order->getOrderCurrencyCode(), 'totalAmount' => $order->getGrandTotal() * 100, 'extOrderId' => $this->extOrderIdHelper->generate($order), 'description' => __('Order # %1', [$incrementId])]; }
protected function _processOrder(\Magento\Sales\Model\Order $order, $response) { //$response = $this->getResponse(); $payment = $order->getPayment(); //$payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0); //TODO: add validation for request data try { $errors = array(); //$this->readConfig(); //$order = Mage::getModel("sales/order")->load($this->getOrderId($answer)); //$order = Mage::getModel("sales/order")->loadByIncrementId($this->getOrderId($answer)); $hashArray = array($response["OutSum"], $response["InvId"], $this->getConfigData('pass_word_2')); $hashCurrent = strtoupper(md5(implode(":", $hashArray))); $correctHash = strcmp($hashCurrent, strtoupper($response['SignatureValue'])) == 0; if (!$correctHash) { $errors[] = "Incorrect HASH (need:" . $hashCurrent . ", got:" . strtoupper($response['SignatureValue']) . ") - fraud data or wrong secret Key"; $errors[] = "Maybe success payment"; } /** * @var $order Mage_Sales_Model_Order */ // if ($this->_transferCurrency != $order->getOrderCurrencyCode()) { // $outSum = round( // $order->getBaseCurrency()->convert($order->getBaseGrandTotal(), $this->_transferCurrency), // 2 // ); // } else { $outSum = round($order->getGrandTotal(), 2); // } if ($outSum != $response["OutSum"]) { $errors[] = "Incorrect Amount: " . $response["OutSum"] . " (need: " . $outSum . ")"; } // if (count($errors) > 0) { // return $errors; // } //return (bool)$correctHash; //$payment->registerCaptureNotification($payment->getBaseAmountAuthorized()); if (!$correctHash) { $payment->setTransactionId($response["InvId"])->setIsTransactionClosed(0); $order->setStatus(Order::STATE_PAYMENT_REVIEW); $order->save(); return "Ok" . $response["InvId"]; } // } catch (Exception $e) { return array("Internal error:" . $e->getMessage()); } }
/** * Retrieve order item value by key * * @param \Magento\Sales\Model\Order $order * @param string $key * @return string * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getOrderItemValue(\Magento\Sales\Model\Order $order, $key) { $escape = true; switch ($key) { case 'order_increment_id': $value = $order->getIncrementId(); break; case 'created_at': $value = $this->formatDate($order->getCreatedAt(), \IntlDateFormatter::SHORT, true); break; case 'shipping_address': $value = $order->getShippingAddress() ? $this->escapeHtml($order->getShippingAddress()->getName()) : __('N/A'); break; case 'order_total': $value = $order->formatPrice($order->getGrandTotal()); $escape = false; break; case 'status_label': $value = $order->getStatusLabel(); break; case 'view_url': $value = $this->getUrl('sales/order/view', ['order_id' => $order->getId()]); break; default: $value = $order->getData($key) ? $order->getData($key) : __('N/A'); break; } return $escape ? $this->escapeHtml($value) : $value; }
/** * @param $order Order * @return Purchase */ protected function makePurchase(Order $order) { // Get all of the purchased products $items = $order->getAllItems(); $purchase = SignifydModel::Make("\\Signifyd\\Models\\Purchase"); $purchase->orderChannel = "WEB"; $purchase->products = array(); foreach ($items as $item) { $purchase->products[] = $this->makeProduct($item); } $purchase->totalPrice = $order->getGrandTotal(); $purchase->currency = $order->getOrderCurrencyCode(); $purchase->orderId = $order->getIncrementId(); $purchase->paymentGateway = $order->getPayment()->getMethod(); $purchase->shippingPrice = floatval($order->getShippingAmount()); $purchase->avsResponseCode = $order->getPayment()->getCcAvsStatus(); $purchase->cvvResponseCode = $order->getPayment()->getCcSecureVerify(); $purchase->createdAt = date('c', strtotime($order->getCreatedAt())); $purchase->browserIpAddress = $this->getIPAddress($order); return $purchase; }
/** * @param Order $order */ public function validateKhipuCallback(Order $order) { try { if (!$order || !$order->getIncrementId()) { throw new \Exception('Order #' . $_REQUEST['order_id'] . ' does not exists'); } $payment = $order->getPayment(); $notificationToken = isset($_POST['notification_token']) ? $_POST['notification_token'] : ''; if ($notificationToken == '') { throw new \Exception('Invalid notification token.'); } $configuration = new \Khipu\Configuration(); $configuration->setSecret($this->getConfigData('merchant_secret')); $configuration->setReceiverId($this->getConfigData('merchant_id')); $configuration->setPlatform('magento2-khipu', Payment::KHIPU_MAGENTO_VERSION); $client = new \Khipu\ApiClient($configuration); $payments = new \Khipu\Client\PaymentsApi($client); try { $paymentResponse = $payments->paymentsGet($notificationToken); } catch (\Khipu\ApiException $exception) { throw new \Exception(print_r($exception->getResponseObject(), TRUE)); } if ($paymentResponse->getReceiverId() != $this->getConfigData('merchant_id')) { throw new \Exception('Invalid receiver id'); } if ($paymentResponse->getTransactionId() != $payment->getAdditionalInformation('khipu_order_token')) { throw new \Exception('Invalid transaction id'); } if ($paymentResponse->getStatus() != 'done') { throw new \Exception('Payment not done'); } if ($paymentResponse->getAmount() != number_format($order->getGrandTotal(), $this->getDecimalPlaces($order->getOrderCurrencyCode()), '.', '')) { throw new \Exception('Amount mismatch'); } if ($paymentResponse->getCurrency() != $order->getOrderCurrencyCode()) { throw new \Exception('Currency mismatch'); } $order->setState(Order::STATE_PROCESSING, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))->save(); } catch (\Exception $e) { exit('Error occurred: ' . $e); } }
/** * @param bool $manualReviewComment * @param bool $createInvoice * @throws Exception */ protected function _setPaymentAuthorized($manualReviewComment = true, $createInvoice = false) { $this->_adyenLogger->addAdyenNotificationCronjob('Set order to authorised'); // if full amount is captured create invoice $currency = $this->_order->getOrderCurrencyCode(); $amount = $this->_value; $orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency); // create invoice for the capture notification if you are on manual capture if ($createInvoice == true && $amount == $orderAmount) { $this->_adyenLogger->addAdyenNotificationCronjob('amount notification:' . $amount . ' amount order:' . $orderAmount); $this->_createInvoice(); } // if you have capture on shipment enabled don't set update the status of the payment $captureOnShipment = $this->_getConfigData('capture_on_shipment', 'adyen_abstract', $this->_order->getStoreId()); if (!$captureOnShipment) { $status = $this->_getConfigData('payment_authorized', 'adyen_abstract', $this->_order->getStoreId()); } // virtual order can have different status if ($this->_order->getIsVirtual()) { $this->_adyenLogger->addAdyenNotificationCronjob('Product is a virtual product'); $virtualStatus = $this->_getConfigData('payment_authorized_virtual'); if ($virtualStatus != "") { $status = $virtualStatus; } } // check for boleto if payment is totally paid if ($this->_paymentMethodCode() == "adyen_boleto") { // check if paid amount is the same as orginal amount $orginalAmount = $this->_boletoOriginalAmount; $paidAmount = $this->_boletoPaidAmount; if ($orginalAmount != $paidAmount) { // not the full amount is paid. Check if it is underpaid or overpaid // strip the BRL of the string $orginalAmount = str_replace("BRL", "", $orginalAmount); $orginalAmount = floatval(trim($orginalAmount)); $paidAmount = str_replace("BRL", "", $paidAmount); $paidAmount = floatval(trim($paidAmount)); if ($paidAmount > $orginalAmount) { $overpaidStatus = $this->_getConfigData('order_overpaid_status', 'adyen_boleto'); // check if there is selected a status if not fall back to the default $status = !empty($overpaidStatus) ? $overpaidStatus : $status; } else { $underpaidStatus = $this->_getConfigData('order_underpaid_status', 'adyen_boleto'); // check if there is selected a status if not fall back to the default $status = !empty($underpaidStatus) ? $underpaidStatus : $status; } } } $comment = "Adyen Payment Successfully completed"; // if manual review is true use the manual review status if this is set if ($manualReviewComment == true && $this->_fraudManualReview) { // check if different status is selected $fraudManualReviewStatus = $this->_getFraudManualReviewStatus(); if ($fraudManualReviewStatus != "") { $status = $fraudManualReviewStatus; $comment = "Adyen Payment is in Manual Review check the Adyen platform"; } } $status = !empty($status) ? $status : $this->_order->getStatus(); $this->_order->addStatusHistoryComment(__($comment), $status); $this->_adyenLogger->addAdyenNotificationCronjob('Order status is changed to authorised status, status is ' . $status); }
/** * @param \Magento\Sales\Model\Order $order * @return string */ protected function _getReceiptOrderLines(\Magento\Sales\Model\Order $order) { $myReceiptOrderLines = ""; $currency = $order->getOrderCurrencyCode(); $formattedAmountValue = $this->_currencyFactory->create()->format($order->getGrandTotal(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $taxAmount = $order->getTaxAmount(); $formattedTaxAmount = $this->_currencyFactory->create()->format($taxAmount, ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $myReceiptOrderLines .= "---||C\n" . "====== YOUR ORDER DETAILS ======||CB\n" . "---||C\n" . " No. Description |Piece Subtotal|\n"; foreach ($order->getItemsCollection() as $item) { //skip dummies if ($item->isDummy()) { continue; } $singlePriceFormat = $this->_currencyFactory->create()->format($item->getPriceInclTax(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $itemAmount = $item->getPriceInclTax() * (int) $item->getQtyOrdered(); $itemAmountFormat = $this->_currencyFactory->create()->format($itemAmount, ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $myReceiptOrderLines .= " " . (int) $item->getQtyOrdered() . " " . trim(substr($item->getName(), 0, 25)) . "| " . $currency . " " . $singlePriceFormat . " " . $currency . " " . $itemAmountFormat . "|\n"; } //discount cost if ($order->getDiscountAmount() > 0 || $order->getDiscountAmount() < 0) { $discountAmountFormat = $this->_currencyFactory->create()->format($order->getDiscountAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $myReceiptOrderLines .= " " . 1 . " " . $this->__('Total Discount') . "| " . $currency . " " . $discountAmountFormat . "|\n"; } //shipping cost if ($order->getShippingAmount() > 0 || $order->getShippingTaxAmount() > 0) { $shippingAmountFormat = $this->_currencyFactory->create()->format($order->getShippingAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $myReceiptOrderLines .= " " . 1 . " " . $order->getShippingDescription() . "| " . $currency . " " . $shippingAmountFormat . "|\n"; } if ($order->getPaymentFeeAmount() > 0) { $paymentFeeAmount = $this->_currencyFactory->create()->format($order->getPaymentFeeAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false); $myReceiptOrderLines .= " " . 1 . " " . $this->__('Payment Fee') . "| " . $currency . " " . $paymentFeeAmount . "|\n"; } $myReceiptOrderLines .= "|--------|\n" . "|Order Total: " . $currency . " " . $formattedAmountValue . "|B\n" . "|Tax: " . $currency . " " . $formattedTaxAmount . "|B\n" . "||C\n"; /* * New header for card details section! * Default location is After Header so simply add to Order Details as separator */ $myReceiptOrderLines .= "---||C\n" . "====== YOUR PAYMENT DETAILS ======||CB\n" . "---||C\n"; return $myReceiptOrderLines; }
protected function _checkIpnRequest() { $request = $this->getRequest()->getPost(); $this->_order = $this->_getOrder($request['ordernumber']); // check order ID $orderId = $this->_order->getRealOrderId(); if ($orderId != $request['ordernumber']) { throw new \Magento\Framework\Exception\LocalizedException(__('Order not found')); } $this->_paymentInst = $this->_order->getPayment()->getMethodInstance(); // check merchant ID if ($this->_paymentInst->getConfigData('merchant') != $request['merchant_id']) { throw new \Magento\Framework\Exception\LocalizedException(__('Invalid merchant ID: ' . $request['merchant_id'])); } // failed operation if ('AS000' != $request['responsecode']) { throw new \Magento\Framework\Exception\LocalizedException($this->_paymentInst->getAssistErrors($request['responsecode'])); } // wrong test mode if ($this->_paymentInst->getConfigData('mode') != $request['testmode']) { throw new \Magento\Framework\Exception\LocalizedException(__('Wrong Test Mode.')); } // accept only Approve operations, cancel and capture are processed real time if ('100' != $request['operationtype']) { throw new \Magento\Framework\Exception\LocalizedException(__('Wrong Operation Type. Only Approve is supported by IPN.')); } // check currency if ($this->_order->getBaseCurrencyCode() != $request['ordercurrency']) { throw new \Magento\Framework\Exception\LocalizedException(__('Invalid currency: ' . $request['ordercurrency'])); } // check amount $orderAmount = number_format($this->_order->getGrandTotal(), 2, '.', ''); if ($orderAmount != $request['orderamount']) { throw new \Magento\Framework\Exception\LocalizedException(__('Invalid amount: ' . $request['orderamount'])); } /* if (Mage::helper('assist')->isResponseSecuredMd5()) { $x = array( $this->_paymentInst->getConfigData('merchant'), $request['ordernumber'], $request['amount'], $request['currency'], $request['orderstate'] ); if ($this->_paymentInst->secreyKey(implode("", $x)) != $request['checkvalue']) { Mage::throwException('Incorrect Checkvalue: ' . $request['checkvalue']); } } if (Mage::helper('assist')->isResponseSecuredPgp()) { $y = implode("", array( $this->_paymentInst->getConfigData('merchant'), $request['ordernumber'], $request['amount'], $request['currency'], $request['orderstate'] )); $keyFile = Mage::getBaseDir('var') . DS . 'assist' . DS . $this->_paymentInst->getConfigData('assist_key'); if ($this->_paymentInst->sign($y, $keyFile) != $request['signature']) { Mage::throwException('Incorrect Signature.'); } } */ return $request; }
/** * @return array */ public function getFormFields() { $formFields = []; try { if ($this->_order->getPayment()) { $realOrderId = $this->_order->getRealOrderId(); $orderCurrencyCode = $this->_order->getOrderCurrencyCode(); $skinCode = trim($this->_adyenHelper->getAdyenHppConfigData('skin_code')); $amount = $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $orderCurrencyCode); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account')); $shopperEmail = $this->_order->getCustomerEmail(); $customerId = $this->_order->getCustomerId(); $shopperIP = $this->_order->getRemoteIp(); $browserInfo = $_SERVER['HTTP_USER_AGENT']; $deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days'); $shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale')); $shopperLocale = !empty($shopperLocale) ? $shopperLocale : $this->_resolver->getLocale(); $countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code')); $countryCode = !empty($countryCode) ? $countryCode : false; // if directory lookup is enabled use the billingadress as countrycode if ($countryCode == false) { if ($this->_order->getBillingAddress() && $this->_order->getBillingAddress()->getCountryId() != "") { $countryCode = $this->_order->getBillingAddress()->getCountryId(); } } $formFields = []; $formFields['merchantAccount'] = $merchantAccount; $formFields['merchantReference'] = $realOrderId; $formFields['paymentAmount'] = (int) $amount; $formFields['currencyCode'] = $orderCurrencyCode; $formFields['shipBeforeDate'] = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("j") + $deliveryDays, date("Y"))); $formFields['skinCode'] = $skinCode; $formFields['shopperLocale'] = $shopperLocale; $formFields['countryCode'] = $countryCode; $formFields['shopperIP'] = $shopperIP; $formFields['browserInfo'] = $browserInfo; $formFields['sessionValidity'] = date(DATE_ATOM, mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y"))); $formFields['shopperEmail'] = $shopperEmail; // recurring $recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type')); $brandCode = $this->_order->getPayment()->getAdditionalInformation("brand_code"); // Paypal does not allow ONECLICK,RECURRING only RECURRING if ($brandCode == "paypal" && $recurringType == 'ONECLICK,RECURRING') { $recurringType = "RECURRING"; } $formFields['recurringContract'] = $recurringType; $formFields['shopperReference'] = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId; //blocked methods $formFields['blockedMethods'] = ""; $baseUrl = $this->_storeManager->getStore($this->getStore())->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK); $formFields['resURL'] = $baseUrl . 'adyen/process/result'; $hmacKey = $this->_adyenHelper->getHmac(); if ($brandCode) { $formFields['brandCode'] = $brandCode; } $issuerId = $this->_order->getPayment()->getAdditionalInformation("issuer_id"); if ($issuerId) { $formFields['issuerId'] = $issuerId; } $formFields = $this->setBillingAddressData($formFields); $formFields = $this->setShippingAddressData($formFields); $formFields = $this->setOpenInvoiceData($formFields); $formFields['shopper.gender'] = $this->getGenderText($this->_order->getCustomerGender()); $dob = $this->_order->getCustomerDob(); if ($dob) { $formFields['shopper.dateOfBirthDayOfMonth'] = trim($this->_getDate($dob, 'd')); $formFields['shopper.dateOfBirthMonth'] = trim($this->_getDate($dob, 'm')); $formFields['shopper.dateOfBirthYear'] = trim($this->_getDate($dob, 'Y')); } if ($this->_order->getPayment()->getAdditionalInformation(\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna") { // // needed for DE and AT $formFields['klarna.acceptPrivacyPolicy'] = 'true'; // don't allow editable shipping/delivery address $formFields['billingAddressType'] = "1"; $formFields['deliveryAddressType'] = "1"; // make setting to make this optional $adyFields['shopperType'] = "1"; } // Sort the array by key using SORT_STRING order ksort($formFields, SORT_STRING); // Generate the signing data string $signData = implode(":", array_map([$this, 'escapeString'], array_merge(array_keys($formFields), array_values($formFields)))); $merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true)); $formFields['merchantSig'] = $merchantSig; $this->_adyenLogger->addAdyenDebug(print_r($formFields, true)); } } catch (Exception $e) { // do nothing for now } return $formFields; }