diff --git a/app/code/community/Payone/Core/Block/Checkout/Onepage/Payment/Methods.php b/app/code/community/Payone/Core/Block/Checkout/Onepage/Payment/Methods.php index b1756456..3ae89c1c 100644 --- a/app/code/community/Payone/Core/Block/Checkout/Onepage/Payment/Methods.php +++ b/app/code/community/Payone/Core/Block/Checkout/Onepage/Payment/Methods.php @@ -75,6 +75,7 @@ public function getMethods() } $aRestrictedMethods = $this->getRestrictedMethods(); + $aRestrictedMethods[] = Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS; if (!empty($aRestrictedMethods)) { $this->methods = array_filter( $this->methods, diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Cancel.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Cancel.php new file mode 100644 index 00000000..156eb148 --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Cancel.php @@ -0,0 +1,41 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Cancel extends Mage_Core_Block_Template +{ + const CART_URL = 'checkout/cart'; + + /** + * Retrieve payment method and assign additional template values + */ + protected function _beforeToHtml() + { + } + + /** + * @return string + */ + public function getCartUrl() + { + return Mage::getUrl(self::CART_URL); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Review.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review.php new file mode 100644 index 00000000..45f14825 --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review.php @@ -0,0 +1,170 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Review extends Mage_Core_Block_Template +{ + /** @var int */ + protected $quoteId; + /** @var Payone_Core_Block_Paydirekt_Express_Review_Billing */ + protected $billing; + /** @var Payone_Core_Block_Paydirekt_Express_Review_Shipping */ + protected $shipping; + /** @var Payone_Core_Block_Paydirekt_Express_Review_ShippingMethod */ + protected $shippingMethod; + /** @var Payone_Core_Block_Paydirekt_Express_Review_PaymentMethod */ + protected $paymentMethod; + /** @var Payone_Core_Block_Paydirekt_Express_Review_Items */ + protected $itemsReview; + /** @var Mage_Checkout_Block_Agreements */ + protected $checkoutAgreements; + + /** + * Retrieve payment method and assign additional template values + */ + protected function _beforeToHtml() + { + + } + + /** + * @return Mage_Sales_Model_Quote + */ + public function getQuote() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + + return $quote; + } + + /** + * @return int + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param int $quoteId + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + } + + /** + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function getBilling() + { + return $this->billing; + } + + /** + * @param Payone_Core_Block_Paydirekt_Express_Review_Billing $billing + */ + public function setBilling($billing) + { + $this->billing = $billing; + } + + /** + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function getShipping() + { + return $this->shipping; + } + + /** + * @param Payone_Core_Block_Paydirekt_Express_Review_Shipping $shipping + */ + public function setShipping($shipping) + { + $this->shipping = $shipping; + } + + /** + * @return Payone_Core_Block_Paydirekt_Express_Review_ShippingMethod + */ + public function getShippingMethod() + { + return $this->shippingMethod; + } + + /** + * @param Payone_Core_Block_Paydirekt_Express_Review_ShippingMethod $shippingMethod + */ + public function setShippingMethod($shippingMethod) + { + $this->shippingMethod = $shippingMethod; + } + + /** + * @return Payone_Core_Block_Paydirekt_Express_Review_PaymentMethod + */ + public function getPaymentMethod() + { + return $this->paymentMethod; + } + + /** + * @param Payone_Core_Block_Paydirekt_Express_Review_PaymentMethod $paymentMethod + */ + public function setPaymentMethod($paymentMethod) + { + $this->paymentMethod = $paymentMethod; + } + + /** + * @return Payone_Core_Block_Paydirekt_Express_Review_Items + */ + public function getItemsReview() + { + return $this->itemsReview; + } + + /** + * @param Payone_Core_Block_Paydirekt_Express_Review_Items $itemsReview + */ + public function setItemsReview($itemsReview) + { + $this->itemsReview = $itemsReview; + } + + /** + * @return Mage_Checkout_Block_Agreements + */ + public function getCheckoutAgreements() + { + return $this->checkoutAgreements; + } + + /** + * @param Mage_Checkout_Block_Agreements $checkoutAgreements + */ + public function setCheckoutAgreements($checkoutAgreements) + { + $this->checkoutAgreements = $checkoutAgreements; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Billing.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Billing.php new file mode 100644 index 00000000..4c00a4ee --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Billing.php @@ -0,0 +1,224 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Review_Billing extends Mage_Core_Block_Template +{ + /** @var int */ + protected $quoteId; + /** @var string */ + protected $firstname = ""; + /** @var string */ + protected $lastname = ""; + /** @var string */ + protected $email = ""; + /** @var string */ + protected $street = ""; + /** @var string */ + protected $zip = ""; + /** @var string */ + protected $state = ""; + /** @var string */ + protected $city = ""; + /** @var string */ + protected $country = ""; + + public function init() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + if (!$quote) { + throw new Payone_Core_Exception_OrderNotFound('Quote with ID ' . $this->quoteId . ' was not found.'); + } + + $this->setFirstname($quote->getBillingAddress()->getFirstname()) + ->setLastname($quote->getBillingAddress()->getLastname()) + ->setEmail($quote->getBillingAddress()->getEmail()) + ->setStreet($quote->getBillingAddress()->getStreetFull()) + ->setZip($quote->getBillingAddress()->getPostcode()) + ->setCity($quote->getBillingAddress()->getCity()) + ->setState($quote->getBillingAddress()->getRegion()) + ->setCountry($quote->getBillingAddress()->getCountry()); + } + + /** + * @return string + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * @param string $firstname + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setFirstname($firstname) + { + $this->firstname = $firstname; + + return $this; + } + + /** + * @return string + */ + public function getLastname() + { + return $this->lastname; + } + + /** + * @param string $lastname + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setLastname($lastname) + { + $this->lastname = $lastname; + + return $this; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $email + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setEmail($email) + { + $this->email = $email; + + return $this; + } + + /** + * @return string + */ + public function getStreet() + { + return $this->street; + } + + /** + * @param string $street + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setStreet($street) + { + $this->street = $street; + + return $this; + } + + /** + * @return string + */ + public function getZip() + { + return $this->zip; + } + + /** + * @param string $zip + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setZip($zip) + { + $this->zip = $zip; + + return $this; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @param string $state + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setState($state) + { + $this->state = $state; + + return $this; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @param string $city + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setCity($city) + { + $this->city = $city; + + return $this; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param string $country + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setCountry($country) + { + $this->country = $country; + + return $this; + } + + /** + * @param int $quoteId + * @return Payone_Core_Block_Paydirekt_Express_Review_Billing + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + + return $this; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Items.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Items.php new file mode 100644 index 00000000..671d324b --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Items.php @@ -0,0 +1,75 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Review_Items extends Mage_Core_Block_Template +{ + /** @var int */ + protected $quoteId; + /** @var array */ + protected $items = array(); + + public function init() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + if (!$quote) { + throw new Payone_Core_Exception_OrderNotFound('Quote with ID ' . $this->quoteId . ' was not found.'); + } + + $this->items = $quote->getAllItems(); + } + + /** + * @return int + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param int $quoteId + * @return Payone_Core_Block_Paydirekt_Express_Review_Items + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + + return $this; + } + + /** + * @return array + */ + public function getItems() + { + return $this->items; + } + + /** + * @param array $items + */ + public function setItems($items) + { + $this->items = $items; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/PaymentMethod.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/PaymentMethod.php new file mode 100644 index 00000000..da098a2b --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/PaymentMethod.php @@ -0,0 +1,69 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Review_PaymentMethod extends Mage_Core_Block_Template +{ + /** @var int */ + protected $quoteId; + + public function init() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + if (!$quote) { + throw new Payone_Core_Exception_OrderNotFound('Quote with ID ' . $this->quoteId . ' was not found.'); + } + } + + /** + * @return int + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param int $quoteId + * @return Payone_Core_Block_Paydirekt_Express_Review_PaymentMethod + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + + return $this; + } + + /** + * @return string + */ + public function getPaymentMethod() + { + /** @var Payone_Core_Model_System_Config_PaymentMethodType $config */ + $config = Mage::getModel('payone_core/system_config_paymentmethodtype')->toArray(); + if (!isset($config[Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYDIREKTEXPRESS])) { + return ucfirst(Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYDIREKTEXPRESS); + } + + return $config[Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYDIREKTEXPRESS]; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Shipping.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Shipping.php new file mode 100644 index 00000000..cb3ec6d0 --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/Shipping.php @@ -0,0 +1,232 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Review_Shipping extends Mage_Core_Block_Template +{ + /** @var int */ + protected $quoteId; + /** @var string */ + protected $firstname = ""; + /** @var string */ + protected $lastname = ""; + /** @var string */ + protected $phone = ""; + /** @var string */ + protected $street = ""; + /** @var string */ + protected $zip = ""; + /** @var string */ + protected $state = ""; + /** @var string */ + protected $city = ""; + /** @var string */ + protected $country = ""; + + public function init() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + if (!$quote) { + throw new Payone_Core_Exception_OrderNotFound('Quote with ID ' . $this->quoteId . ' was not found.'); + } + + $this->setFirstname($quote->getShippingAddress()->getFirstname()) + ->setLastname($quote->getShippingAddress()->getLastname()) + ->setPhone($quote->getShippingAddress()->getPrefix() . ' ' . $quote->getShippingAddress()->getTelephone()) + ->setStreet($quote->getShippingAddress()->getStreetFull()) + ->setZip($quote->getShippingAddress()->getPostcode()) + ->setCity($quote->getShippingAddress()->getCity()) + ->setState($quote->getShippingAddress()->getRegion()) + ->setCountry($quote->getShippingAddress()->getCountry()); + } + + /** + * @return int + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param int $quoteId + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + + return $this; + } + + /** + * @return string + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * @param string $firstname + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setFirstname($firstname) + { + $this->firstname = $firstname; + + return $this; + } + + /** + * @return string + */ + public function getLastname() + { + return $this->lastname; + } + + /** + * @param string $lastname + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setLastname($lastname) + { + $this->lastname = $lastname; + + return $this; + } + + /** + * @return string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param string $phone + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setPhone($phone) + { + $this->phone = $phone; + + return $this; + } + + /** + * @return string + */ + public function getStreet() + { + return $this->street; + } + + /** + * @param string $street + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setStreet($street) + { + $this->street = $street; + + return $this; + } + + /** + * @return string + */ + public function getZip() + { + return $this->zip; + } + + /** + * @param string $zip + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setZip($zip) + { + $this->zip = $zip; + + return $this; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @param string $state + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setState($state) + { + $this->state = $state; + + return $this; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @param string $city + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setCity($city) + { + $this->city = $city; + + return $this; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param string $country + * @return Payone_Core_Block_Paydirekt_Express_Review_Shipping + */ + public function setCountry($country) + { + $this->country = $country; + + return $this; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/ShippingMethod.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/ShippingMethod.php new file mode 100644 index 00000000..7b7b308e --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Review/ShippingMethod.php @@ -0,0 +1,75 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Review_ShippingMethod extends Mage_Core_Block_Template +{ + /** @var int */ + protected $quoteId; + + public function init() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + if (!$quote) { + throw new Payone_Core_Exception_OrderNotFound('Quote with ID ' . $this->quoteId . ' was not found.'); + } + } + + /** + * @return int + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param int $quoteId + * @return Payone_Core_Block_Paydirekt_Express_Review_ShippingMethod + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + + return $this; + } + + /** + * @return string + */ + public function getShippingMethod() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->quoteId); + $shippingMethod = $quote->getShippingAddress()->getShippingMethod(); + $rate = $quote->getShippingAddress()->getShippingRateByCode($shippingMethod); + if ($rate) { + $carrierTitle = $rate->getCarrierTitle(); + $methodTitle = $rate->getMethodTitle(); + } + else { + list($carrierTitle, $methodTitle) = explode('_', $quote->getShippingAddress()->getShippingMethod()); + } + + return $carrierTitle . ' - ' . $methodTitle; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Block/Paydirekt/Express/Shortcut.php b/app/code/community/Payone/Core/Block/Paydirekt/Express/Shortcut.php new file mode 100644 index 00000000..52bea112 --- /dev/null +++ b/app/code/community/Payone/Core/Block/Paydirekt/Express/Shortcut.php @@ -0,0 +1,321 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Block_Paydirekt_Express_Shortcut extends Mage_Core_Block_Template +{ + const INIT_CHECKOUT_URL = 'payone_core/paydirektExpress/initCheckout'; + + const DEFAULT_LINK_IMAGE = 'https://www.paydirekt.de/presse/medien/logos/ohne-schutzzone/4c_ohne_schutzzone/paydirekt_logo_claim_4c.png'; + + /** + * Position of "OR" label against shortcut + */ + const POSITION_BEFORE = 'before'; + const POSITION_AFTER = 'after'; + + /** @var Payone_Core_Model_Factory */ + protected $factory = null; + + /** + * Whether the block should be eventually rendered + * + * @var bool + */ + protected $shouldRender = true; + + /** + * Payment method code + * + * @var string + */ + protected $paymentMethodCode = Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS; + + /** + * @var string + */ + protected $quoteId; + + /** + * @var string + */ + protected $customerId; + + /** + * @return bool + */ + public function isPaydirektExpressActive() + { + $config = $this->getConfiguration(); + + return !empty($config); + } + + /** + * @return string + */ + public function getInitUrl() + { + return Mage::getBaseUrl() . self::INIT_CHECKOUT_URL; + } + + /** + * @return string + */ + public function getQuoteId() + { + if ($this->quoteId == null) { + $this->quoteId = Mage::getSingleton('checkout/session')->getQuoteId(); + } + + return $this->quoteId; + } + + /** + * @param string $quoteId + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + } + + /** + * @return string + */ + public function getCustomerId() + { + if ($this->customerId == null) { + $this->customerId = Mage::getSingleton('customer/session')->getCustomerId(); + } + + return $this->customerId; + } + + /** + * @param string $customerId + */ + public function setCustomerId($customerId) + { + $this->customerId = $customerId; + } + + /** + * @return Mage_Core_Block_Abstract + */ + protected function _beforeToHtml() + { + $result = parent::_beforeToHtml(); + $quote = Mage::getSingleton('checkout/session')->getQuote(); + + // check payment method availability + $methodInstance = Mage::helper('payment')->getMethodInstance($this->paymentMethodCode); + if (!$methodInstance || !$methodInstance->isAvailable($quote)) { + $this->shouldRender = false; + return $result; + } + + // check visibility button on shopping cart + $shortcutOnShoppingCart = $this->getHelperConfig()->getConfigGeneral($quote->getStoreId())->getPaymentPaydirektExpressCheckout()->getPaydirektExpressCheckoutVisibleOnCart(); + if(empty($shortcutOnShoppingCart)) { + $this->shouldRender = false; + return $result; + } + + // check if we are in a secure environment + $isSecure = Mage::app()->getStore()->isCurrentlySecure(); + // set misc data + $this->setShortcutHtmlId($this->helper('core')->uniqHash('pde_shortcut_')) + ->setCheckoutUrl($this->getUrl(self::INIT_CHECKOUT_URL, array('_secure' => $isSecure))); + + $this->setImageUrl($this->_getCheckoutShortcutImageUrl($quote)); + + return $result; + } + + /** + * Render the block if needed + * + * @return string + */ + protected function _toHtml() + { + if (!$this->shouldRender) { + return ''; + } + + return parent::_toHtml(); + } + + /** + * Check is "OR" label position before shortcut + * + * @return bool + */ + public function isOrPositionBefore() + { + return ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_BEFORE); + } + + /** + * Check is "OR" label position after shortcut + * + * @return bool + */ + public function isOrPositionAfter() + { + return ($this->getShowOrPosition() && $this->getShowOrPosition() == self::POSITION_AFTER); + } + + /** + * @return Payone_Core_Helper_Config + */ + protected function getHelperConfig() + { + return $this->getFactory()->helperConfig(); + } + + /** + * @return Payone_Core_Model_Factory + */ + protected function getFactory() + { + if ($this->factory === null) { + $this->factory = new Payone_Core_Model_Factory(); + } + + return $this->factory; + } + + /** + * Checkout with Paydirekt image URL getter + * + * @param Mage_Sales_Model_Quote $quote + * @return string + */ + protected function _getCheckoutShortcutImageUrl($quote) + { + $localUrl = $this->getHelperConfig()->getConfigGeneral($quote->getStoreId())->getPaymentPaydirektExpressCheckout()->getPaydirektExpressCheckoutImage(); + if ($localUrl) { + return Mage::getBaseUrl('media') . 'payone' . DS . $localUrl; + } + + return self::DEFAULT_LINK_IMAGE; + } + + /** + * @return \Payone_Core_Model_Config_Payment_Method + */ + private function getConfiguration() + { + /** @var \Mage_Checkout_Model_Session $session */ + $session = Mage::getSingleton('checkout/session'); + + /** @var \Mage_Sales_Model_Quote $quote */ + $quote = $session->getQuote(); + + /** @var \Mage_Payment_Helper_Data $paymentHelper */ + $paymentHelper = Mage::helper('payment'); + + /** @var \Payone_Core_Model_Payment_Method_WalletPaydirektExpress $paymentMethod */ + $paymentMethod = $paymentHelper->getMethodInstance(Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS); + + try { + /** @var \Payone_Core_Model_Config_Payment_Method $paymentConfig */ + $paymentConfig = $paymentMethod->getConfigForQuote($quote); + } catch (\Payone_Core_Exception_PaymentMethodConfigNotFound $e) { + return null; + } + + return $paymentConfig; + } + + /** + * We try to collect the shipping rates * + * If not found, the method is not usable, and not displayed + * + * *2 tries : + * - First try with the configured shipping method + * - Second try, check if any other rate exists, if so, pick it + * The same mechanism will be used when processing the quote for real (during Checkout) + * + * Note for improvement : this might bring slight perf reduction on systems with many shipping options + * + * @return bool + */ + public function isApplicable() + { + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($this->getQuoteId()); + + if (is_null($quote)) { + return false; + } + + if (!empty($quote->getShippingAddress()->getShippingMethod())) { + return true; + } + + $shippingAddress = $quote->getShippingAddress() + ->setCountryId('DE') + ->setCity('Stadt') + ->setPostcode('12345'); + $shippingAddress->requestShippingRates(); + /** @var Payone_Core_Model_Payment_Method_Abstract $methodInstance */ + $methodInstance = Mage::helper('payment')->getMethodInstance(Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS); + /** @var Payone_Core_Model_Config_Payment_Method $config */ + $config = $methodInstance->getConfigForQuote($quote); + $configShippingMethod = $config->getAssociatedShippingMethod(); + + // Try with configured shipping method + $found = $this->rateExistsForMethod($shippingAddress, $configShippingMethod); + if (!empty($found)) { + $shippingAddress->save(); + return true; + } + + // Try with first available shipping method + $rates = $shippingAddress->getShippingRatesCollection()->getItems(); + if (!empty($rates)) { + /** @var Mage_Sales_Model_Quote_Address_Rate $availableRate */ + $availableRate = array_shift($rates); + $shippingAddress->setShippingMethod($availableRate->getMethod())->save(); + + return true; + } + + return false; + } + + /** + * @param Mage_Sales_Model_Quote_Address $shippingAddress + * @param string $configShippingMethod + * @return bool + */ + private function rateExistsForMethod($shippingAddress, $configShippingMethod) + { + $shippingAddress->setShippingMethod($configShippingMethod); + $shippingAddress + ->setCollectShippingRates(1) + ->collectShippingRates(); + + return !empty($shippingAddress->getShippingRateByCode($configShippingMethod)); + } +} diff --git a/app/code/community/Payone/Core/Block/Payment/Method/Form/Wallet.php b/app/code/community/Payone/Core/Block/Payment/Method/Form/Wallet.php index c615a756..178ccc3b 100644 --- a/app/code/community/Payone/Core/Block/Payment/Method/Form/Wallet.php +++ b/app/code/community/Payone/Core/Block/Payment/Method/Form/Wallet.php @@ -48,6 +48,7 @@ public function walletTypeMapping() { return $walletPayment = array( Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKT => Payone_Api_Enum_WalletType::PAYDIREKT, + Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS => Payone_Api_Enum_WalletType::PAYDIREKTEXPRESS, Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYPALEXPRESS => Payone_Api_Enum_WalletType::PAYPAL_EXPRESS, Payone_Core_Model_System_Config_PaymentMethodCode::WALLETALIPAY => Payone_Api_Enum_WalletType::ALIPAY ); diff --git a/app/code/community/Payone/Core/Block/PaymentAdditionalStyle.php b/app/code/community/Payone/Core/Block/PaymentAdditionalStyle.php index 6152047f..e29a0a2e 100644 --- a/app/code/community/Payone/Core/Block/PaymentAdditionalStyle.php +++ b/app/code/community/Payone/Core/Block/PaymentAdditionalStyle.php @@ -26,6 +26,7 @@ class Payone_Core_Block_PaymentAdditionalStyle extends Mage_Core_Block_Template private $stylesheetUrls = array( Payone_Core_Model_System_Config_PaymentMethodCode::MASTERPASS => 'payone/core/masterpass.css', Payone_Core_Model_System_Config_PaymentMethodCode::AMAZONPAY => 'payone/core/amazonpay_button.css', + Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS => 'payone/core/paydirektexpress.css', ); /** diff --git a/app/code/community/Payone/Core/Model/Config/General.php b/app/code/community/Payone/Core/Model/Config/General.php index fad2b713..f1bbad16 100644 --- a/app/code/community/Payone/Core/Model/Config/General.php +++ b/app/code/community/Payone/Core/Model/Config/General.php @@ -52,6 +52,10 @@ class Payone_Core_Model_Config_General extends Payone_Core_Model_Config_AreaAbst * @var Payone_Core_Model_Config_General_PaymentPaypalExpressCheckout */ protected $payment_paypal_express_checkout; + /** + * @var Payone_Core_Model_Config_General_PaymentPaydirektExpressCheckout + */ + protected $payment_paydirekt_express_checkout; /** * @var Payone_Core_Model_Config_General_ParameterNarrativeText @@ -139,6 +143,22 @@ public function getPaymentPaypalExpressCheckout() return $this->payment_paypal_express_checkout; } + /** + * @param Payone_Core_Model_Config_General_PaymentPaydirektExpressCheckout $payment_paydirekt_express_checkout + */ + public function setPaymentPaydirektExpressCheckout(Payone_Core_Model_Config_General_PaymentPaydirektExpressCheckout $payment_paydirekt_express_checkout) + { + $this->payment_paydirekt_express_checkout = $payment_paydirekt_express_checkout; + } + + /** + * @return Payone_Core_Model_Config_General_PaymentPaydirektExpressCheckout + */ + public function getPaymentPaydirektExpressCheckout() + { + return $this->payment_paydirekt_express_checkout; + } + /** * @param Payone_Core_Model_Config_General_StatusMapping $status_mapping */ diff --git a/app/code/community/Payone/Core/Model/Config/General/ParameterNarrativeText.php b/app/code/community/Payone/Core/Model/Config/General/ParameterNarrativeText.php index adc0f7c9..ca63d3b1 100644 --- a/app/code/community/Payone/Core/Model/Config/General/ParameterNarrativeText.php +++ b/app/code/community/Payone/Core/Model/Config/General/ParameterNarrativeText.php @@ -45,6 +45,10 @@ class Payone_Core_Model_Config_General_ParameterNarrativeText * @var string */ protected $paydirekt = ''; + /** + * @var string + */ + protected $paydirekt_express = ''; /** * @var string @@ -98,9 +102,25 @@ public function getPaydirekt() { return $this->paydirekt; } - + /** - * @param string $paydirekt + * @param string $paydirekt_express + */ + public function setPaydirektExpress($paydirekt_express) + { + $this->paydirekt_express = $paydirekt_express; + } + + /** + * @return string + */ + public function getPaydirektExpress() + { + return $this->paydirekt_express; + } + + /** + * @param string $paypal_express */ public function setPaypalExpress($paypal_express) { diff --git a/app/code/community/Payone/Core/Model/Config/General/PaymentPaydirektExpressCheckout.php b/app/code/community/Payone/Core/Model/Config/General/PaymentPaydirektExpressCheckout.php new file mode 100644 index 00000000..47e0b5ba --- /dev/null +++ b/app/code/community/Payone/Core/Model/Config/General/PaymentPaydirektExpressCheckout.php @@ -0,0 +1,61 @@ + - www.fatchip.com + * @author Vincent Boulanger + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.com + */ +class Payone_Core_Model_Config_General_PaymentPaydirektExpressCheckout extends Payone_Core_Model_Config_AreaAbstract +{ + /** @var int */ + protected $paydirektExpressCheckoutVisibleOnCart = 0; + /** @var string */ + protected $paydirektExpressCheckoutImage = ''; + + /** + * @param int $paydirektExpressCheckoutVisibleOnCart + */ + public function setPaydirektExpressCheckoutVisibleOnCart($paydirektExpressCheckoutVisibleOnCart) + { + $this->paydirektExpressCheckoutVisibleOnCart = $paydirektExpressCheckoutVisibleOnCart; + } + + /** + * @return int + */ + public function getPaydirektExpressCheckoutVisibleOnCart() + { + return $this->paydirektExpressCheckoutVisibleOnCart; + } + + /** + * @param string $paydirektExpressCheckoutImage + */ + public function setPaydirektExpressCheckoutImage($paydirektExpressCheckoutImage) + { + $this->paydirektExpressCheckoutImage = $paydirektExpressCheckoutImage; + } + + /** + * @return string + */ + public function getPaydirektExpressCheckoutImage() + { + return $this->paydirektExpressCheckoutImage; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Config/General/StatusMapping.php b/app/code/community/Payone/Core/Model/Config/General/StatusMapping.php index f770d233..731039b3 100644 --- a/app/code/community/Payone/Core/Model/Config/General/StatusMapping.php +++ b/app/code/community/Payone/Core/Model/Config/General/StatusMapping.php @@ -174,6 +174,12 @@ class Payone_Core_Model_Config_General_StatusMapping extends Payone_Core_Model_C * @var null */ protected $walletPaydirekt = null; + /** + * Payment method wallet_paydirekt_express + * + * @var null + */ + protected $walletPaydirektExpress = null; /** * Payment method wallet_paypal_express * @@ -759,6 +765,26 @@ public function getWalletPaydirekt() return $this->walletPaydirekt; } + /** + * @param $walletPaydirektExpress + */ + public function setWalletPaydirektExpress($walletPaydirektExpress) + { + if (is_string($walletPaydirektExpress)) { + $walletPaydirektExpress = $this->initValue($walletPaydirektExpress); + } + + $this->walletPaydirektExpress = $walletPaydirektExpress; + } + + /** + * @return $walletPaydirektExpress|null + */ + public function getWalletPaydirektExpress() + { + return $this->walletPaydirektExpress; + } + /** * @param $walletPaypalExpress */ diff --git a/app/code/community/Payone/Core/Model/Config/Payment/Method.php b/app/code/community/Payone/Core/Model/Config/Payment/Method.php index dec732a5..9e7d4cdf 100644 --- a/app/code/community/Payone/Core/Model/Config/Payment/Method.php +++ b/app/code/community/Payone/Core/Model/Config/Payment/Method.php @@ -312,6 +312,11 @@ class Payone_Core_Model_Config_Payment_Method */ protected $ratepay_directdebit_allowspecific = 0; + /** + * @var string + */ + protected $associated_shipping_method = ''; + /** * Check if Method can be used in Country * @@ -1480,4 +1485,20 @@ public function getRatepayDirectdebitAllowspecific() { return $this->ratepay_directdebit_allowspecific; } + + /** + * @return string + */ + public function getAssociatedShippingMethod() + { + return $this->associated_shipping_method; + } + + /** + * @param string $associated_shipping_method + */ + public function setAssociatedShippingMethod($associated_shipping_method) + { + $this->associated_shipping_method = $associated_shipping_method; + } } diff --git a/app/code/community/Payone/Core/Model/Factory.php b/app/code/community/Payone/Core/Model/Factory.php index f24684fd..bf4c171c 100644 --- a/app/code/community/Payone/Core/Model/Factory.php +++ b/app/code/community/Payone/Core/Model/Factory.php @@ -1766,4 +1766,24 @@ public function getRequestMasterpassGetCheckout(array $data = array()) $request = new Payone_Api_Request_MasterpassGetCheckout($data); return $request; } + + /** + * @param array $data + * @return Payone_Api_Request_PaydirektExpressSetCheckout + */ + public function getRequestPaydirektExpressSetCheckout(array $data = array()) + { + $request = new Payone_Api_Request_PaydirektExpressSetCheckout($data); + return $request; + } + + /** + * @param array $data + * @return Payone_Api_Request_PaydirektExpressGetStatus + */ + public function getRequestPaydirektExpressGetStatus(array $data = array()) + { + $request = new Payone_Api_Request_PaydirektExpressGetStatus($data); + return $request; + } } diff --git a/app/code/community/Payone/Core/Model/Handler/Cancellation.php b/app/code/community/Payone/Core/Model/Handler/Cancellation.php index 32efaa0b..7cb1c293 100644 --- a/app/code/community/Payone/Core/Model/Handler/Cancellation.php +++ b/app/code/community/Payone/Core/Model/Handler/Cancellation.php @@ -39,6 +39,8 @@ public function handle(Mage_Core_Controller_Front_Action $controller = null) $oSession = Mage::getSingleton('checkout/session'); if ($oSession->getPayoneExternalCheckoutActive() === true) { $oSession->unsPayoneExternalCheckoutActive(); + $oSession->unsPaydirektExpressCheckoutActive(); + // Load last order by ID $orderId = $oSession->getLastOrderId(); $oOrder = $this->getFactory()->getModelSalesOrder(); diff --git a/app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php b/app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php index 3b474bfc..8993c19f 100644 --- a/app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php +++ b/app/code/community/Payone/Core/Model/Handler/Payment/Abstract.php @@ -209,6 +209,7 @@ protected function updateOrder(Mage_Sales_Model_Order $order) $order->setData('payone_payment_method_type', $this->getPayment()->getData('payone_payolution_type')); } elseif ($this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_Wallet || $this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_WalletPaydirekt || + $this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_WalletPaydirektExpress || $this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_WalletPaypalExpress || $this->getPaymentMethod() instanceof Payone_Core_Model_Payment_Method_WalletAliPay ) { diff --git a/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php b/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php index 79d728cd..15018f49 100644 --- a/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php +++ b/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Authorize/Abstract.php @@ -91,6 +91,10 @@ public function mapFromPayment(Mage_Sales_Model_Order_Payment $payment) if($workOrderId = $payment->getAdditionalInformation(Payone_Core_Model_Service_Mastercard_Masterpass_Checkout::PAYONE_MASTERPASS_CHECKOUT_WORKORDERID)) { $request->setWorkorderId($workOrderId); } + //Add workorderid when paydirekt express checkout is used + if($workOrderId = $payment->getAdditionalInformation(Payone_Core_Model_Service_Paydirekt_Express_Checkout::PAYONE_PAYDIREKT_CHECKOUT_WORKORDERID)) { + $request->setWorkorderId($workOrderId); + } $payment = $this->mapPaymentParameters(); @@ -130,9 +134,13 @@ public function afterMapFromPayment(Payone_Api_Request_Authorization_Abstract $r protected function _getReferenceNumber($oPayment, $oOrder) { $sRefNr = $oOrder->getIncrementId(); - if (($oPayment instanceof Payone_Core_Model_Payment_Method_Wallet - || $oPayment instanceof Payone_Core_Model_Payment_Method_WalletPaydirekt) - && ($this->_getWalletType() == 'PDT') + if ( + $oPayment instanceof Payone_Core_Model_Payment_Method_WalletPaydirektExpress + || + ( + ($oPayment instanceof Payone_Core_Model_Payment_Method_Wallet || $oPayment instanceof Payone_Core_Model_Payment_Method_WalletPaydirekt) + && ($this->_getWalletType() == 'PDT') + ) ) { $sRefNr = str_replace('_', '-', $sRefNr); } @@ -561,7 +569,9 @@ protected function mapPaymentParameters() } } //Wallet PayDirekt - elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaydirekt) { + elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaydirekt || + $paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaydirektExpress + ) { $payment = new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet(); $payData = new Payone_Api_Request_Parameter_Paydata_Paydata(); @@ -584,6 +594,14 @@ protected function mapPaymentParameters() ); } + if ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaydirektExpress) { + $payData->addItem( + new Payone_Api_Request_Parameter_Paydata_DataItem( + array('key' => 'terms_accepted_timestamp', 'data' => (new DateTimeImmutable())->format(DATE_ISO8601)) + ) + ); + } + $payment->setPaydata($payData); } //Wallet PayPal Express @@ -1004,7 +1022,10 @@ protected function _getWalletType() } else { if($aPostPayment && array_key_exists('payone_wallet_paydirekt_type', $aPostPayment)) { $sType = $aPostPayment['payone_wallet_paydirekt_type']; - } else { + } elseif($aPostPayment && array_key_exists('payone_wallet_paydirekt_express_type', $aPostPayment)) { + $sType = $aPostPayment['payone_wallet_paydirekt_express_type']; + } + else { $sType = Payone_Api_Enum_WalletType::PAYPAL_EXPRESS; } } @@ -1064,6 +1085,8 @@ protected function mapClearingType(Payone_Core_Model_Payment_Method_Abstract $pa $clearingType = Payone_Enum_ClearingType::WALLET; } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaydirekt) { $clearingType = Payone_Enum_ClearingType::WALLETPAYDIREKT; + } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaydirektExpress) { + $clearingType = Payone_Enum_ClearingType::WALLETPAYDIREKTEXPRESS; } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletPaypalExpress) { $clearingType = Payone_Enum_ClearingType::WALLETPAYPALEXPRESS; } elseif ($paymentMethod instanceof Payone_Core_Model_Payment_Method_WalletAliPay) { diff --git a/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php b/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php index 8e65f05c..ebf8a818 100644 --- a/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php +++ b/app/code/community/Payone/Core/Model/Mapper/ApiRequest/Payment/Genericpayment.php @@ -116,6 +116,28 @@ public function mapExpressCheckoutParameters($quote, $workOrderId = null) return $request; } + /** + * @return Payone_Api_Request_PaydirektExpressSetCheckout + */ + public function getPaydirektExpressInitCheckoutRequest() + { + $request = $this->getFactory()->getRequestPaydirektExpressSetCheckout(); + $this->mapDefaultParameters($request); + + return $request; + } + + /** + * @return Payone_Api_Request_PaydirektExpressGetStatus + */ + public function getPaydirektExpressGetStatusRequest() + { + $request = $this->getFactory()->getRequestPaydirektExpressGetStatus(); + $this->mapDefaultParameters($request); + + return $request; + } + /** * @param $amount * @param $sRatePayShopId diff --git a/app/code/community/Payone/Core/Model/Payment/Method/WalletPaydirektExpress.php b/app/code/community/Payone/Core/Model/Payment/Method/WalletPaydirektExpress.php new file mode 100644 index 00000000..fcfe2dc0 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Payment/Method/WalletPaydirektExpress.php @@ -0,0 +1,71 @@ + - www.fatchip.com +* @author Vincent Boulanger +* @license GNU General Public License (GPL 3) +* @link http://www.fatchip.com +*/ +class Payone_Core_Model_Payment_Method_WalletPaydirektExpress extends Payone_Core_Model_Payment_Method_Abstract +{ + /** @var string */ + protected $methodType = Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYDIREKTEXPRESS; + + /** @var string */ + protected $_code = Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS; + + /** @var string */ + protected $_formBlockType = 'payone_core/payment_method_form_wallet'; + + /** @var string */ + protected $_infoBlockType = 'payone_core/payment_method_info_wallet'; + + /** @var Payone_Core_Model_Config_Payment_Method_Interface[] */ + protected $matchingConfigs = array(); + + /** @var bool */ + protected $_canUseInternal = false; + + /** + * @api + * + * To be used in Form_Block, which has to display all wallet types + * + * @param Mage_Sales_Model_Quote $quote + * @return Payone_Core_Model_Config_Payment_Method_Interface[] + */ + public function getAllConfigsByQuote(Mage_Sales_Model_Quote $quote) + { + if (empty($this->matchingConfigs)) { + $configStore = $this->getConfigStore($quote->getStoreId()); + + $this->matchingConfigs = $configStore->getPayment()->getMethodsForQuote($this->methodType, $quote); + } + + return $this->matchingConfigs; + } + + /** + * @param string $redirectUrl + */ + public function setRedirectUrl($redirectUrl) + { + $oSession = Mage::getSingleton('checkout/session'); + $oSession->setPayoneExternalCheckoutActive(true); + $this->redirectUrl = $redirectUrl; + } +} diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Checkout.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Checkout.php new file mode 100644 index 00000000..210760b7 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Checkout.php @@ -0,0 +1,634 @@ + - www.fatchip.com + * @author Vincent Boulanger + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.com + */ +class Payone_Core_Model_Service_Paydirekt_Express_Checkout +{ + const API_VERSION = '3.10'; + + const CHECKOUT_TYPE_FOR_AUTH = 'directsale'; + const CHECKOUT_TYPE_FOR_PREAUTH = 'order'; + + const DEFAULT_SHIPPING_SKU = 'Shipping'; + const DEFAULT_DISCOUNT_SKU = 'Discount'; + + const PAYONE_PAYDIREKT_CHECKOUT_WORKORDERID = 'payone_paydirekt_checkout_workorderid'; + + const PRIVACY_POLICY_COOKIE_RESTRICTION_MODE_URL = 'privacy-policy-cookie-restriction-mode/'; + + /** @var Mage_Customer_Model_Session */ + protected $customerSession; + + /** @var Mage_Checkout_Model_Session */ + protected $checkoutSession; + + /** @var Payone_Core_Model_Factory */ + protected $factory; + + /** @var Mage_Sales_Model_Quote */ + protected $quote; + + /** @var Payone_Core_Model_Config_Payment_Method_Interface */ + protected $configPayment; + + /** @var Payone_Core_Model_Service_Payment_Genericpayment */ + protected $service; + + /** @var Payone_Api_Service_Payment_Genericpayment */ + protected $serviceApi; + + /** + * @param array $params + * @throws Exception + */ + public function __construct($params = array()) + { + if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) { + $this->quote = $params['quote']; + $this->quote->save(); + } else { + throw new Exception('Quote instance is required.'); + } + + if (isset($params['config']) && $params['config'] instanceof Payone_Core_Model_Config_Payment_Method) { + $this->configPayment = $params['config']; + } else { + throw new Exception('Config instance is required.'); + } + + $this->service = $this->getFactory()->getServicePaymentGenericpayment($this->configPayment); + $this->serviceApi = $this->getFactory()->getServiceApiPaymentGenericpayment(); + + $this->customerSession = Mage::getSingleton('customer/session'); + $this->checkoutSession = Mage::getSingleton('checkout/session'); + } + + /** + * @param Payone_Core_Model_Service_Paydirekt_Express_Request_InitCheckoutRequest $request + * + * @return Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutErrorResponse|Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutOkResponse + */ + public function initCheckout(Payone_Core_Model_Service_Paydirekt_Express_Request_InitCheckoutRequest $request) + { + $this->checkoutSession->unsLastQuoteId(); + $apiRequest = $this->_mapInitCheckoutParameters(); + + $apiResponse = $this->serviceApi->request($apiRequest); + + if ($apiResponse->getStatus() == 'ERROR') { + $response = new Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutErrorResponse(); + $response->setCode($apiResponse->getErrorcode()); + $response->setData('message', $apiResponse->getCustomermessage()); + $response->setData('errorMessage', $apiResponse->getErrormessage()); + + return $response; + } + + $response = new Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutOkResponse(); + $response->setRedirectUrl($apiResponse->getRedirecturl()); + $response->setWorkorderId($apiResponse->getWorkorderId()); + $data = $apiResponse->getRawResponse(); + if (isset($data['add_paydata[workorderid]'])) { + $response->setData( + 'add_paydata[workorderid]', + $data['add_paydata[workorderid]'] + ); + } + + return $response; + } + + /** + * @param Payone_Core_Model_Service_Paydirekt_Express_Request_GetStatusRequest $request + * @return Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusErrorResponse|Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusOkResponse + */ + public function getStatus(Payone_Core_Model_Service_Paydirekt_Express_Request_GetStatusRequest $request) + { + $apiRequest = $this->_mapGetStatusParameters($request->getWorkorderId()); + + $apiResponse = $this->serviceApi->request($apiRequest); + + if ($apiResponse->getStatus() == 'ERROR') { + $response = new Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusErrorResponse(); + $response->setCode($apiResponse->getErrorcode()); + $response->setData('message', $apiResponse->getCustomermessage()); + $response->setData('errorMessage', $apiResponse->getErrormessage()); + + return $response; + } + + $payData = $apiResponse->getPaydataArray(); + $response = new Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusOkResponse(); + $response->setWorkorderId($apiResponse->getWorkorderid()); + foreach ($payData as $key => $value) { + $response->setData($key, $value); + } + + return $response; + } + + /** + * @param string|null $workorderId + * @return Payone_Api_Request_PaydirektExpressGetStatus|Payone_Api_Request_PaydirektExpressSetCheckout + */ + protected function _mapCommonParameters($workorderId = null) + { + if(null === $workorderId) { + /** @var Payone_Api_Request_PaydirektExpressSetCheckout $request */ + $request = $this->service->getMapper() + ->getPaydirektExpressInitCheckoutRequest(); + } else { + /** @var Payone_Api_Request_PaydirektExpressGetStatus $request */ + $request = $this->service->getMapper() + ->getPaydirektExpressGetStatusRequest($this->quote, $workorderId); + $request->setWorkorderId($workorderId); + } + $request->setAid($this->configPayment->getAid()); + $request->setAmount($this->quote->getGrandTotal()); + $request->setApiVersion(self::API_VERSION); + $request->setClearingtype(Payone_Enum_ClearingType::WALLET); + $request->setCurrency($this->quote->getQuoteCurrencyCode()); + + $this->_convertRequestAmountCurrency($request, $this->quote); + + return $request; + } + + /** + * @return Payone_Api_Request_PaydirektExpressSetCheckout + * @throws Exception + */ + protected function _mapInitCheckoutParameters() + { + /** @var Payone_Api_Request_PaydirektExpressSetCheckout $request */ + $request = $this->_mapCommonParameters(); + + $paydata = $this->_initPaydata(); + $request->setPaydata($paydata); + + $request->setWallet( + new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet( + array( + 'wallettype' => Payone_Api_Enum_WalletType::PAYDIREKTEXPRESS, + 'successurl' => Mage::helper('payone_core/url')->getMagentoUrl('*/*/success'), + 'backurl' => Mage::helper('payone_core/url')->getMagentoUrl('*/*/cancel'), + 'errorurl' => Mage::helper('payone_core/url')->getMagentoUrl('*/*/error') + ) + ) + ); + + $configShippingMethod = $this->configPayment->getAssociatedShippingMethod(); + $shippingAddress = $this->quote->getShippingAddress() + ->setCountryId('DE') + ->setCity('Stadt') + ->setPostcode('12345') + ->setShippingMethod($configShippingMethod); + $shippingAddress->setCollectShippingRates(1)->collectShippingRates(); + + if (empty($shippingAddress->getShippingMethod())) { + $rates = $shippingAddress->getShippingRatesCollection()->getItems(); + if(empty($rates)) { + throw new Exception( + Mage::helper('payone_core') + ->__('Unable to initialize Paydirekt Express Checkout.') + ); + } + + $shippingMethod = array_shift($rates)->getCode(); + $shippingAddress->setShippingMethod($shippingMethod) + ->setCollectShippingRates(1) + ->collectTotals(); + + // We keep a trace that the shipping method got changed + Mage::log( + 'PAYONE - Paydirekt Express : ' + . 'configured shipping method (' . $configShippingMethod . ') was unavailable. ' + . 'It got replaced by first available method (' . $shippingMethod . ')', + Zend_Log::WARN + ); + } + + $shippingAddress->save(); + $this->quote->setShippingAddress($shippingAddress); + + $this->quote->setTotalsCollectedFlag(false); + $this->quote->collectTotals(); + + $invoicing = new Payone_Api_Request_Parameter_Invoicing_Transaction(); + $this->_initQuoteItems($invoicing); + $this->_initsetShippingItem($invoicing); + $this->_initDiscountItem($invoicing); + $request->setInvoicing($invoicing); + + // Recollect totals, as amounts got updated (shipping) + // Update request amount with new GrandTotal + $this->quote->setTotalsCollectedFlag(false) + ->setTriggerRecollect(1) + ->collectTotals() + ->save(); + $request->setAmount($this->quote->getGrandTotal()); + $this->_convertRequestAmountCurrency($request, $this->quote); + + return $request; + } + + /** + * @param string $workorderId + * @return Payone_Api_Request_PaydirektExpressGetStatus + */ + protected function _mapGetStatusParameters($workorderId) + { + /** @var Payone_Api_Request_PaydirektExpressGetStatus $request */ + $request = $this->_mapCommonParameters($workorderId); + + // PAYDATA // + $paydata = new Payone_Api_Request_Parameter_Paydata_Paydata(); + $paydata->addItem( + new Payone_Api_Request_Parameter_Paydata_DataItem( + array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYDIREKT_ECS_GET_EXPRESSCHECKOUTDETAILS) + ) + ); + $request->setPaydata($paydata); + // END PAYDATA // + + $request->setWallettype(Payone_Api_Enum_WalletType::PAYDIREKTEXPRESS); + + return $request; + } + + /** + * @param Payone_Core_Model_Service_Paydirekt_Express_Request_PrepareReviewOrderRequest $request + */ + public function prepareOrderReview(Payone_Core_Model_Service_Paydirekt_Express_Request_PrepareReviewOrderRequest $request) + { + /** @var Payone_Core_Helper_Config $configHelper */ + $configHelper = Mage::helper('payone_core/config'); + $paymentMethodCode = \Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS; + + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($request->getQuoteId()); + $paymentConfig = $configHelper->getConfigPaymentMethodForQuote( + \Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYDIREKTEXPRESS, + $quote + ); + + $billing = $quote->getBillingAddress(); + $billing->setData('should_ignore_validation', true); + $billing->setData('payment_method', $paymentMethodCode); + $billing->setFirstname($request->getBillingFirstname()) + ->setLastname($request->getBillingLastname()) + ->setEmail($request->getBillingEmail()) + ->setPostcode($request->getBillingZip()) + ->setCity($request->getBillingCity()) + ->setCountryId($request->getBillingCountry()) + ->setStreetFull( + $request->getBillingStreetname() . ' ' . $request->getBillingStreetnumber() . ', ' + . $request->getBillingAdditionaladdressinformation() + ); + if (!empty($request->getBuyerEmail())) { + $billing->setEmail($request->getBuyerEmail()); + } + $billing->save(); + + $shipping = $quote->getShippingAddress(); + $shipping->setSameAsBilling(false); + $shipping->setData('should_ignore_validation', true); + $shipping->setData('payment_method', $paymentMethodCode); + $shipping->setCollectShippingRates(true); + $shipping->setFirstname($request->getShippingFirstname()) + ->setLastname($request->getShippingLastname()) + ->setEmail($request->getShippingEmail()) + ->setPostcode($request->getShippingZip()) + ->setCity($request->getShippingCity()) + ->setCountryId($request->getShippingCountry()) + ->setStreetFull( + $request->getShippingStreetname() . ' ' . $request->getShippingStreetnumber() . ', ' + . $request->getShippingAdditionaladdressinformation() + ); + $shipping->collectShippingRates(); + $shipping->save(); + + $payment = $quote->getPayment(); + $payment->setMethod($paymentMethodCode); + $payment->setData('payone_config_payment_method_id', $paymentConfig->getId()); + $payment->setAdditionalInformation(self::PAYONE_PAYDIREKT_CHECKOUT_WORKORDERID, $request->getWorkorderid()); + $payment->save(); + + $coupon = $this->checkoutSession->getData('cart_coupon_code'); + if (!empty($coupon)) { + $this->quote->setCouponCode($coupon); + } + + $quote->collectTotals(); + $quote->save(); + } + + /** + * @param Payone_Core_Model_Service_Paydirekt_Express_Request_PlaceOrderRequest $request + * @return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface + */ + public function placeOrder(Payone_Core_Model_Service_Paydirekt_Express_Request_PlaceOrderRequest $request) + { + /** @var \Mage_Checkout_Helper_Data $checkoutHelper */ + $checkoutHelper = Mage::helper('checkout'); + $requiredAgreements = $checkoutHelper->getRequiredAgreementIds(); + if ($requiredAgreements) { + $postedAgreements = $request->getAgreements(); + $diff = array_diff($requiredAgreements, $postedAgreements); + if ($diff) { + $agreementsErrorMessage = Mage::helper('payone_core') + ->__('Please agree to all the terms and conditions before placing the order.'); + Mage::throwException($agreementsErrorMessage); + } + } + + try{ + /** @var Mage_Sales_Model_Quote $quote */ + $quote = Mage::getModel('sales/quote')->load($request->getQuoteId()); + $quote->setTotalsCollectedFlag(true); + $quote->getBillingAddress()->setData('should_ignore_validation', true); + $quote->getShippingAddress()->setData('should_ignore_validation', true); + + if (Mage::getSingleton('customer/session')->isLoggedIn()) { + $customer = Mage::getSingleton('customer/session')->getCustomer(); + $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); + $quote->setCustomerId($customer->getId()) + ->setCustomerIsGuest(false) + ->setCustomerGroupId($customerGroupId); + } else { + $quote->setCustomerId(null) + ->setCustomerIsGuest(true) + ->setCustomerEmail($quote->getBillingAddress()->getEmail()) + ->setCustomerGroupId(\Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); + } + + $quote->save(); + + /** @var Mage_Sales_Model_Service_Quote $cartService */ + $cartService = Mage::getModel('sales/service_quote', $quote); + $cartService->submitAll(); + + $this->checkoutSession->setData('last_quote_id', $quote->getId()); + $this->checkoutSession->setData('last_success_quote_id', $quote->getId()); + $this->checkoutSession->clearHelperData(); + $order = $cartService->getOrder(); + + if ($order) { + Mage::dispatchEvent( + 'checkout_type_onepage_save_order_after', + ['order' => $order, 'quote' => $quote] + ); + if ($order->getCanSendNewEmailFlag()) { + try { + $order->queueNewOrderEmail(); + } catch (Exception $e) { + Mage::logException($e); + } + } + // add order information to the session + $this->checkoutSession->setData('last_order_id', $order->getId()); + $this->checkoutSession->setData('last_real_order_id', $order->getIncrementId()); + // as well a billing agreement can be created + $agreement = $order->getPayment()->getBillingAgreement(); + if ($agreement) { + $this->checkoutSession->setData('last_billing_agreement_id', $agreement->getId()); + } + + // Set quote as inactive, as order was created successfully + $quote->setIsActive(false)->save(); + } + + Mage::dispatchEvent( + 'checkout_submit_all_after', + ['order' => $order, 'quote' => $quote, 'recurring_profiles' => []] + ); + + $response = new Payone_Core_Model_Service_Paydirekt_Express_Response_PlaceOrderOkResponse(); + } + catch (\Exception $ex) { + $response = new Payone_Core_Model_Service_Paydirekt_Express_Response_PlaceOrderErrorResponse(); + $response->setCode($ex->getCode()); + $response->setData('message', $ex->getMessage()); + } + + return $response; + } + + /** + * @param Payone_Api_Request_Genericpayment $request + * @param Mage_Sales_Model_Quote $quote + */ + protected function _convertRequestAmountCurrency(Payone_Api_Request_Genericpayment $request, Mage_Sales_Model_Quote $quote) + { + if($this->configPayment->getCurrencyConvert()) { + $request->setCurrency($quote->getBaseCurrencyCode()); + $request->setAmount($quote->getBaseGrandTotal()); + } + } + + /** + * @return Payone_Api_Request_Parameter_Paydata_Paydata + */ + protected function _initPaydata() + { + $paydata = new Payone_Api_Request_Parameter_Paydata_Paydata(); + $paydata->addItem( + new Payone_Api_Request_Parameter_Paydata_DataItem( + array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYDIREKT_ECS_SET_EXPRESSCHECKOUT) + ) + ); + + $authorization = $this->getHelperConfig() + ->getConfigPaymentMethodByType( + $this->quote->getStoreId(), + Payone_Core_Model_System_Config_PaymentMethodType::WALLETPAYDIREKTEXPRESS + )->getRequestType(); + + if ($authorization === 'authorization') { + $paydata->addItem( + new Payone_Api_Request_Parameter_Paydata_DataItem( + array('key' => 'type', 'data' => self::CHECKOUT_TYPE_FOR_AUTH) + ) + ); + } else { + $paydata->addItem( + new Payone_Api_Request_Parameter_Paydata_DataItem( + array('key' => 'type', 'data' => self::CHECKOUT_TYPE_FOR_PREAUTH) + ) + ); + } + + $paydata->addItem( + new Payone_Api_Request_Parameter_Paydata_DataItem( + array('key' => 'web_url_shipping_terms', 'data' => Mage::getBaseUrl() . self::PRIVACY_POLICY_COOKIE_RESTRICTION_MODE_URL) + ) + ); + + return $paydata; + } + + /** + * @param Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing + */ + protected function _initQuoteItems(Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing) + { + foreach ($this->quote->getItemsCollection() as $key => $itemData) { + /** @var $itemData Mage_Sales_Model_Quote_Item */ + $number = $itemData->getQty(); + if ($number <= 0 || $itemData->getParentItemId()) { + continue; // Do not map items with zero quantity + } + + $params['it'] = Payone_Api_Enum_InvoicingItemType::GOODS; + $params['id'] = $itemData->getSku(); + $params['pr'] = $this->_convertItemPrice($itemData); + $params['no'] = $number; + $params['de'] = $itemData->getName(); + $params['va'] = $itemData->getTaxPercent(); + + $item = new Payone_Api_Request_Parameter_Invoicing_Item(); + $item->init($params); + $invoicing->addItem($item); + } + } + + /** + * @param Mage_Sales_Model_Quote_Item $itemData + * @return float + */ + protected function _convertItemPrice(Mage_Sales_Model_Quote_Item $itemData) + { + // If tax is applied after discount, the item hold the tax compensation for that discount + // we have then to substract it from the item price + $dTC = $itemData->getDiscountTaxCompensation(); + if ($this->configPayment->getCurrencyConvert()) { + return $itemData->getBasePriceInclTax() - $dTC; + } + + return $itemData->getPriceInclTax() - $dTC; + } + + /** + * @param Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing + */ + protected function _initsetShippingItem(Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing) + { + $configMiscShipping = $this->getHelperConfig()->getConfigMisc($this->quote->getStoreId())->getShippingCosts(); + $sku = $configMiscShipping->getSku(); + if (!empty($sku)) { + $sku = $this->getFactory()->helper()->__(self::DEFAULT_SHIPPING_SKU); + } + + $shippingVatRatio = $this->quote->getShippingAddress()->getShippingTaxAmount() + / $this->quote->getShippingAddress()->getShippingAmount(); + if (is_nan($shippingVatRatio) || !is_numeric($shippingVatRatio)) { + $shippingVatRatio = 0; + } + + $params['it'] = Payone_Api_Enum_InvoicingItemType::SHIPMENT; + $params['id'] = $sku; + $params['pr'] = $this->_convertShippingAmount($this->quote->getShippingAddress()); + $params['no'] = 1; + $params['de'] = 'Shipping Costs'; + $params['va'] = round($shippingVatRatio * 100, 2); + + $item = new Payone_Api_Request_Parameter_Invoicing_Item(); + $item->init($params); + $invoicing->addItem($item); + } + + /** + * @param Mage_Sales_Model_Quote_Address $shippingAddress + * @return float + */ + protected function _convertShippingAmount(Mage_Sales_Model_Quote_Address $shippingAddress) + { + if ($this->configPayment->getCurrencyConvert()) { + return $shippingAddress->getBaseShippingInclTax(); + } + + return $shippingAddress->getShippingInclTax(); + } + + /** + * @param Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing + */ + protected function _initDiscountItem(Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing) + { + $discountAmount = $this->_convertDiscountAmount(); + if ($discountAmount != 0) { + $configMiscDiscount = $this->getHelperConfig()->getConfigMisc()->getDiscount(); + $sku = $configMiscDiscount->getSku(); + $description = $configMiscDiscount->getDescription(); + if (empty($sku)) { + $sku = $this->getFactory()->helper()->__(self::DEFAULT_DISCOUNT_SKU); + } + + if (empty($description)) { + $description = $this->getFactory()->helper()->__(self::DEFAULT_DISCOUNT_SKU); + } + + $params['it'] = Payone_Api_Enum_InvoicingItemType::VOUCHER; + $params['id'] = $sku; + $params['de'] = $description; + $params['no'] = 1; + $params['pr'] = $discountAmount; + $params['va'] = 0; + + $item = new Payone_Api_Request_Parameter_Invoicing_Item(); + $item->init($params); + + $invoicing->addItem($item); + } + } + + /** + * @return float + */ + protected function _convertDiscountAmount() + { + if ($this->configPayment->getCurrencyConvert()) { + return $this->quote->getShippingAddress()->getBaseDiscountAmount(); + } + + return $this->quote->getShippingAddress()->getDiscountAmount(); + } + + /** + * @return Payone_Core_Helper_Config + */ + protected function getHelperConfig() + { + return $this->getFactory()->helperConfig(); + } + + /** + * @return Payone_Core_Model_Factory + */ + public function getFactory() + { + if ($this->factory === null) { + $this->factory = Mage::getModel('payone_core/factory'); + } + + return $this->factory; + } +} diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/GetStatusRequest.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/GetStatusRequest.php new file mode 100644 index 00000000..94733003 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/GetStatusRequest.php @@ -0,0 +1,86 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Request_GetStatusRequest + implements Payone_Core_Model_Service_Paydirekt_Express_RequestInterface +{ + /** @var Mage_Sales_Model_Quote */ + protected $quote; + /** @var string */ + protected $workorderId; + + /** + * @param string $quoteId + * @param string $workorderId + */ + public function __construct($quoteId, $workorderId = null) + { + if (!empty($quoteId)) { + $this->quote = Mage::getModel('sales/quote') + ->load($quoteId); + } else { + throw new InvalidArgumentException('Quote instance is required.'); + } + + $this->workorderId = $workorderId; + } + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_RequestInterface::INIT_CHECKOUT_REQUEST_TYPE; + } + + /** + * @param Mage_Sales_Model_Quote $quote + */ + public function setQuote($quote) + { + $this->quote = $quote; + } + + /** + * @return Mage_Sales_Model_Quote + */ + public function getQuote() + { + return $this->quote; + } + + /** + * @param string $workorderId + */ + public function setWorkorderId($workorderId) + { + $this->workorderId = $workorderId; + } + + /** + * @return string + */ + public function getWorkorderId() + { + return $this->workorderId; + } +} diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/InitCheckoutRequest.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/InitCheckoutRequest.php new file mode 100644 index 00000000..2f4809ca --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/InitCheckoutRequest.php @@ -0,0 +1,86 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Request_InitCheckoutRequest + implements Payone_Core_Model_Service_Paydirekt_Express_RequestInterface +{ + /** @var Mage_Sales_Model_Quote */ + protected $quote; + /** @var string */ + protected $workorderId; + + /** + * @param string $quoteId + * @param string $workorderId + */ + public function __construct($quoteId, $workorderId = null) + { + if (!empty($quoteId)) { + $this->quote = Mage::getModel('sales/quote') + ->load($quoteId); + } else { + throw new InvalidArgumentException('Quote instance is required.'); + } + + $this->workorderId = $workorderId; + } + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_RequestInterface::INIT_CHECKOUT_REQUEST_TYPE; + } + + /** + * @param Mage_Sales_Model_Quote $quote + */ + public function setQuote($quote) + { + $this->quote = $quote; + } + + /** + * @return Mage_Sales_Model_Quote + */ + public function getQuote() + { + return $this->quote; + } + + /** + * @param string $workorderId + */ + public function setWorkorderId($workorderId) + { + $this->workorderId = $workorderId; + } + + /** + * @return string + */ + public function getWorkorderId() + { + return $this->workorderId; + } +} diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/PlaceOrderRequest.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/PlaceOrderRequest.php new file mode 100644 index 00000000..f78d7293 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/PlaceOrderRequest.php @@ -0,0 +1,78 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Request_PlaceOrderRequest + implements Payone_Core_Model_Service_Paydirekt_Express_RequestInterface +{ + /** @var string */ + protected $quoteId; + /** @var array */ + protected $agreements = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_RequestInterface::PLACE_ORDER_REQUEST_TYPE; + } + + /** + * @return string + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param string $quoteId + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + } + + /** + * @return array + */ + public function getAgreements() + { + return $this->agreements; + } + + /** + * @param string $agreement + */ + public function addAgreement($agreement) + { + array_push($this->agreements, $agreement); + } + + /** + * @param array $agreements + */ + public function setAgreements($agreements) + { + $this->agreements = $agreements; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/PrepareReviewOrderRequest.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/PrepareReviewOrderRequest.php new file mode 100644 index 00000000..f9714536 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Request/PrepareReviewOrderRequest.php @@ -0,0 +1,252 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Request_PrepareReviewOrderRequest + implements Payone_Core_Model_Service_Paydirekt_Express_RequestInterface +{ + /** @var array */ + protected $data = array(); + /** @var string */ + protected $quoteId; + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_RequestInterface::PREPARE_REVIEW_ORDER_REQUEST_TYPE; + } + + /** + * @return string + */ + public function getQuoteId() + { + return $this->quoteId; + } + + /** + * @param string $quoteId + */ + public function setQuoteId($quoteId) + { + $this->quoteId = $quoteId; + } + + /** + * @return string + */ + public function getBuyerEmail() + { + return $this->_getData('buyer_email'); + } + + /** + * @return string + */ + public function getBillingFirstname() + { + return $this->_getData('billing_firstname'); + } + + /** + * @return string + */ + public function getBillingLastname() + { + return $this->_getData('billing_lastname'); + } + + /** + * @return string + */ + public function getBillingStreetname() + { + return $this->_getData('billing_streetname'); + } + + /** + * @return string + */ + public function getBillingStreetnumber() + { + return $this->_getData('billing_streetnumber'); + } + + /** + * @return string + */ + public function getBillingCity() + { + return $this->_getData('billing_city'); + } + + /** + * @return string + */ + public function getBillingZip() + { + return $this->_getData('billing_zip'); + } + + /** + * @return string + */ + public function getBillingCountry() + { + return $this->_getData('billing_country'); + } + + /** + * @return string + */ + public function getBillingCompany() + { + return $this->_getData('billing_company'); + } + + /** + * @return string + */ + public function getBillingAdditionaladdressinformation() + { + return $this->_getData('billing_additionaladdressinformation'); + } + + /** + * @return string + */ + public function getBillingEmail() + { + return $this->_getData('billing_email'); + } + + /** + * @return string + */ + public function getShippingFirstname() + { + return $this->_getData('shipping_firstname'); + } + + /** + * @return string + */ + public function getShippingLastname() + { + return $this->_getData('shipping_lastname'); + } + + /** + * @return string + */ + public function getShippingStreetname() + { + return $this->_getData('shipping_streetname'); + } + + /** + * @return string + */ + public function getShippingStreetnumber() + { + return $this->_getData('shipping_streetnumber'); + } + + /** + * @return string + */ + public function getShippingCity() + { + return $this->_getData('shipping_city'); + } + + /** + * @return string + */ + public function getShippingZip() + { + return $this->_getData('shipping_zip'); + } + + /** + * @return string + */ + public function getShippingCountry() + { + return $this->_getData('shipping_country'); + } + + /** + * @return string + */ + public function getShippingCompany() + { + return $this->_getData('shipping_company'); + } + + /** + * @return string + */ + public function getShippingAdditionaladdressinformation() + { + return $this->_getData('shipping_additionaladdressinformation'); + } + + /** + * @return string + */ + public function getShippingEmail() + { + return $this->_getData('shipping_email'); + } + + /** + * @return string + */ + public function getWorkorderid() + { + return $this->_getData('workorderid'); + } + + /** + * @param array $data + */ + public function setData(array $data) + { + $this->data = $data; + } + + /** + * @param string $key + * @return string + */ + private function _getData($key) + { + if (!isset($this->data[$key])) { + return ''; + } + + return $this->data[$key]; + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/RequestInterface.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/RequestInterface.php new file mode 100644 index 00000000..6cfd41a6 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/RequestInterface.php @@ -0,0 +1,33 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +interface Payone_Core_Model_Service_Paydirekt_Express_RequestInterface +{ + const INIT_CHECKOUT_REQUEST_TYPE = 'init_checkout'; + const PREPARE_REVIEW_ORDER_REQUEST_TYPE = 'prepare_review_order'; + const PLACE_ORDER_REQUEST_TYPE = 'place_order'; + + /** + * @return string + */ + public function getType(); +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/GetStatusErrorResponse.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/GetStatusErrorResponse.php new file mode 100644 index 00000000..68553233 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/GetStatusErrorResponse.php @@ -0,0 +1,92 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusErrorResponse + implements Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + /** @var int */ + protected $code; + /** @var array */ + protected $data = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::FETCH_CHECKOUT_ERROR_RESPONSE_TYPE; + } + + /** + * @return int + */ + public function getCode() + { + return $this->code; + } + + /** + * @param int $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null) + { + if ($key == null) { + return $this->data; + } + + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @return string + */ + public function __toString() + { + $data = array(); + $data['code'] = $this->code; + $data['data'] = $this->data; + + return json_encode($data); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/GetStatusOkResponse.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/GetStatusOkResponse.php new file mode 100644 index 00000000..2177dbed --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/GetStatusOkResponse.php @@ -0,0 +1,100 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusOkResponse + implements Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + /** @var string */ + protected $workorderId; + /** @var array */ + protected $data = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::FETCH_CHECKOUT_OK_RESPONSE_TYPE; + } + + /** + * @return int + */ + public function getCode() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::FETCH_CHECKOUT_OK_RESPONSE_CODE; + } + + /** + * @param string $workorderId + */ + public function setWorkorderId($workorderId) + { + $this->workorderId = $workorderId; + } + + /** + * @return string + */ + public function getWorkorderId() + { + return $this->workorderId; + } + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null) + { + if ($key == null) { + return $this->data; + } + + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * @return string + */ + public function __toString() + { + $data = array(); + $data['code'] = $this->code; + $data['data'] = $this->data; + + return json_encode($data); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/InitCheckoutErrorResponse.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/InitCheckoutErrorResponse.php new file mode 100644 index 00000000..2aafdb78 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/InitCheckoutErrorResponse.php @@ -0,0 +1,92 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutErrorResponse + implements Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + /** @var int */ + protected $code; + /** @var array */ + protected $data = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::INIT_CHECKOUT_ERROR_RESPONSE_TYPE; + } + + /** + * @return int + */ + public function getCode() + { + return $this->code; + } + + /** + * @param int $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null) + { + if ($key == null) { + return $this->data; + } + + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @return string + */ + public function __toString() + { + $data = array(); + $data['code'] = $this->code; + $data['data'] = $this->data; + + return json_encode($data); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/InitCheckoutOkResponse.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/InitCheckoutOkResponse.php new file mode 100644 index 00000000..ea72e36f --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/InitCheckoutOkResponse.php @@ -0,0 +1,118 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutOkResponse + implements Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + /** @var string */ + protected $redirectUrl; + /** @var string */ + protected $workorderId; + /** @var array */ + protected $data = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::INIT_CHECKOUT_OK_RESPONSE_TYPE; + } + + /** + * @return int + */ + public function getCode() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::INIT_CHECKOUT_OK_RESPONSE_CODE; + } + + /** + * @param string $redirectUrl + */ + public function setRedirectUrl($redirectUrl) + { + $this->redirectUrl = $redirectUrl; + } + + /** + * @return string + */ + public function getRedirectUrl() + { + return $this->redirectUrl; + } + + /** + * @param string $workorderId + */ + public function setWorkorderId($workorderId) + { + $this->workorderId = $workorderId; + } + + /** + * @return string + */ + public function getWorkorderId() + { + return $this->workorderId; + } + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null) + { + if ($key == null) { + return $this->data; + } + + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * @return string + */ + public function __toString() + { + $data = array(); + $data['code'] = $this->code; + $data['data'] = $this->data; + + return json_encode($data); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/PlaceOrderErrorResponse.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/PlaceOrderErrorResponse.php new file mode 100644 index 00000000..ba79116f --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/PlaceOrderErrorResponse.php @@ -0,0 +1,92 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Response_PlaceOrderErrorResponse + implements Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + /** @var int */ + protected $code; + /** @var array */ + protected $data = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::PLACE_ORDER_ERROR_RESPONSE_TYPE; + } + + /** + * @return int + */ + public function getCode() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::PLACE_ORDER_ERROR_RESPONSE_CODE; + } + + /** + * @param int $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null) + { + if ($key == null) { + return $this->data; + } + + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @return string + */ + public function __toString() + { + $data = array(); + $data['code'] = $this->code; + $data['data'] = $this->data; + + return json_encode($data); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/PlaceOrderOkResponse.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/PlaceOrderOkResponse.php new file mode 100644 index 00000000..ac26f974 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/Response/PlaceOrderOkResponse.php @@ -0,0 +1,92 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_Service_Paydirekt_Express_Response_PlaceOrderOkResponse + implements Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + /** @var int */ + protected $code = Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::PLACE_ORDER_OK_RESPONSE_CODE; + /** @var array */ + protected $data = array(); + + /** + * @return string + */ + public function getType() + { + return Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::PLACE_ORDER_OK_RESPONSE_TYPE; + } + + /** + * @return int + */ + public function getCode() + { + return $this->code; + } + + /** + * @param int $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null) + { + if ($key == null) { + return $this->data; + } + + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value) + { + $this->data[$key] = $value; + } + + /** + * @return string + */ + public function __toString() + { + $data = array(); + $data['code'] = $this->code; + $data['data'] = $this->data; + + return json_encode($data); + } +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/ResponseInterface.php b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/ResponseInterface.php new file mode 100644 index 00000000..c9de95f1 --- /dev/null +++ b/app/code/community/Payone/Core/Model/Service/Paydirekt/Express/ResponseInterface.php @@ -0,0 +1,65 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +interface Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface +{ + const INIT_CHECKOUT_OK_RESPONSE_TYPE = 'init_checkout_ok'; + const INIT_CHECKOUT_ERROR_RESPONSE_TYPE = 'init_checkout_error'; + const FETCH_CHECKOUT_OK_RESPONSE_TYPE = 'fetch_checkout_ok'; + const FETCH_CHECKOUT_ERROR_RESPONSE_TYPE = 'fetch_checkout_error'; + const PLACE_ORDER_OK_RESPONSE_TYPE = 'place_order_ok'; + const PLACE_ORDER_ERROR_RESPONSE_TYPE = 'place_order_error'; + + const INIT_CHECKOUT_OK_RESPONSE_CODE = 200; + const INIT_CHECKOUT_ERROR_RESPONSE_CODE = 400; + const FETCH_CHECKOUT_OK_RESPONSE_CODE = 200; + const FETCH_CHECKOUT_ERROR_RESPONSE_CODE = 400; + const PLACE_ORDER_OK_RESPONSE_CODE = 200; + const PLACE_ORDER_ERROR_RESPONSE_CODE = 400; + + /** + * @return string + */ + public function getType(); + + /** + * @return int + */ + public function getCode(); + + /** + * @param string $key + * @return mixed + */ + public function getData($key = null); + + /** + * @param string $key + * @param string $value + */ + public function setData($key, $value); + + /** + * @return string + */ + public function __toString(); +} \ No newline at end of file diff --git a/app/code/community/Payone/Core/Model/System/Config/PaymentMethodCode.php b/app/code/community/Payone/Core/Model/System/Config/PaymentMethodCode.php index a32660d4..25631d4a 100644 --- a/app/code/community/Payone/Core/Model/System/Config/PaymentMethodCode.php +++ b/app/code/community/Payone/Core/Model/System/Config/PaymentMethodCode.php @@ -61,6 +61,7 @@ class Payone_Core_Model_System_Config_PaymentMethodCode extends Payone_Core_Mode const PAYOLUTIONINSTALLMENT = 'payone_payolution_installment'; const PAYMENTGUARANTEEINVOICE = 'payone_payment_guarantee_invoice'; const WALLETPAYDIREKT = 'payone_wallet_paydirekt'; + const WALLETPAYDIREKTEXPRESS = 'payone_wallet_paydirekt_express'; const WALLETPAYPALEXPRESS = 'payone_wallet_paypal_express'; const WALLETALIPAY = 'payone_wallet_alipay'; const MASTERPASS = 'payone_masterpass'; @@ -90,6 +91,7 @@ public function toArray() self::PAYOLUTIONINSTALLMENT => 'Paysafe Pay Later™ Installment', self::PAYMENTGUARANTEEINVOICE => 'Invoice with Payment Guarantee', self::WALLETPAYDIREKT => 'Paydirekt', + self::WALLETPAYDIREKTEXPRESS => 'Paydirekt Express', self::WALLETPAYPALEXPRESS => 'Paypal Express', self::WALLETALIPAY => 'AliPay', self::ONLINEBANKTRANSFERSOFORT => 'Sofortueberweisung', diff --git a/app/code/community/Payone/Core/Model/System/Config/PaymentMethodType.php b/app/code/community/Payone/Core/Model/System/Config/PaymentMethodType.php index 4cf72e86..fd62f409 100644 --- a/app/code/community/Payone/Core/Model/System/Config/PaymentMethodType.php +++ b/app/code/community/Payone/Core/Model/System/Config/PaymentMethodType.php @@ -59,6 +59,7 @@ class Payone_Core_Model_System_Config_PaymentMethodType extends Payone_Core_Mode const PAYOLUTIONINSTALLMENT = 'payolution_installment'; const PAYMENTGUARANTEEINVOICE = 'payment_guarantee_invoice'; const WALLETPAYDIREKT = 'wallet_paydirekt'; + const WALLETPAYDIREKTEXPRESS = 'wallet_paydirekt_express'; const WALLETPAYPALEXPRESS = 'wallet_paypal_express'; const WALLETALIPAY = 'wallet_alipay'; const MASTERPASS = 'masterpass'; @@ -89,6 +90,7 @@ public function toArray() self::PAYOLUTIONINSTALLMENT => 'Paysafe Pay Later™ Installment', self::PAYMENTGUARANTEEINVOICE => 'Invoice with Payment Guarantee', self::WALLETPAYDIREKT => 'Paydirekt', + self::WALLETPAYDIREKTEXPRESS => 'Paydirekt Express', self::WALLETPAYPALEXPRESS => 'Paypal Express', self::WALLETALIPAY => 'AliPay', self::ONLINEBANKTRANSFERSOFORT => 'Sofortueberweisung', diff --git a/app/code/community/Payone/Core/Model/System/Config/ShippingMethodCode.php b/app/code/community/Payone/Core/Model/System/Config/ShippingMethodCode.php new file mode 100644 index 00000000..de47fbab --- /dev/null +++ b/app/code/community/Payone/Core/Model/System/Config/ShippingMethodCode.php @@ -0,0 +1,51 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ + +/** + * + * @category Payone + * @package Payone_Core_Model + * @subpackage System + * @copyright Copyright (c) 2019 - www.fatchip.de + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_Model_System_Config_ShippingMethodCode extends Payone_Core_Model_System_Config_Abstract +{ + /** + * @return array + */ + public function toArray() + { + $carriers = Mage::getSingleton('shipping/config')->getActiveCarriers(); + $methods = array(); + foreach ($carriers as $carrierCode => $carrier) { + $allowedMethods = $carrier->getAllowedMethods(); + foreach ($allowedMethods as $methodCode => $methodLabel) { + $methods[$carrierCode . '_' . $methodCode] = strtoupper($carrierCode) . ' - ' . $methodLabel; + } + } + + return $methods; + } +} diff --git a/app/code/community/Payone/Core/controllers/PaydirektExpressController.php b/app/code/community/Payone/Core/controllers/PaydirektExpressController.php new file mode 100644 index 00000000..a6d386a2 --- /dev/null +++ b/app/code/community/Payone/Core/controllers/PaydirektExpressController.php @@ -0,0 +1,340 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Core_PaydirektExpressController extends Payone_Core_Controller_Abstract +{ + const CART_URL = 'checkout/cart'; + const REVIEW_URL = 'payone_core/paydirektExpress/review'; + const SUCCESS_REDIRECT_URL = 'payone_core/paydirektExpress/orderSuccess'; + + /** @var Payone_Core_Model_Service_Paydirekt_Express_Checkout */ + protected $_checkoutService = null; + /** @var Payone_Core_Model_Config_Payment_Method */ + protected $_config = null; + /** @var Mage_Sales_Model_Quote */ + protected $_quote = false; + + /** + * Start the checkout process on paydirekt side, through a request + */ + public function initCheckoutAction() + { + try { + $request = new Payone_Core_Model_Service_Paydirekt_Express_Request_InitCheckoutRequest( + $this->_getCheckoutSession()->getQuoteId() + ); + + $response = $this->_getCheckoutService()->initCheckout($request); + + if ($response instanceof Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutOkResponse) { + $this->_getSession()->setWorkOrderId($response->getWorkorderId()); + $this->_getCheckoutSession()->setPayoneExternalCheckoutActive(true); + $this->_getCheckoutSession()->setPaydirektExpressCheckoutActive(true); + if ($response->getRedirectUrl()) { + $this->_redirectUrl($response->getRedirectUrl()); + return; + } + } elseif ($response instanceof Payone_Core_Model_Service_Paydirekt_Express_Response_InitCheckoutErrorResponse) { + $this->_getCheckoutSession()->addError($response->getData('message')); + } + } catch (Mage_Core_Exception $e) { + $this->_getCheckoutSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getCheckoutSession()->addError($this->__('Unable to start Paydirekt Express Checkout.')); + Mage::logException($e); + } + + $this->_redirect(self::CART_URL); + } + + /** + * Handles the return from the initialisation of the checkout + */ + public function successAction() + { + try { + $request = new Payone_Core_Model_Service_Paydirekt_Express_Request_GetStatusRequest( + $this->_getCheckoutSession()->getQuoteId(), + $this->_getSession()->getWorkOrderId() + ); + + $response = $this->_getCheckoutService()->getStatus($request); + + if ($response instanceof Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusOkResponse) { + $request = new Payone_Core_Model_Service_Paydirekt_Express_Request_PrepareReviewOrderRequest(); + $request->setData($response->getData()); + $request->setQuoteId($this->_getCheckoutSession()->getQuoteId()); + $this->_getCheckoutService()->prepareOrderReview($request); + + $this->_redirect(self::REVIEW_URL); + return; + } elseif ($response instanceof Payone_Core_Model_Service_Paydirekt_Express_Response_GetStatusErrorResponse) { + $this->_getCheckoutSession()->addError($response->getData('message')); + } + + } catch (Mage_Core_Exception $e) { + $this->_getCheckoutSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getCheckoutSession()->addError($this->__('Unable to proceed with Paydirekt Express Checkout.')); + Mage::logException($e); + } + + $this->_redirect(self::CART_URL); + } + + public function errorAction() + { + $this->_getCheckoutSession()->unsPayoneExternalCheckoutActive(); + $this->_getCheckoutSession()->unsPaydirektExpressCheckoutActive(); + $this->_getCheckoutSession()->addError($this->__('An error occured during the Paydirekt Express Checkout.')); + $this->_redirect(self::CART_URL); + } + + public function cancelAction() + { + $this->_getCheckoutSession()->unsPayoneExternalCheckoutActive(); + $this->_getCheckoutSession()->unsPaydirektExpressCheckoutActive(); + $this->_getCheckoutSession()->addSuccess($this->__('The Paydirekt Express Checkout has been canceled.')); + $this->_redirect(self::CART_URL); + } + + /** + * Prepares and displays the review page to check the order before confirmation + */ + public function reviewAction() + { + try { + $quoteId = $this->_getCheckoutSession()->getQuoteId(); + $customerId = $this->_getSession()->getData('customerId'); + if ($customerId) { + $customer = $this->getFactory()->getModelCustomer()->load($customerId); + $this->_getCustomerSession() + ->setCustomerAsLoggedIn($customer) + ->setCustomerGroupId($customer->getGroupId()); + } + + $this->loadLayout(); + $this->_initLayoutMessages('checkout/session'); + + /** @var Payone_Core_Block_Paydirekt_Express_Review $reviewBlock */ + $reviewBlock = $this->getLayout()->getBlock('paydirekt.express.review'); + $reviewBlock->setQuoteId($quoteId); + + /** @var Payone_Core_Block_Paydirekt_Express_Review_Billing $billing */ + $billing = $reviewBlock->getLayout() + ->createBlock('payone_core/paydirekt_express_review_billing') + ->setBlockId('paydirekt.express.review.billing') + ->setTemplate('payone/core/paydirekt/express/review/billing.phtml'); + $billing->setQuoteId($quoteId); + $billing->init(); + + /** @var Payone_Core_Block_Paydirekt_Express_Review_Shipping $shipping */ + $shipping = $reviewBlock->getLayout() + ->createBlock('payone_core/paydirekt_express_review_shipping') + ->setBlockId('paydirekt.express.review.shipping') + ->setTemplate('payone/core/paydirekt/express/review/shipping.phtml'); + $shipping->setQuoteId($quoteId); + $shipping->init(); + + /** @var Payone_Core_Block_Paydirekt_Express_Review_ShippingMethod $shippingMethod */ + $shippingMethod = $reviewBlock->getLayout() + ->createBlock('payone_core/paydirekt_express_review_shippingMethod') + ->setBlockId('paydirekt.express.review.shippingmethod') + ->setTemplate('payone/core/paydirekt/express/review/shipping_method.phtml'); + $shippingMethod->setQuoteId($quoteId); + $shippingMethod->init(); + + /** @var Payone_Core_Block_Paydirekt_Express_Review_PaymentMethod $paymentMethod */ + $paymentMethod = $reviewBlock->getLayout() + ->createBlock('payone_core/paydirekt_express_review_paymentMethod') + ->setBlockId('paydirekt.express.review.paymentmethod') + ->setTemplate('payone/core/paydirekt/express/review/payment_method.phtml'); + $paymentMethod->setQuoteId($quoteId); + $paymentMethod->init(); + + /** @var Payone_Core_Block_Paydirekt_Express_Review_Items $itemsReview */ + $itemsReview = $reviewBlock->getLayout() + ->createBlock('payone_core/paydirekt_express_review_items') + ->setBlockId('paydirekt.express.review.items') + ->setTemplate('payone/core/paydirekt/express/review/items.phtml'); + $itemsReview->setQuoteId($quoteId); + $itemsReview->init(); + + /** @var Mage_Checkout_Block_Agreements $checkoutAgreements */ + $checkoutAgreements = $reviewBlock->getLayout() + ->createBlock('checkout/agreements') + ->setBlockId('paydirekt.express.review.checkoutagreements') + ->setTemplate('checkout/onepage/agreements.phtml'); + + $reviewBlock->setBilling($billing); + $reviewBlock->setShipping($shipping); + $reviewBlock->setShippingMethod($shippingMethod); + $reviewBlock->setPaymentMethod($paymentMethod); + $reviewBlock->setItemsReview($itemsReview); + $reviewBlock->setCheckoutAgreements($checkoutAgreements); + + $this->renderLayout(); + return; + } catch (Mage_Core_Exception $e) { + $this->_getCheckoutSession()->addError($e->getMessage()); + } catch (Exception $e) { + $this->_getCheckoutSession()->addError($this->__('Unable to proceed with Paydirekt Express Checkout review.')); + Mage::logException($e); + } + + $this->_redirect(self::CART_URL); + return; + } + + /** + * Submits the order + */ + public function placeOrderAction() + { + try { + $request = new Payone_Core_Model_Service_Paydirekt_Express_Request_PlaceOrderRequest(); + $request->setQuoteId($this->_getCheckoutSession()->getQuoteId()); + foreach ($this->getRequest()->get('agreement') as $agreement) { + $request->addAgreement($agreement); + } + + /** @var Payone_Core_Model_Service_Paydirekt_EXpress_ResponseInterface $response */ + $response = $this->_getCheckoutService()->placeOrder($request); + + if ($response instanceof Payone_Core_Model_Service_Paydirekt_Express_Response_PlaceOrderErrorResponse) { + Mage::log($response->getData('message')); + + $redirectUrl = Mage::getUrl(self::REVIEW_URL); + } + else { + $this->_getCheckoutSession()->unsPayoneExternalCheckoutActive(); + $this->_getCheckoutSession()->unsPaydirektExpressCheckoutActive(); + $redirectUrl = Mage::getUrl(self::SUCCESS_REDIRECT_URL); + } + + $response->setData('redirectUrl', $redirectUrl); + } + catch (Exception $ex) { + $response = json_encode( + array( + 'code' => Payone_Core_Model_Service_Paydirekt_Express_ResponseInterface::PLACE_ORDER_ERROR_RESPONSE_CODE, + 'data' => array( + 'message' => $ex->getMessage() + ) + ) + ); + } + + echo $response; + } + + /** + * Handles the successful placement of the order, redirecting to success page eventually + */ + protected function orderSuccessAction() + { + $session = $this->_getCheckoutSession(); + $lastOrderId = $session->getLastOrderId(); + $session->clear(); + $this->loadLayout(); + $this->_initLayoutMessages('checkout/session'); + Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId))); + $this->renderLayout(); + } + + /** + * @return Payone_Core_Model_Service_Paydirekt_Express_Checkout + */ + protected function _getCheckoutService() + { + if (!$this->_checkoutService) { + if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) { + $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden'); + Mage::throwException(Mage::helper('payone_core')->__('Unable to initialize Paydirekt Express Checkout.')); + } + + $this->_checkoutService = Mage::getModel( + 'payone_core/service_paydirekt_express_checkout', array( + 'quote' => $this->_getQuote(), + 'config' => $this->_getConfig(), + ) + ); + } + + return $this->_checkoutService; + } + + /** + * @return Payone_Core_Model_Config_Payment_Method + */ + protected function _getConfig() + { + if (!$this->_config) { + $quote = $this->_getQuote(); + $methodInstance = Mage::helper('payment')->getMethodInstance(Payone_Core_Model_System_Config_PaymentMethodCode::WALLETPAYDIREKTEXPRESS); + $this->_config = $methodInstance->getConfigForQuote($quote); + } + + return $this->_config; + } + + /** + * Return checkout quote object + * + * @return Mage_Sales_Model_Quote + */ + protected function _getQuote() + { + if (!$this->_quote) { + $this->_quote = $this->_getCheckoutSession()->getQuote(); + } + + return $this->_quote; + } + + /** + * Return checkout session object + * + * @return Mage_Checkout_Model_Session + */ + protected function _getCheckoutSession() + { + return Mage::getSingleton('checkout/session'); + } + + /** + * Payone session instance getter + * + * @return Payone_Core_Model_Session + */ + protected function _getSession() + { + return Mage::getSingleton('payone_core/session'); + } + + /** + * @return Mage_Customer_Model_Session + */ + protected function _getCustomerSession() + { + return Mage::getSingleton('customer/session'); + } +} diff --git a/app/code/community/Payone/Core/etc/config.xml b/app/code/community/Payone/Core/etc/config.xml index 90e5b82c..ae08f71c 100644 --- a/app/code/community/Payone/Core/etc/config.xml +++ b/app/code/community/Payone/Core/etc/config.xml @@ -29,7 +29,7 @@ - 4.4.0 + 4.4.1 @@ -298,6 +298,10 @@ * + + + * + * @@ -831,6 +835,11 @@ payone_core/payment_method_walletPaydirekt payone + + PAYONE - Paydirekt Express + payone_core/payment_method_walletPaydirektExpress + payone + PAYONE - Paypal Express payone_core/payment_method_walletPaypalExpress @@ -904,6 +913,9 @@ 1 + + 1 + 1 @@ -978,6 +990,7 @@ a:1:{s:18:"_2496553448474_474";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} a:1:{s:18:"_1910987005853_853";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} a:1:{s:18:"_1514988840741_741";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} + a:1:{s:18:"_1514988840741_742";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} a:1:{s:18:"_2177301865940_940";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} a:1:{s:18:"_2339656494812_812";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} a:1:{s:18:"_1926207461842_842";a:2:{s:8:"txaction";a:1:{i:0;s:9:"appointed";}s:12:"state_status";a:1:{i:0;s:21:"processing|processing";}}} diff --git a/app/code/community/Payone/Core/etc/system.xml b/app/code/community/Payone/Core/etc/system.xml index dd8961d8..3c818d46 100644 --- a/app/code/community/Payone/Core/etc/system.xml +++ b/app/code/community/Payone/Core/etc/system.xml @@ -413,6 +413,15 @@ 1 1 + + + payone_core/adminhtml_system_config_form_field_statusMapping + payone_core/system_config_backend_serialized_array + 70 + 1 + 1 + 1 + payone_core/adminhtml_system_config_form_field_statusMapping @@ -670,6 +679,37 @@ + + + text + 120 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + + image + adminhtml/system_config_backend_image + payone + payone + 20 + 1 + 1 + 1 + Allowed file types: jpeg, gif, png. + + + @@ -1453,6 +1493,25 @@ + + + text + 5 + 1 + 1 + 1 + + + + select + payone_core/system_config_shippingMethodCode + 990 + 1 + 1 + 1 + + + text diff --git a/app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-4.4.0-4.4.1.php b/app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-4.4.0-4.4.1.php new file mode 100644 index 00000000..7e264ed9 --- /dev/null +++ b/app/code/community/Payone/Core/sql/payone_core_setup/mysql4-upgrade-4.4.0-4.4.1.php @@ -0,0 +1,58 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ + +/** @var $this Mage_Core_Model_Resource_Setup */ +/** @var $installer Mage_Core_Model_Resource_Setup */ + +$installer = $this; +$installer->startSetup(); + +$tablePaymentMethod = $this->getTable('payone_core/config_payment_method'); + +/** @var $helper Payone_Core_Helper_Data */ +$helper = Mage::helper('payone_core'); +$useSqlInstaller = $helper->mustUseSqlInstaller(); + +if ($useSqlInstaller) { + $sql = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'upgrade-4.4.0-4.4.1.sql'); + + $installSqlConfig = [ + '{{payone_config_payment_method}}' => $tablePaymentMethod + ]; + + $installSql = str_replace(array_keys($installSqlConfig), array_values($installSqlConfig), $sql); + $installer->run($installSql); +} else { + $connection = $installer->getConnection(); + + // Alter table payone_config_payment_method + $connection->addColumn($tablePaymentMethod, 'associated_shipping_method', [ + 'TYPE' => Varien_Db_Ddl_Table::TYPE_TEXT, + 'LENGTH' => 50, + 'NULLABLE' => true, + 'DEFAULT' => null, + 'COMMENT' => 'associated_shipping_method', + ]); +} + +$installer->endSetup(); diff --git a/app/code/community/Payone/Core/sql/payone_core_setup/upgrade-4.4.0-4.4.1.sql b/app/code/community/Payone/Core/sql/payone_core_setup/upgrade-4.4.0-4.4.1.sql new file mode 100644 index 00000000..33b9bacf --- /dev/null +++ b/app/code/community/Payone/Core/sql/payone_core_setup/upgrade-4.4.0-4.4.1.sql @@ -0,0 +1,6 @@ +#-------------------------------------------------------------------------------------------------------------- +# Alter tables payone_config_payment_method, add columns for shipping method (related to PaydirektExpress) +#-------------------------------------------------------------------------------------------------------------- + +ALTER TABLE `{{payone_config_payment_method}}` + ADD `associated_shipping_method` VARCHAR(50) NULL COMMENT 'associated_shipping_method'; \ No newline at end of file diff --git a/app/design/frontend/base/default/layout/payone/core.xml b/app/design/frontend/base/default/layout/payone/core.xml index 1481fe11..dad1f35d 100644 --- a/app/design/frontend/base/default/layout/payone/core.xml +++ b/app/design/frontend/base/default/layout/payone/core.xml @@ -124,6 +124,65 @@ + + + + + + + + + + + payone/core/paydirektexpress.css + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -146,6 +205,12 @@ after + + + 1 + after + + 1 @@ -164,6 +229,12 @@ after + + + 1 + after + + @@ -179,6 +250,10 @@ + + + @@ -187,6 +262,10 @@ + + + diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/review.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review.phtml new file mode 100644 index 00000000..05e03340 --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review.phtml @@ -0,0 +1,104 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> +getQuote(); + +?> + +
+

__('Checkout with Paydirekt') ?>

+
+getMessagesBlock()->toHtml() ?> + +
+

__('Billing Information') ?>

+
+ getBilling()->toHtml(); + ?> +
+
+ getPaymentMethod()->toHtml(); + ?> +
+
+
+

__('Shipping Information') ?>

+
+ getShipping()->toHtml(); + ?> +
+
+ getShippingMethod()->toHtml(); + ?> + +
+
+
+

__('Review items and totals') ?>

+
+
+ getItemsReview()->toHtml(); + ?> +
+
+
+
+ getCheckoutAgreements()->toHtml(); + ?> +
+
+
+ +
+ + + diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/billing.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/billing.phtml new file mode 100644 index 00000000..897c2918 --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/billing.phtml @@ -0,0 +1,61 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> + +
+
+

__('Contact details') ?>

+
+
+ + + + + + + + + + + + + + +
__("Name :") ?> + getFirstname(); ?>  + getLastname(); ?> +
__("Email :") ?>getEmail(); ?>
__("Address :") ?> +

getStreet(); ?>

+

+ getZip(); ?>  + getCity(); ?>  + getState())) { ?> + (getState(); ?>)  + + getCountry(); ?> +

+
+
+
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/items.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/items.phtml new file mode 100644 index 00000000..74a2cca9 --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/items.phtml @@ -0,0 +1,31 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> + +
+ +
+ + diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/payment_method.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/payment_method.phtml new file mode 100644 index 00000000..a08a17bb --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/payment_method.phtml @@ -0,0 +1,41 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> + +
+
+

__('Payment Method') ?>

+
+
+ + + + + +
__("Payment Method") ?> :getPaymentMethod(); ?>
+
+
+ + diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/shipping.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/shipping.phtml new file mode 100644 index 00000000..12e9b1c3 --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/shipping.phtml @@ -0,0 +1,62 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> + +
+
+

__('Shipping Address') ?>

+
+
+ + + + + + getPhone())) { ?> + + + + + + + + + +
__("Name :") ?> + getFirstname(); ?>  + getLastname(); ?> +
__("Phone :") ?>getPhone(); ?>
__("Address :") ?> +

getStreet(); ?>

+

+ getZip(); ?>  + getCity(); ?>  + getState())) { ?> + (getState(); ?>)  + + getCountry(); ?> +

+
+
+
\ No newline at end of file diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/shipping_method.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/shipping_method.phtml new file mode 100644 index 00000000..a217d7f9 --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/review/shipping_method.phtml @@ -0,0 +1,41 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> + +
+
+

__('Shipping method') ?>

+
+
+ + + + + +
__("Shipping method") ?> :getShippingMethod(); ?>
+
+
+ + diff --git a/app/design/frontend/base/default/template/payone/core/paydirekt/express/shortcut.phtml b/app/design/frontend/base/default/template/payone/core/paydirekt/express/shortcut.phtml new file mode 100644 index 00000000..dff1bfe6 --- /dev/null +++ b/app/design/frontend/base/default/template/payone/core/paydirekt/express/shortcut.phtml @@ -0,0 +1,42 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +?> + +isPaydirektExpressActive()) : ?> + isApplicable()) : ?> + + + diff --git a/app/design/frontend/rwd/default/layout/payone/core.xml b/app/design/frontend/rwd/default/layout/payone/core.xml index 1d817dc8..0e9c72aa 100644 --- a/app/design/frontend/rwd/default/layout/payone/core.xml +++ b/app/design/frontend/rwd/default/layout/payone/core.xml @@ -126,6 +126,65 @@
+ + + + + + + + + + + payone/core/paydirektexpress.css + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -148,6 +207,12 @@ after + + + 1 + after + + 1 @@ -166,6 +231,12 @@ after + + + 1 + after + + @@ -181,6 +252,10 @@ + + + @@ -189,6 +264,10 @@ + + + diff --git a/app/locale/de_DE/Payone_Core.csv b/app/locale/de_DE/Payone_Core.csv index 5243d4e6..487572ea 100644 --- a/app/locale/de_DE/Payone_Core.csv +++ b/app/locale/de_DE/Payone_Core.csv @@ -120,6 +120,9 @@ "New Paydirekt","Wallet Paydirekt" "Add Paydirekt","Wallet Paydirekt hinzufügen" "Edit Paydirekt","Wallet Paydirekt bearbeiten" +"New Paydirekt Express","Wallet Paydirekt Express" +"Add Paydirekt Express","Wallet Paydirekt Express hinzufügen" +"Edit Paydirekt Express","Wallet Paydirekt Express bearbeiten" "New Paypal Express","Wallet Paypal Express" "Add Paypal Express","Wallet Paypal Express hinzufügen" "Edit Paypal Express","Wallet Paypal Express bearbeiten" @@ -425,6 +428,7 @@ Debit type used for payment by installments,"Debittyp, der für die Ratenzahlung ">>>SDK TRANSLATIONS<<<",">>>SDK TRANSLATIONS<<<" "PAYPAL_EXPRESS","Paypal Express" "PAYDIREKT","Paydirekt" +"PAYDIREKT_EXPRESS","Paydirekt Express" "YES","Ja" "NO","Nein" @@ -541,6 +545,7 @@ DIRECT_DEBIT,Lastschrift "CASHONDELIVERY","Nachnahme" "WALLET","Wallet" "WALLETPAYDIREKT", "Paydirekt" +"WALLETPAYDIREKTEXPRESS", "Paydirekt Express" "WALLETPAYPALEXPRESS", "Paypal Express" "WALLETALIPAY", "AliPay" @@ -1273,3 +1278,5 @@ RatePay Debit Type,RatePay Ratenkauf Typ "AMAZONPAY_MFA_FAILED", "Beim Zahlungsvorgang ist ein Problem aufgetreten. Ihre Bestellung wurde nicht aufgegeben und Ihr Konto nicht belastet." "AMAZONPAY_MFA_ABANDONED", "Mit dieser Zahlungsart ist ein Problem aufgetreten. Um Ihre Bestellung abzuschließen, wählen Sie bitte eine andere aus." + +"Unable to initialize Paydirekt Express Checkout.","Der Paydirekt Express Checkout konnte nicht initialisiert werden." \ No newline at end of file diff --git a/js/payone/core/paydirektexpress.js b/js/payone/core/paydirektexpress.js new file mode 100644 index 00000000..373a898b --- /dev/null +++ b/js/payone/core/paydirektexpress.js @@ -0,0 +1,108 @@ +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the GNU General Public License (GPL 3) + * that is bundled with this package in the file LICENSE.txt + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Payone_Core to newer + * versions in the future. If you wish to customize Payone_Core for your + * needs please refer to http://www.payone.de for more information. + * + * @category Payone + * @package js + * @subpackage payone + * @copyright Copyright (c) 2019 - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +var PayoneCheckout = { + shippingMethodCode: false, + baseUrl: "", + placeOrderUrl: "payone_core/paydirektExpress/placeOrder", + reloadReviewUrl: "checkout/onepage/review/", + init: function (baseUrl) { + this.baseUrl = baseUrl; + + var button = jQuery('#placeOrder'); + button.on('click', function () { + window.placeOrder(PayoneCheckout.getPlaceOrderUrl()); + }); + + this.reloadReview(); + }, + reloadReview: function () { + jQuery.ajax( + { + url: this.getReloadReviewUrl(), + error: function (result) { + console.log(result); + }, + success: function (result) { + var review = jQuery(result).filter('#checkout-review-table-wrapper'); + var container = jQuery('#checkout-review-load'); + container.html(review); + }, + complete: function(request, status) { + window.unlockActivity(); + } + } + ); + }, + getPlaceOrderUrl: function () { + return this.baseUrl + this.placeOrderUrl; + }, + getReloadReviewUrl: function () { + return this.baseUrl + this.reloadReviewUrl; + } +}; + +window.placeOrder = function (url) { + var agreementCollection = jQuery("[id^=agreement-]"); + var agreement = []; + agreementCollection.each(function() { + if (this.checked) { + var index = $(this).attr("name").match(/.*\[(.*)\]/); + if (index.length > 1) { + agreement.push(index[1]); + } + } + }); + + window.lockActivity(); + jQuery.ajax( + { + url: url, + data: { + agreement: agreement + }, + error: function(result) { + window.unlockActivity(); + alert('An error occurred during the Paydirekt Express Checkout.'); + }, + success: function (result) { + window.unlockActivity(); + + var response = JSON.parse(result); + if (response.code !== 200) { + alert(response.data.message); + return; + } + + window.location = response.data.redirectUrl; + } + } + ); +}; + +window.lockActivity = function() { + var fadeOut = jQuery('.fadeOut'); + fadeOut.show(); +}; +window.unlockActivity = function() { + var fadeOut = jQuery('.fadeOut'); + fadeOut.hide(); +}; \ No newline at end of file diff --git a/lib/Payone/Api/Enum/GenericpaymentAction.php b/lib/Payone/Api/Enum/GenericpaymentAction.php index 0e8fb5ee..266e3520 100644 --- a/lib/Payone/Api/Enum/GenericpaymentAction.php +++ b/lib/Payone/Api/Enum/GenericpaymentAction.php @@ -57,4 +57,7 @@ class Payone_Api_Enum_GenericpaymentAction const MASTERPASS_SET_CHECKOUT = 'setcheckout'; const MASTERPASS_GET_CHECKOUT = 'getcheckout'; + + const PAYDIREKT_ECS_SET_EXPRESSCHECKOUT = 'checkout'; + const PAYDIREKT_ECS_GET_EXPRESSCHECKOUTDETAILS = 'getstatus'; } diff --git a/lib/Payone/Api/Enum/WalletType.php b/lib/Payone/Api/Enum/WalletType.php index 4e742129..16411c68 100644 --- a/lib/Payone/Api/Enum/WalletType.php +++ b/lib/Payone/Api/Enum/WalletType.php @@ -74,6 +74,7 @@ class Payone_Api_Enum_WalletType const AMAZONPAY = 'AMZ'; const PAYPAL_EXPRESS = 'PPE'; const PAYDIREKT = 'PDT'; + const PAYDIREKTEXPRESS = 'PDT'; const ALIPAY = 'ALP'; const MASTERPASS = 'MPA'; diff --git a/lib/Payone/Api/Mapper/Request/Payment/Genericpayment.php b/lib/Payone/Api/Mapper/Request/Payment/Genericpayment.php index 7758e204..51db901c 100644 --- a/lib/Payone/Api/Mapper/Request/Payment/Genericpayment.php +++ b/lib/Payone/Api/Mapper/Request/Payment/Genericpayment.php @@ -34,6 +34,14 @@ public function map(Payone_Api_Request_Interface $request) $this->mapAmount($request); } + if ($request instanceof Payone_Api_Request_PaydirektExpressSetCheckout && $request->getInvoicing()) { + foreach ($request->getInvoicing()->getItems() as $invoicingItem) { + $invoicingItem->setPr( + round($invoicingItem->getPr(), 2) * 100 + ); + } + } + return $request->toArray(); } diff --git a/lib/Payone/Api/Request/PaydirektExpressGetStatus.php b/lib/Payone/Api/Request/PaydirektExpressGetStatus.php new file mode 100644 index 00000000..62502bea --- /dev/null +++ b/lib/Payone/Api/Request/PaydirektExpressGetStatus.php @@ -0,0 +1,53 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Api_Request_PaydirektExpressGetStatus + extends Payone_Api_Request_Genericpayment +{ + /** @var string */ + protected $wallettype; + + /** + * @param array $data + */ + public function __construct(array $data = array()) + { + $this->request = Payone_Api_Enum_RequestType::GENERICPAYMENT; + parent::__construct($data); + } + + /** + * @param string $wallettype + */ + public function setWallettype($wallettype) + { + $this->wallettype = $wallettype; + } + + /** + * @return string + */ + public function getWallettype() + { + return $this->wallettype; + } +} diff --git a/lib/Payone/Api/Request/PaydirektExpressSetCheckout.php b/lib/Payone/Api/Request/PaydirektExpressSetCheckout.php new file mode 100644 index 00000000..0f5f4bce --- /dev/null +++ b/lib/Payone/Api/Request/PaydirektExpressSetCheckout.php @@ -0,0 +1,70 @@ + - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +class Payone_Api_Request_PaydirektExpressSetCheckout + extends Payone_Api_Request_Genericpayment +{ + /** @var Payone_Api_Request_Parameter_Invoicing_Transaction */ + protected $invoicing = null; + /** @var string */ + protected $wallettype; + + /** + * @param array $data + */ + public function __construct(array $data = array()) + { + parent::__construct($data); + } + + /** + * @param string $wallettype + */ + public function setWallettype($wallettype) + { + $this->wallettype = $wallettype; + } + + /** + * @return string + */ + public function getWallettype() + { + return $this->wallettype; + } + + /** + * @param Payone_Api_Request_Parameter_Invoicing_Transaction $invoicing + */ + public function setInvoicing($invoicing) + { + $this->invoicing = $invoicing; + } + + /** + * @return Payone_Api_Request_Parameter_Invoicing_Transaction + */ + public function getInvoicing() + { + return $this->invoicing; + } +} diff --git a/lib/Payone/Enum/ClearingType.php b/lib/Payone/Enum/ClearingType.php index 4dd98cd2..6fc5262f 100644 --- a/lib/Payone/Enum/ClearingType.php +++ b/lib/Payone/Enum/ClearingType.php @@ -72,6 +72,7 @@ class Payone_Enum_ClearingType const MASTERPASS = 'wlt'; const WALLETALIPAY = 'wlt'; const WALLETPAYDIREKT = 'wlt'; + const WALLETPAYDIREKTEXPRESS = 'wlt'; const WALLETPAYPALEXPRESS = 'wlt'; const WALLET = 'wlt'; // Default wlt mapping } diff --git a/skin/frontend/base/default/payone/core/paydirektexpress.css b/skin/frontend/base/default/payone/core/paydirektexpress.css new file mode 100644 index 00000000..15984c86 --- /dev/null +++ b/skin/frontend/base/default/payone/core/paydirektexpress.css @@ -0,0 +1,86 @@ +/** + * + * NOTICE OF LICENSE + * + * This source file is subject to the GNU General Public License (GPL 3) + * that is bundled with this package in the file LICENSE.txt + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Payone_Core to newer + * versions in the future. If you wish to customize Payone_Core for your + * needs please refer to http://www.payone.de for more information. + * + * @category Payone + * @package skin_adminhtml_default_default + * @subpackage payone_core + * @copyright Copyright (c) 2019 - www.fatchip.de + * @author FATCHIP GmbH + * @license GNU General Public License (GPL 3) + * @link http://www.fatchip.de + */ +.table-label { + vertical-align: text-top; +} +.table-value { + padding-left: 10px; +} + +#shippingMethodsDiv .sp-methods dd input.radio { + float: left; + margin-right: -40px; + margin-top: 10px; + margin-left: 15px; +} +#shippingMethodsDiv .sp-methods dd label { + font-size: 14px !important; + font-weight: normal !important; + color: #636363; + background-color: #f4f4f4; + padding: 6px 10px 6px 40px; + display: inline-block; + width: auto; + max-width: none; + min-width: 250px; + float: none; +} +#shippingMethodsDiv .sp-methods dd span ~ label { + padding-left: 15px !important; +} +#shippingMethodsDiv .sp-methods dd input ~ label:hover, +#shippingMethodsDiv .sp-methods dd input:hover ~ label { + background-color: #ececec; +} + +.paydirekt-logo { + border: 0; +} +.paydirekt-logo a img { + max-height: 42px; +} + +.fadeOut { + display: none; + position: fixed; + z-index: 1; + top: 0; + left: 0; + height: 100vh; + width: 100vw; + font-size: 30px; + background: rgba(255, 255, 255, 0.75); +} +.fadeOut div { + position: fixed; + top: 50vh; + left: 50vw; + width: 300px; + text-align: center; +} +.fadeOut div span { + position: relative; + left: -150px; +} +.fadeOut div span img { + margin-right: 16px; +} \ No newline at end of file