示例#1
0
 /**
  * @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;
 }
示例#2
0
 /**
  * @return bool
  */
 protected function _isAutoCapture()
 {
     // validate if payment methods allowes manual capture
     if ($this->_manualCaptureAllowed()) {
         $captureMode = trim($this->_getConfigData('capture_mode', 'adyen_abstract', $this->_order->getStoreId()));
         $sepaFlow = trim($this->_getConfigData('sepa_flow', 'adyen_abstract', $this->_order->getStoreId()));
         $_paymentCode = $this->_paymentMethodCode();
         $captureModeOpenInvoice = $this->_getConfigData('auto_capture_openinvoice', 'adyen_abstract', $this->_order->getStoreId());
         $captureModePayPal = trim($this->_getConfigData('paypal_capture_mode', 'adyen_abstract', $this->_order->getStoreId()));
         /*
          * if you are using authcap the payment method is manual.
          * There will be a capture send to indicate if payment is successful
          */
         if (($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") && $sepaFlow == "authcap") {
             $this->_adyenLogger->addAdyenNotificationCronjob('Manual Capture is applied for sepa because it is in authcap flow');
             return false;
         }
         // payment method ideal, cash adyen_boleto or adyen_pos has direct capture
         if ($_paymentCode == "adyen_pos" || ($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") && $sepaFlow != "authcap") {
             $this->_adyenLogger->addAdyenNotificationCronjob('This payment method does not allow manual capture.(2) paymentCode:' . $_paymentCode . ' paymentMethod:' . $this->_paymentMethod . ' sepaFLow:' . $sepaFlow);
             return true;
         }
         // if auto capture mode for openinvoice is turned on then use auto capture
         if ($captureModeOpenInvoice == true && $this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod)) {
             $this->_adyenLogger->addAdyenNotificationCronjob('This payment method is configured to be working as auto capture ');
             return true;
         }
         // if PayPal capture modues is different from the default use this one
         if (strcmp($this->_paymentMethod, 'paypal') === 0 && $captureModePayPal != "") {
             if (strcmp($captureModePayPal, 'auto') === 0) {
                 $this->_adyenLogger->addAdyenNotificationCronjob('This payment method is paypal and configured to work as auto capture');
                 return true;
             } elseif (strcmp($captureModePayPal, 'manual') === 0) {
                 $this->_adyenLogger->addAdyenNotificationCronjob('This payment method is paypal and configured to work as manual capture');
                 return false;
             }
         }
         if (strcmp($captureMode, 'manual') === 0) {
             $this->_adyenLogger->addAdyenNotificationCronjob('Capture mode for this payment is set to manual');
             return false;
         }
         /*
          * online capture after delivery, use Magento backend to online invoice
          * (if the option auto capture mode for openinvoice is not set)
          */
         if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_paymentMethod)) {
             $this->_adyenLogger->addAdyenNotificationCronjob('Capture mode for klarna is by default set to manual');
             return false;
         }
         $this->_adyenLogger->addAdyenNotificationCronjob('Capture mode is set to auto capture');
         return true;
     } else {
         // does not allow manual capture so is always immediate capture
         $this->_adyenLogger->addAdyenNotificationCronjob('This payment method does not allow manual capture');
         return true;
     }
 }
示例#3
0
 /**
  * @return string
  */
 public function getFormUrl()
 {
     $url = "";
     try {
         if ($this->_order->getPayment()) {
             $paymentRoutine = $this->_adyenHelper->getAdyenHppConfigData('payment_routine');
             switch ($this->_adyenHelper->isDemoMode()) {
                 case true:
                     if ($paymentRoutine == 'single' && $this->getPaymentMethodSelectionOnAdyen()) {
                         $url = 'https://test.adyen.com/hpp/pay.shtml';
                     } else {
                         if ($this->getPaymentMethodSelectionOnAdyen()) {
                             $url = 'https://test.adyen.com/hpp/select.shtml';
                         } else {
                             if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_order->getPayment()->getAdditionalInformation('brand_code'))) {
                                 $url = "https://test.adyen.com/hpp/skipDetails.shtml";
                             } else {
                                 $url = "https://test.adyen.com/hpp/details.shtml";
                             }
                         }
                     }
                     break;
                 default:
                     if ($paymentRoutine == 'single' && $this->getPaymentMethodSelectionOnAdyen()) {
                         $url = 'https://live.adyen.com/hpp/pay.shtml';
                     } else {
                         if ($this->getPaymentMethodSelectionOnAdyen()) {
                             $url = 'https://live.adyen.com/hpp/select.shtml';
                         } else {
                             if ($this->_adyenHelper->isPaymentMethodOpenInvoiceMethod($this->_order->getPayment()->getAdditionalInformation('brand_code'))) {
                                 $url = "https://live.adyen.com/hpp/skipDetails.shtml";
                             } else {
                                 $url = "https://live.adyen.com/hpp/details.shtml";
                             }
                         }
                     }
                     break;
             }
         }
     } catch (Exception $e) {
         // do nothing for now
         throw $e;
     }
     return $url;
 }