public function fullApiRequest($payment) { $order = $payment->getOrder(); $amount = $order->getGrandTotal(); $customerEmail = $order->getCustomerEmail(); $shopperIp = $order->getRemoteIp(); $orderCurrencyCode = $order->getOrderCurrencyCode(); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account"); $request = array("action" => "Payment.authorise", "paymentRequest.merchantAccount" => $merchantAccount, "paymentRequest.amount.currency" => $orderCurrencyCode, "paymentRequest.amount.value" => $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode), "paymentRequest.reference" => $order->getIncrementId(), "paymentRequest.shopperIP" => $shopperIp, "paymentRequest.shopperEmail" => $customerEmail, "paymentRequest.shopperReference" => $order->getIncrementId(), "paymentRequest.fraudOffset" => "0", "paymentRequest.browserInfo.userAgent" => $_SERVER['HTTP_USER_AGENT'], "paymentRequest.browserInfo.acceptHeader" => $_SERVER['HTTP_ACCEPT']); $billingAddress = $order->getBillingAddress(); if ($billingAddress) { $addressArray = $this->_adyenHelper->getStreet($billingAddress); $requestBilling = array("paymentRequest.card.billingAddress.street" => $addressArray['name'], "paymentRequest.card.billingAddress.postalCode" => $billingAddress->getPostcode(), "paymentRequest.card.billingAddress.city" => $billingAddress->getCity(), "paymentRequest.card.billingAddress.houseNumberOrName" => $addressArray['house_number'], "paymentRequest.card.billingAddress.stateOrProvince" => $billingAddress->getRegionCode(), "paymentRequest.card.billingAddress.country" => $billingAddress->getCountryId()); $request = array_merge($request, $requestBilling); } $deliveryAddress = $order->getDeliveryAddress(); if ($deliveryAddress) { $addressArray = $this->_adyenHelper->getStreet($deliveryAddress); $requestDelivery = array("paymentRequest.card.deliveryAddress.street" => $addressArray['name'], "paymentRequest.card.deliveryAddress.postalCode" => $deliveryAddress->getPostcode(), "paymentRequest.card.deliveryAddress.city" => $deliveryAddress->getCity(), "paymentRequest.card.deliveryAddress.houseNumberOrName" => $addressArray['house_number'], "paymentRequest.card.deliveryAddress.stateOrProvince" => $deliveryAddress->getRegionCode(), "paymentRequest.card.deliveryAddress.country" => $deliveryAddress->getCountryId()); $request = array_merge($request, $requestDelivery); } // If cse is enabled add encrypted card date into request if ($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) { $request['paymentRequest.additionalData.card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data"); } else { $requestCreditCardDetails = array("paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(), "paymentRequest.card.expiryYear" => $payment->getCcExpYear(), "paymentRequest.card.holderName" => $payment->getCcOwner(), "paymentRequest.card.number" => $payment->getCcNumber(), "paymentRequest.card.cvc" => $payment->getCcCid()); $request = array_merge($request, $requestCreditCardDetails); } return $this->_apiRequest($request); }
/** * @param array $buildSubject * @return array */ public function build(array $buildSubject) { /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $order = $paymentDataObject->getOrder(); $payment = $paymentDataObject->getPayment(); $fullOrder = $payment->getOrder(); $currencyCode = $fullOrder->getOrderCurrencyCode(); $amount = $fullOrder->getGrandTotal(); $amount = ['currency' => $currencyCode, 'value' => $this->adyenHelper->formatAmount($amount, $currencyCode)]; return ["amount" => $amount, "reference" => $order->getOrderIncrementId(), "fraudOffset" => "0"]; }
/** * Create capture request * * @param array $buildSubject * @return array */ public function build(array $buildSubject) { /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject); $payment = $paymentDataObject->getPayment(); $pspReference = $payment->getCcTransId(); $currency = $payment->getOrder()->getOrderCurrencyCode(); //format the amount to minor units $amount = $this->adyenHelper->formatAmount($amount, $currency); $modificationAmount = ['currency' => $currency, 'value' => $amount]; return ["modificationAmount" => $modificationAmount, "reference" => $payment->getOrder()->getIncrementId(), "originalReference" => $pspReference]; }
/** * @param $store * @param $country * @return array */ protected function _fetchHppMethods($store, $country) { $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code'); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account'); if (!$skinCode || !$merchantAccount) { return []; } $adyFields = ["paymentAmount" => (int) $this->_adyenHelper->formatAmount($this->_getCurrentPaymentAmount(), $this->_getCurrentCurrencyCode($store)), "currencyCode" => $this->_getCurrentCurrencyCode($store), "merchantReference" => "Get Payment methods", "skinCode" => $skinCode, "merchantAccount" => $merchantAccount, "sessionValidity" => date(DATE_ATOM, mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y"))), "countryCode" => $this->_getCurrentCountryCode($store, $country), "shopperLocale" => $this->_getCurrentLocaleCode($store)]; $responseData = $this->_getDirectoryLookupResponse($adyFields, $store); $paymentMethods = []; if (isset($responseData['paymentMethods'])) { foreach ($responseData['paymentMethods'] as $paymentMethod) { $paymentMethodCode = $paymentMethod['brandCode']; $paymentMethod = $this->_fieldMapPaymentMethod($paymentMethod); // check if payment method is an openinvoice method $paymentMethod['isPaymentMethodOpenInvoiceMethod'] = $this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($paymentMethodCode); // add icon location in result if ($this->_adyenHelper->showLogos()) { $params = []; // use frontend area $params = array_merge(['area' => 'frontend', '_secure' => $this->_request->isSecure()], $params); $asset = $this->_assetRepo->createAsset('Adyen_Payment::images/logos/' . $paymentMethodCode . '.png', $params); $placeholder = $this->_assetSource->findSource($asset); $icon = null; if ($placeholder) { list($width, $height) = getimagesize($asset->getSourceFile()); $icon = ['url' => $asset->getUrl(), 'width' => $width, 'height' => $height]; } $paymentMethod['icon'] = $icon; } $paymentMethods[$paymentMethodCode] = $paymentMethod; } } return $paymentMethods; }
/** * @param $formFields * @return mixed */ protected function setOpenInvoiceData($formFields) { $count = 0; $currency = $this->_order->getOrderCurrencyCode(); foreach ($this->_order->getAllVisibleItems() as $item) { ++$count; $linename = "line" . $count; $formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currency; $formFields['openinvoicedata.' . $linename . '.description'] = str_replace("\n", '', trim($item->getName())); $formFields['openinvoicedata.' . $linename . '.itemAmount'] = $this->_adyenHelper->formatAmount($item->getPrice(), $currency); $formFields['openinvoicedata.' . $linename . '.itemVatAmount'] = $item->getTaxAmount() > 0 && $item->getPriceInclTax() > 0 ? $this->_adyenHelper->formatAmount($item->getPriceInclTax(), $currency) - $this->_adyenHelper->formatAmount($item->getPrice(), $currency) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency); // $product = $item->getProduct(); // Calculate vat percentage $percentageMinorUnits = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent()); $formFields['openinvoicedata.' . $linename . '.itemVatPercentage'] = $percentageMinorUnits; $formFields['openinvoicedata.' . $linename . '.numberOfItems'] = (int) $item->getQtyOrdered(); if ($this->_order->getPayment()->getAdditionalInformation(\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna") { $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High"; } else { $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None"; } } $formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference']; $formFields['openinvoicedata.numberOfLines'] = $count; return $formFields; }
public function getFormFields() { $paymentInfo = $this->getInfoInstance(); $order = $paymentInfo->getOrder(); $realOrderId = $order->getRealOrderId(); $orderCurrencyCode = $order->getOrderCurrencyCode(); $skinCode = trim($this->getConfigData('skin_code')); $amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account')); $shopperEmail = $order->getCustomerEmail(); $customerId = $order->getCustomerId(); $shopperIP = $order->getRemoteIp(); $browserInfo = $_SERVER['HTTP_USER_AGENT']; $deliveryDays = $this->getConfigData('delivery_days'); $shopperLocale = trim($this->getConfigData('shopper_locale')); $shopperLocale = !empty($shopperLocale) ? $shopperLocale : $this->resolver->getLocale(); $countryCode = trim($this->getConfigData('country_code')); $countryCode = !empty($countryCode) ? $countryCode : false; // if directory lookup is enabled use the billingadress as countrycode if ($countryCode == false) { if ($order->getBillingAddress() && $order->getBillingAddress()->getCountryId() != "") { $countryCode = $order->getBillingAddress()->getCountryId(); } } $formFields = array(); $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')); $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(); $brandCode = $this->getInfoInstance()->getCcType(); if ($brandCode) { $formFields['brandCode'] = $brandCode; } // Sort the array by key using SORT_STRING order ksort($formFields, SORT_STRING); // Generate the signing data string $signData = implode(":", array_map(array($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->info(print_r($formFields, true)); return $formFields; }
protected function _fetchHppMethods($store) { $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code'); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData('merchant_account'); if (!$skinCode || !$merchantAccount) { return array(); } $adyFields = array("paymentAmount" => (int) $this->_adyenHelper->formatAmount($this->_getCurrentPaymentAmount(), $this->_getCurrentCurrencyCode($store)), "currencyCode" => $this->_getCurrentCurrencyCode($store), "merchantReference" => "Get Payment methods", "skinCode" => $skinCode, "merchantAccount" => $merchantAccount, "sessionValidity" => date(DATE_ATOM, mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y"))), "countryCode" => $this->_getCurrentCountryCode($store), "shopperLocale" => $this->_getCurrentLocaleCode($store)); $responseData = $this->_getDirectoryLookupResponse($adyFields, $store); $paymentMethods = array(); if (isset($responseData['paymentMethods'])) { foreach ($responseData['paymentMethods'] as $paymentMethod) { $paymentMethod = $this->_fieldMapPaymentMethod($paymentMethod); $paymentMethodCode = $paymentMethod['brandCode']; $paymentMethod = $this->_fieldMapPaymentMethod($paymentMethod); $paymentMethods[$paymentMethodCode] = $paymentMethod; } } return $paymentMethods; }
/** * @return string */ public function getLaunchLink() { $launchlink = ""; try { if ($this->_order->getPayment()) { $realOrderId = $this->_order->getRealOrderId(); $orderCurrencyCode = $this->_order->getOrderCurrencyCode(); $amount = $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $orderCurrencyCode); $shopperEmail = $this->_order->getCustomerEmail(); $customerId = $this->_order->getCustomerId(); $callbackUrl = $this->_urlBuilder->getUrl('adyen/process/resultpos', ['_secure' => $this->_getRequest()->isSecure()]); $addReceiptOrderLines = $this->_adyenHelper->getAdyenPosConfigData("add_receipt_order_lines"); $recurringContract = $this->_adyenHelper->getAdyenPosConfigData('recurring_type'); $currencyCode = $orderCurrencyCode; $paymentAmount = $amount; $merchantReference = $realOrderId; $shopperReference = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId; $shopperEmail = $shopperEmail; $recurringParams = ""; if ($this->_order->getPayment()->getAdditionalInformation("store_cc") != "") { $recurringParams = "&recurringContract=" . urlencode($recurringContract) . "&shopperReference=" . urlencode($shopperReference) . "&shopperEmail=" . urlencode($shopperEmail); } $receiptOrderLines = ""; if ($addReceiptOrderLines) { $orderLines = base64_encode($this->_getReceiptOrderLines($this->_order)); $receiptOrderLines = "&receiptOrderLines=" . urlencode($orderLines); } // extra parameters so that you alway's return these paramters from the application $extraParamaters = urlencode("/?originalCustomCurrency=" . $currencyCode . "&originalCustomAmount=" . $paymentAmount . "&originalCustomMerchantReference=" . $merchantReference . "&originalCustomSessionId=" . session_id()); $launchlink = "adyen://payment?sessionId=" . session_id() . "&amount=" . $paymentAmount . "¤cy=" . $currencyCode . "&merchantReference=" . $merchantReference . $recurringParams . $receiptOrderLines . "&callback=" . $callbackUrl . $extraParamaters; // cash not working see ticket // https://youtrack.is.adyen.com/issue/IOS-130#comment=102-20285 // . "&transactionType=CASH"; $this->_adyenLogger->addAdyenDebug(print_r($launchlink, true)); } } catch (Exception $e) { // do nothing for now throw $e; } return $launchlink; }
/** * @param $payment * @return array */ protected function getFormFields($payment) { $order = $payment->getOrder(); $realOrderId = $order->getRealOrderId(); $orderCurrencyCode = $order->getOrderCurrencyCode(); // check if paybymail has it's own skin $skinCode = trim($this->_adyenHelper->getAdyenPayByMailConfigData('skin_code')); if ($skinCode == "") { // use HPP skin and HMAC $skinCode = $this->_adyenHelper->getAdyenHppConfigData('skin_code'); $hmacKey = $this->_adyenHelper->getHmac(); } else { // use pay_by_mail skin and hmac $hmacKey = $this->_adyenHelper->getHmacPayByMail(); } $amount = $this->_adyenHelper->formatAmount($order->getGrandTotal(), $orderCurrencyCode); $merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account')); $shopperEmail = $order->getCustomerEmail(); $customerId = $order->getCustomerId(); $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 (is_object($order->getBillingAddress()) && $order->getBillingAddress()->getCountry() != "") { $countryCode = $order->getBillingAddress()->getCountry(); } else { $countryCode = ""; } } $deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days'); $deliveryDays = !empty($deliveryDays) ? $deliveryDays : 5; $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; if ($countryCode != "") { $formFields['countryCode'] = $countryCode; } $formFields['shopperEmail'] = $shopperEmail; // recurring $recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type')); $formFields['recurringContract'] = $recurringType; $sessionValidity = $this->_adyenHelper->getAdyenPayByMailConfigData('session_validity'); if ($sessionValidity == "") { $sessionValidity = 3; } $formFields['sessionValidity'] = date("c", strtotime("+" . $sessionValidity . " days")); $formFields['shopperReference'] = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId; // 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)); return $formFields; }
/** * @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 array $buildSubject * @return array */ public function build(array $buildSubject) { /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $amount = \Magento\Payment\Gateway\Helper\SubjectReader::readAmount($buildSubject); $order = $paymentDataObject->getOrder(); $payment = $paymentDataObject->getPayment(); $pspReference = $payment->getCcTransId(); $currency = $payment->getOrder()->getOrderCurrencyCode(); $storeId = $order->getStoreId(); $merchantAccount = $this->adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId); $grandTotal = $payment->getOrder()->getGrandTotal(); // check if it contains a split payment $orderPaymentCollection = $this->orderPaymentCollectionFactory->create()->addFieldToFilter('payment_id', $payment->getId()); // partial refund if multiple payments check refund strategy if ($orderPaymentCollection->getSize() > 1) { $refundStrategy = $this->adyenHelper->getAdyenAbstractConfigData('split_payments_refund_strategy', $order->getStoreId()); $ratio = null; if ($refundStrategy == "1") { // Refund in ascending order $orderPaymentCollection->addPaymentFilterAscending($payment->getId()); } elseif ($refundStrategy == "2") { // Refund in descending order $orderPaymentCollection->addPaymentFilterDescending($payment->getId()); } elseif ($refundStrategy == "3") { // refund based on ratio $ratio = $amount / $grandTotal; $orderPaymentCollection->addPaymentFilterAscending($payment->getId()); } // loop over payment methods and refund them all $result = []; foreach ($orderPaymentCollection as $splitPayment) { // could be that not all the split payments need a refund if ($amount > 0) { if ($ratio) { // refund based on ratio calculate refund amount $modificationAmount = $ratio * ($splitPayment->getAmount() - $splitPayment->getTotalRefunded()); } else { // total authorised amount of the split payment $splitPaymentAmount = $splitPayment->getAmount() - $splitPayment->getTotalRefunded(); // if rest amount is zero go to next payment if (!$splitPaymentAmount > 0) { continue; } // if refunded amount is greather then split payment amount do a full refund if ($amount >= $splitPaymentAmount) { $modificationAmount = $splitPaymentAmount; } else { $modificationAmount = $amount; } // update amount with rest of the available amount $amount = $amount - $splitPaymentAmount; } $modificationAmountObject = ['currency' => $currency, 'value' => $this->adyenHelper->formatAmount($modificationAmount, $currency)]; $result[] = ["modificationAmount" => $modificationAmountObject, "reference" => $payment->getOrder()->getIncrementId(), "originalReference" => $splitPayment->getPspreference(), "merchantAccount" => $merchantAccount]; } } } else { //format the amount to minor units $amount = $this->adyenHelper->formatAmount($amount, $currency); $modificationAmount = ['currency' => $currency, 'value' => $amount]; $result = [["modificationAmount" => $modificationAmount, "reference" => $payment->getOrder()->getIncrementId(), "originalReference" => $pspReference, "merchantAccount" => $merchantAccount]]; } return $result; }
public function fullApiRequest($payment, $paymentMethodCode) { $order = $payment->getOrder(); $amount = $order->getGrandTotal(); $customerEmail = $order->getCustomerEmail(); $shopperIp = $order->getRemoteIp(); $orderCurrencyCode = $order->getOrderCurrencyCode(); $merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account"); $recurringType = $this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'); $realOrderId = $order->getRealOrderId(); $customerId = $order->getCustomerId(); $shopperReference = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId; // call lib $service = new \Adyen\Service\Payment($this->_client); $amount = ['currency' => $orderCurrencyCode, 'value' => $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode)]; $browserInfo = ['userAgent' => $_SERVER['HTTP_USER_AGENT'], 'acceptHeader' => $_SERVER['HTTP_ACCEPT']]; $request = array("merchantAccount" => $merchantAccount, "amount" => $amount, "reference" => $order->getIncrementId(), "shopperIP" => $shopperIp, "shopperEmail" => $customerEmail, "shopperReference" => $shopperReference, "fraudOffset" => "0", "browserInfo" => $browserInfo); // set the recurring type $recurringContractType = null; if ($recurringType) { if ($paymentMethodCode == \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE) { // For ONECLICK look at the recurringPaymentType that the merchant has selected in Adyen ONECLICK settings if ($payment->getAdditionalInformation('customer_interaction')) { $recurringContractType = \Adyen\Payment\Model\RecurringType::ONECLICK; } else { $recurringContractType = \Adyen\Payment\Model\RecurringType::RECURRING; } } else { if ($paymentMethodCode == \Adyen\Payment\Model\Method\Cc::METHOD_CODE) { if ($payment->getAdditionalInformation("store_cc") == "" && ($recurringType == "ONECLICK,RECURRING" || $recurringType == "RECURRING")) { $recurringContractType = \Adyen\Payment\Model\RecurringType::RECURRING; } elseif ($payment->getAdditionalInformation("store_cc") == "1") { $recurringContractType = $recurringType; } } else { $recurringContractType = $recurringType; } } } if ($recurringContractType) { $recurring = array('contract' => $recurringContractType); $request['recurring'] = $recurring; } $this->_adyenLogger->error('storeCC?:' . $payment->getAdditionalInformation("store_cc")); $this->_adyenLogger->error('recuringtype' . $recurringType); $this->_adyenLogger->error('recurringcontractType' . $recurringContractType); $billingAddress = $order->getBillingAddress(); if ($billingAddress) { $addressArray = $this->_adyenHelper->getStreet($billingAddress); $requestBilling = array("street" => $addressArray['name'], "postalCode" => $billingAddress->getPostcode(), "city" => $billingAddress->getCity(), "houseNumberOrName" => $addressArray['house_number'], "stateOrProvince" => $billingAddress->getRegionCode(), "country" => $billingAddress->getCountryId()); // houseNumberOrName is mandatory if ($requestBilling['houseNumberOrName'] == "") { $requestBilling['houseNumberOrName'] = "NA"; } $requestBilling['billingAddress'] = $requestBilling; $request = array_merge($request, $requestBilling); } $deliveryAddress = $order->getDeliveryAddress(); if ($deliveryAddress) { $addressArray = $this->_adyenHelper->getStreet($deliveryAddress); $requestDelivery = array("street" => $addressArray['name'], "postalCode" => $deliveryAddress->getPostcode(), "city" => $deliveryAddress->getCity(), "houseNumberOrName" => $addressArray['house_number'], "stateOrProvince" => $deliveryAddress->getRegionCode(), "country" => $deliveryAddress->getCountryId()); // houseNumberOrName is mandatory if ($requestDelivery['houseNumberOrName'] == "") { $requestDelivery['houseNumberOrName'] = "NA"; } $requestDelivery['deliveryAddress'] = $requestDelivery; $request = array_merge($request, $requestDelivery); } // define the shopper interaction if ($paymentMethodCode == \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE) { $recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference"); if ($payment->getAdditionalInformation('customer_interaction')) { $shopperInteraction = "Ecommerce"; } else { $shopperInteraction = "ContAuth"; } // For recurring Ideal and Sofort needs to be converted to SEPA for this it is mandatory to set selectBrand to sepadirectdebit if (!$payment->getAdditionalInformation('customer_interaction')) { if ($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") { $this->selectedBrand = "sepadirectdebit"; } } } else { $recurringDetailReference = null; $shopperInteraction = "Ecommerce"; } if ($shopperInteraction) { $request['shopperInteraction'] = $shopperInteraction; } if ($recurringDetailReference && $recurringDetailReference != "") { $request['selectedRecurringDetailReference'] = $recurringDetailReference; } // If cse is enabled add encrypted card date into request if ($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) { $request['additionalData']['card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data"); } else { $requestCreditCardDetails = array("expiryMonth" => $payment->getCcExpMonth(), "expiryYear" => $payment->getCcExpYear(), "holderName" => $payment->getCcOwner(), "number" => $payment->getCcNumber(), "cvc" => $payment->getCcCid()); $cardDetails['card'] = $requestCreditCardDetails; $request = array_merge($request, $cardDetails); } $result = $service->authorise($request); return $result; }