_pricePattern, '', $row['price']); $price = Zend_Locale_Math::round($price, 2); $promoValue = preg_replace($this->_pricePattern, '', $row['promoValue']); if ($promoValue > 0) { if ($row['promoType'] == App_ECommerce_Promo_Admin_View::PROMO_TYPE_PERCENT) { $promoPrice = Zend_Locale_Math::Mul($row['price'], $row['promoValue'], 4); $promoPrice = Zend_Locale_Math::Div($promoPrice, 100, 4); } else { $promoPrice = $promoValue; } $promoPrice = Zend_Locale_Math::round($promoPrice, 2); $price = Zend_Locale_Math::Sub($price, $promoPrice, 2); } $item = array( 'id' => $row['productId'], 'price' => $price, 'quantity' => (int) $row['quantity'], 'description' => $row['title'], ); $data['items'][] = $item; } if ($orderData['promo'] > 0) { $data['items'][] = array( 'id' => 'PROMO', 'price' => Zend_Locale_Math::round($orderData['promo'], 2), 'quantity' => 1, 'description' => 'Promo Code Discount', ); } if ($orderData['giftCard'] > 0) { $data['items'][] = array( 'id' => 'GIFT', 'price' => Zend_Locale_Math::round($orderData['giftCard'], 2), 'quantity' => 1, 'description' => 'Gift Card Discount', ); } // billing info $data['billingInfo'] = array( 'name' => $orderData['billingFirstName']. ' ' . $orderData['billingLastName'], 'address1' => $orderData['billingAddress'], 'city' => $orderData['billingCity'], 'state' => $orderData['billingState'], 'zip' => $orderData['billingZip'], //'phone' => preg_replace('/[^0-9]+/', '', $orderData['billingPhone']), // треба додати поле на форму чекауту 'email' => $orderData['billingEmail'], ); if (!empty($orderData['userId'])) { $data['billingInfo']['userid'] = $orderData['userId']; } // shipping info $data['shippingInfo'] = array( 'name' => $orderData['shippingFirstName'] . ' ' . $orderData['shippingLastName'], 'address1' => $orderData['shippingAddress'], 'city' => $orderData['shippingCity'], 'state' => $orderData['shippingState'], 'zip' => $orderData['shippingZip'], ); // order info $checkout = new App_ECommerce_Checkout_Obj(); $transactionId = $checkout->getTransactionId(); $data['orderId'] = $transactionId; $data['invoiceId'] = $orderData['invoice']; $data['tax'] = $orderData['tax']; $shipping = Zend_Locale_Math::round($orderData['shippingRate'], 2); if ($orderData['shippingHandling'] > 0) { $shippingHandling = Zend_Locale_Math::round($orderData['shippingHandling'], 2); $shipping = Zend_Locale_Math::Add($shipping, $shippingHandling, 2); $shipping = Zend_Locale_Math::round($shipping, 2); } $data['shipping'] = $shipping; $data['total'] = $orderData['total']; //card info $expirationDate = strtotime($orderData['expirationDate']); $data['cardnumber'] = $orderData['cardNumber']; $data['cardexpmonth'] = date('m', $expirationDate); $data['cardexpyear'] = date('Y', $expirationDate); $data['cvmvalue'] = $orderData['cardCode']; $data['cvmindicator'] = 'provided'; return $data; } public function getErrors() { $paymentData = $this->getProcessResponse()->getData(); return $paymentData['r_error']; } public function process($data = array(), $type = null) { parent::process($data, $type); if ($this->getProcessResponse()->isSuccess()) { $paymentData = $this->_payment->getOption('data'); $this->getPayment()->updateOrder($paymentData['invoiceId']); } return $this; } }