/** * Returns the configuration attribute definitions of the provider to generate a list of available fields and * rules for the value of each field in the frontend. * * @param MShop_Order_Item_Base_Interface $basket Basket object * @return array List of attribute definitions implementing MW_Common_Critera_Attribute_Interface */ public function getConfigFE(MShop_Order_Item_Base_Interface $basket) { $list = array(); $feconfig = $this->_feConfig; try { $address = $basket->getAddress(); if (($fn = $address->getFirstname()) !== '' && ($ln = $address->getLastname()) !== '') { $feconfig['directdebit.accountowner']['default'] = $fn . ' ' . $ln; } } catch (MShop_Order_Exception $e) { } // If address isn't available foreach ($feconfig as $key => $config) { $list[$key] = new MW_Common_Criteria_Attribute_Default($config); } return $list; }
/** * Returns an list of order data required by PayPal. * * @param MShop_Order_Item_Base_Interface $orderBase Order base item * @return array Associative list of key/value pairs with order data required by PayPal */ protected function _getOrderDetails(MShop_Order_Item_Base_Interface $orderBase) { $values = $this->_getAuthParameter(); try { $orderAddressDelivery = $orderBase->getAddress(MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY); /* setting up the shipping address details (ReviewOrder) */ $values['ADDROVERRIDE'] = 1; $values['PAYMENTREQUEST_0_SHIPTONAME'] = $orderAddressDelivery->getFirstName() . ' ' . $orderAddressDelivery->getLastName(); $values['PAYMENTREQUEST_0_SHIPTOSTREET'] = $orderAddressDelivery->getAddress1() . ' ' . $orderAddressDelivery->getAddress2() . ' ' . $orderAddressDelivery->getAddress3(); $values['PAYMENTREQUEST_0_SHIPTOCITY'] = $orderAddressDelivery->getCity(); $values['PAYMENTREQUEST_0_SHIPTOSTATE'] = $orderAddressDelivery->getState(); $values['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $orderAddressDelivery->getCountryId(); $values['PAYMENTREQUEST_0_SHIPTOZIP'] = $orderAddressDelivery->getPostal(); } catch (Exception $e) { } // If no address is available $lastPos = 0; foreach ($orderBase->getProducts() as $product) { $lastPos = $product->getPosition() - 1; $values['L_PAYMENTREQUEST_0_NUMBER' . $lastPos] = $product->getId(); $values['L_PAYMENTREQUEST_0_NAME' . $lastPos] = $product->getName(); $values['L_PAYMENTREQUEST_0_QTY' . $lastPos] = $product->getQuantity(); $values['L_PAYMENTREQUEST_0_AMT' . $lastPos] = $product->getPrice()->getValue(); } foreach ($orderBase->getServices() as $service) { if (($val = $service->getPrice()->getValue()) > '0.00') { $lastPos++; $values['L_PAYMENTREQUEST_0_NAME' . $lastPos] = $service->getName(); $values['L_PAYMENTREQUEST_0_QTY' . $lastPos] = '1'; $values['L_PAYMENTREQUEST_0_AMT' . $lastPos] = $val; } } $paymentItem = $orderBase->getService('payment'); if (($paymentCosts = $paymentItem->getPrice()->getCosts()) > '0.00') { $lastPos++; $values['L_PAYMENTREQUEST_0_NAME' . $lastPos] = $this->_getContext()->getI18n()->dt('mshop', 'Payment costs'); $values['L_PAYMENTREQUEST_0_QTY' . $lastPos] = '1'; $values['L_PAYMENTREQUEST_0_AMT' . $lastPos] = $paymentCosts; } $price = $orderBase->getPrice(); $amount = $price->getValue() + $price->getCosts(); $values['MAXAMT'] = $amount + 0.01; // @todo rounding error? $values['PAYMENTREQUEST_0_AMT'] = number_format($amount, 2, '.', ''); $values['PAYMENTREQUEST_0_ITEMAMT'] = (string) ($price->getValue() + $paymentCosts); $values['PAYMENTREQUEST_0_SHIPPINGAMT'] = (string) ($price->getCosts() - $paymentCosts); $values['PAYMENTREQUEST_0_INSURANCEAMT'] = '0.00'; $values['PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED'] = 'false'; $values['PAYMENTREQUEST_0_SHIPDISCAMT'] = '0.00'; $values['PAYMENTREQUEST_0_TAXAMT'] = $price->getTaxRate(); $values['PAYMENTREQUEST_0_CURRENCYCODE'] = $orderBase->getPrice()->getCurrencyId(); $values['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->_getConfigValue(array('paypalexpress.PaymentAction'), 'sale'); try { $orderServiceDeliveryItem = $orderBase->getService('delivery'); $values['L_SHIPPINGOPTIONAMOUNT0'] = (string) ($price->getCosts() - $paymentCosts); $values['L_SHIPPINGOPTIONLABEL0'] = $orderServiceDeliveryItem->getName(); $values['L_SHIPPINGOPTIONNAME0'] = $orderServiceDeliveryItem->getCode(); $values['L_SHIPPINGOPTIONISDEFAULT0'] = 'true'; } catch (Exception $e) { } // If no delivery service is available return $values; }