コード例 #1
0
ファイル: Orderstored.php プロジェクト: xiaoguizhidao/bb
 /**
  * Get the original order's increment ID
  * 
  * @return string
  */
 public function getOrderIncrementId()
 {
     if (!is_null($this->_storedOrder)) {
         return $this->_storedOrder->getIncrementId();
     }
     return '';
 }
コード例 #2
0
ファイル: ResponseProcessor.php プロジェクト: alexkuk/Magento
 /**
  * @return string JSON encoded answer to the WayForPay gateway
  */
 protected function _getAnswerToGateWay()
 {
     $responseToGateway = array('orderReference' => $this->_order->getIncrementId(), 'status' => 'accept', 'time' => time());
     $sign = array();
     foreach ($responseToGateway as $dataKey => $dataValue) {
         $sign[] = $dataValue;
     }
     $sign = implode(WayForPay_Payment_Helper_Data::SIGNATURE_SEPARATOR, $sign);
     $sign = hash_hmac('md5', $sign, $this->_paymentMethod->getConfigData('secret_key'));
     $responseToGateway['signature'] = $sign;
     return json_encode($responseToGateway);
 }
コード例 #3
0
ファイル: Observer.php プロジェクト: aplazame/magento
 /**
  * @param Mage_Sales_Model_Order $order
  * @return bool
  */
 protected function is_aplazame_payment($order)
 {
     $code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
     /** @var Mage_Sales_Model_Order $parentOrder */
     $parentOrder = Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId());
     return $code == $parentOrder->getPayment()->getMethod();
 }
コード例 #4
0
 /**
  * Processes payment for specified order
  * @param Mage_Sales_Model_Order $Order
  * @return
  */
 public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null)
 {
     $amount = $Order->getGrandTotal();
     $increment = $Order->getIncrementId();
     $VendorTxCode = $increment . "-" . date("y-m-d-H-i-s", time()) . "-" . rand(0, 1000000);
     $model = Mage::getModel('sarp/protxDirect')->load($this->getSubscription()->getId(), 'subscription_id');
     $data = array('VPSProtocol' => self::PROTOCOL_VERSION, 'TxType' => self::REPEAT, 'Vendor' => Mage::getStoreConfig(self::VENDOR), 'VendorTxCode' => $VendorTxCode, 'Amount' => $amount, 'Currency' => $Order->getOrderCurrencyCode(), 'Description' => 'Order', 'RelatedVPSTxId' => $model->getVpsTxId(), 'RelatedVendorTxCode' => $model->getVendorTxCode(), 'RelatedSecurityKey' => $model->getSecurityKey(), 'RelatedTxAuthNo' => $model->getTxAuthNo());
     $ready = array();
     foreach ($data as $key => $value) {
         $ready[] = $key . '=' . $value;
     }
     $str = implode('&', $ready);
     switch (Mage::getStoreConfig(self::MODE)) {
         case 'test':
             $url = self::TEST_REPEAT_URL;
             break;
         case 'live':
             $url = self::LIVE_REPEAT_URL;
             break;
         default:
             $url = self::SIMULATOR_REPEAT_URL;
     }
     $ready = $this->requestPost($url, $str);
     if (empty($ready)) {
         throw new AW_Sarp_Exception($this->__("Order cannot be completed. Unknown error"));
     }
     if ($ready['Status'] != 'OK') {
         throw new AW_Sarp_Exception($ready['Status'] . " - " . $ready['StatusDetail']);
     }
 }
コード例 #5
0
ファイル: Create.php プロジェクト: romfr/payone-magento
 /**
  * @param Mage_Sales_Model_Order $order
  * @param Payone_Api_Response_Interface $response
  * @param Payone_Api_Request_Interface $request
  * @throws Payone_Core_Exception_TransactionAlreadyExists
  * @return null|Payone_Core_Model_Domain_Transaction
  */
 public function createByApiResponse(Mage_Sales_Model_Order $order, Payone_Api_Response_Interface $response, Payone_Api_Request_Interface $request)
 {
     $transaction = $this->getFactory()->getModelTransaction();
     $transaction->load($response->getTxid(), 'txid');
     // should not exist but to be sure load by txid
     if ($transaction->hasData()) {
         throw new Payone_Core_Exception_TransactionAlreadyExists($response->getTxid());
     }
     $transaction->setTxid($response->getTxid());
     $transaction->setLastTxaction($response->getStatus());
     $transaction->setUserid($response->getUserid());
     $transaction->setStoreId($order->getStoreId());
     $transaction->setOrderId($order->getId());
     $transaction->setReference($order->getIncrementId());
     $transaction->setCurrency($order->getOrderCurrencyCode());
     $transaction->setCustomerId($order->getCustomerId());
     $transaction->setClearingtype($request->getClearingtype());
     $transaction->setMode($request->getMode());
     $transaction->setMid($request->getMid());
     $transaction->setAid($request->getAid());
     $transaction->setPortalid($request->getPortalid());
     $transaction->setLastSequencenumber(0);
     $data = $response->toArray();
     $transaction->addData($data);
     $transaction->save();
     return $transaction;
 }
コード例 #6
0
ファイル: View.php プロジェクト: votanlean/Magento-Pruebas
 /**
  * Retrieve order item value by key
  *
  * @param Mage_Sales_Model_Order $order
  * @param string $key
  * @return string
  */
 public function getOrderItemValue(Mage_Sales_Model_Order $order, $key)
 {
     $escape = true;
     switch ($key) {
         case 'order_increment_id':
             $value = $order->getIncrementId();
             break;
         case 'created_at':
             $value = $this->helper('core')->formatDate($order->getCreatedAt(), 'short', true);
             break;
         case 'shipping_address':
             $value = $order->getShippingAddress() ? $this->htmlEscape($order->getShippingAddress()->getName()) : $this->__('N/A');
             break;
         case 'order_total':
             $value = $order->formatPrice($order->getGrandTotal());
             $escape = false;
             break;
         case 'status_label':
             $value = $order->getStatusLabel();
             break;
         case 'view_url':
             $value = $this->getUrl('*/order/view', array('order_id' => $order->getId()));
             break;
         default:
             $value = $order->getData($key) ? $order->getData($key) : $this->__('N/A');
     }
     return $escape ? $this->escapeHtml($value) : $value;
 }
コード例 #7
0
 public function generateOrderArray(Mage_Sales_Model_Order $order)
 {
     $array = array('@context' => 'http://schema.org', '@type' => 'Order', 'merchant' => array('@type' => 'Organization', 'name' => $order->getStore()->getFrontendName()), 'orderNumber' => $order->getIncrementId(), 'priceCurrency' => $order->getOrderCurrency()->toString(), 'price' => (string) number_format($order->getBaseTotalDue(), 2), 'acceptedOffer' => $this->generateAcceptedOfferArray($order));
     if (!$order->getCustomerIsGuest()) {
         $array['url'] = $this->getViewOrderUrl($order);
     }
     return $array;
 }
コード例 #8
0
 /**
  * Adds information to based on the order object inside magento
  *
  * @param Mage_Sales_Model_Order $order
  * @return Bitpay_Core_Model_Invoice
  */
 public function prepateWithOrder($order)
 {
     if (false === isset($order) || true === empty($order)) {
         \Mage::helper('bitpay')->debugData('[ERROR] In Bitpay_Core_Model_Invoice::prepateWithOrder(): Missing or empty $order parameter.');
         throw new \Exception('In Bitpay_Core_Model_Invoice::prepateWithOrder(): Missing or empty $order parameter.');
     }
     $this->addData(array('quote_id' => $order->getQuoteId(), 'increment_id' => $order->getIncrementId()));
     return $this;
 }
コード例 #9
0
 /**
  * Send PDF to customer, add status history comment to order.
  *
  * @param stdClass $response
  * @param Mage_Sales_Model_Order $order
  * @return Dhl_OnlineRetoure_AddressController
  */
 protected function _printPdf(stdClass $response, Mage_Sales_Model_Order $order)
 {
     $localeDate = Mage::app()->getLocale()->date($response->issueDate);
     $filenameDate = Mage::getSingleton('core/date')->date('Y-m-d', $response->issueDate);
     $this->_prepareDownloadResponse(sprintf("%s_Return_%s_%s.pdf", str_replace(" ", "_", Mage::app()->getStore()->getName()), $order->getIncrementId(), $filenameDate), base64_decode($response->label), 'application/pdf');
     $comment = 'Return label with ident code (IDC) %s successfully created on %s.';
     $order->addStatusHistoryComment($this->__($comment, $response->idc, $localeDate))->setIsVisibleOnFront(true)->save();
     Mage::helper("dhlonlineretoure/validate")->logSuccess();
     return $this;
 }
コード例 #10
0
ファイル: Data.php プロジェクト: shashankkanungo/magento
 public function getReviewVendorUrl(Mage_Sales_Model_Order $order, $vendorId)
 {
     $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
     if ($orderId = $order->getIncrementId()) {
         if ($customerId = $customer->getId()) {
             $url = Mage::getUrl('vendor/review/write', array('vendor_id' => $vendorId, 'customer_id' => $customerId, 'order_id' => $orderId, 'hash' => $this->hashKey($customerId, $vendorId, $orderId)));
             return $url;
         }
     }
     return '';
 }
コード例 #11
0
 /**
  * Make stored value card payloads for any redeemed
  * gift cards
  *
  * @param Mage_Sales_Model_Order $order
  * @param IPaymentContainer      $paymentContainer
  * @param SplObjectStorage       $processedPayments
  */
 public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments)
 {
     foreach ($this->_giftcardContainer->getRedeemedGiftcards() as $giftcard) {
         $iterable = $paymentContainer->getPayments();
         $payload = $iterable->getEmptyStoredValueCardPayment();
         $payload->setOrderId($order->getIncrementId())->setTenderType($giftcard->getTenderType())->setAccountUniqueId($giftcard->getCardNumber())->setPanIsToken((bool) $giftcard->getPanIsToken())->setCreateTimestamp($giftcard->getRedeemedAt())->setAmount($giftcard->getAmountRedeemed())->setPin($giftcard->getPin())->setPaymentRequestId($giftcard->getRedeemRequestId());
         // add the new payload
         $iterable->OffsetSet($payload, $payload);
         // put the payment in the processed payments set
         $processedPayments->attach($giftcard);
     }
 }
コード例 #12
0
ファイル: Order.php プロジェクト: aplazame/magento
 public static function crateFromOrder(Mage_Sales_Model_Order $order)
 {
     $aOrder = new self();
     $aOrder->id = $order->getIncrementId();
     $aOrder->currency = $order->getOrderCurrencyCode();
     $aOrder->total_amount = Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getTotalDue());
     $aOrder->articles = array_map(array('Aplazame_Aplazame_BusinessModel_Article', 'crateFromOrderItem'), $order->getAllVisibleItems());
     if (($discounts = $order->getDiscountAmount()) !== null) {
         $aOrder->discount = Aplazame_Sdk_Serializer_Decimal::fromFloat(-$discounts);
     }
     return $aOrder;
 }
コード例 #13
0
ファイル: Push.php プロジェクト: technomagegithub/olgo.nl
 /**
  * Send the shop owner and subscribers to the debug-email an email with the message that there is a double transaction
  */
 protected function _sendDoubleTransactionEmail()
 {
     $helper = Mage::helper('buckaroo3extended');
     $orderId = $this->_order->getIncrementId();
     $currentOrderStatus = $this->_order->getStatus();
     $recipients = explode(',', Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/debug_email', $this->getStoreId()));
     $recipients[] = Mage::getStoreConfig('trans_email/ident_general/email');
     $mail = $helper->__('Status Success received for order %s while the order currently the status %s has.', $orderId, $currentOrderStatus);
     foreach ($recipients as $recipient) {
         mail(trim($recipient), 'Dubbele transactie voor dezelfde order', $mail);
     }
 }
コード例 #14
0
ファイル: Session.php プロジェクト: okite11/frames21
 /**
  * Get order instance based on last order ID
  *
  * @return Mage_Sales_Model_Order
  */
 public function getLastRealOrder()
 {
     $orderId = $this->getLastRealOrderId();
     if ($this->_order !== null && $orderId == $this->_order->getIncrementId()) {
         return $this->_order;
     }
     $this->_order = $this->_getOrderModel();
     if ($orderId) {
         $this->_order->loadByIncrementId($orderId);
     }
     return $this->_order;
 }
コード例 #15
0
 /** Send order to MailChimp Automatically by Order Status
  *
  *
  */
 public function autoExportJobs()
 {
     $allow_sent = false;
     $orderIds[] = '0';
     $ecommerceOrders = Mage::getModel('monkey/ecommerce')->getCollection()->getData();
     if ($ecommerceOrders) {
         foreach ($ecommerceOrders as $ecommerceOrder) {
             $orderIds[] = $ecommerceOrder['order_id'];
         }
     }
     $orders = Mage::getResourceModel('sales/order_collection');
     //Get ALL orders which has not been sent to MailChimp
     $orders->getSelect()->where('main_table.entity_id NOT IN(?)', $orderIds);
     //Get status options selected in the Configuration
     $states = explode(',', Mage::helper('monkey')->config('order_status'));
     foreach ($orders as $order) {
         foreach ($states as $state) {
             if ($order->getStatus() == $state || $state == 'all_status') {
                 $allow_sent = true;
             }
         }
         if ($allow_sent == true) {
             $this->_order = $order;
             $api = Mage::getSingleton('monkey/api', array('store' => $this->_order->getStoreId()));
             if (!$api) {
                 return false;
             }
             $subtotal = $this->_order->getSubtotal();
             $discount = (double) $this->_order->getDiscountAmount();
             if ($discount != 0) {
                 $subtotal = $subtotal + $discount;
             }
             $this->_info = array('id' => $this->_order->getIncrementId(), 'total' => $subtotal, 'shipping' => $this->_order->getShippingAmount(), 'tax' => $this->_order->getTaxAmount(), 'store_id' => $this->_order->getStoreId(), 'store_name' => $this->_order->getStoreName(), 'plugin_id' => 1215, 'items' => array());
             $email = $this->_order->getCustomerEmail();
             $campaign = $this->_order->getEbizmartsMagemonkeyCampaignId();
             $this->setItemstoSend();
             if ($email && $campaign) {
                 $this->_info['email_id'] = $email;
                 $this->_info['campaign_id'] = $campaign;
                 //Send order to MailChimp
                 $rs = $api->campaignEcommOrderAdd($this->_info);
             } else {
                 $this->_info['email'] = $email;
                 $rs = $api->ecommOrderAdd($this->_info);
             }
             $allow_sent = false;
             if ($rs === TRUE) {
                 $this->_logCall();
             }
         }
     }
 }
コード例 #16
0
 /**
  * get the locale code for the order
  *
  * @return string
  */
 protected function _getLocale()
 {
     $languageCode = $this->_coreHelper->getConfigModel()->setStore($this->_order->getStore())->languageCode;
     $splitCode = explode('-', $languageCode);
     if (!empty($splitCode[0]) && !empty($splitCode[1])) {
         $result = strtolower($splitCode[0]) . '_' . strtoupper($splitCode[1]);
     } else {
         $logData = ['order_id' => $this->_order->getIncrementId(), 'language_code' => $languageCode];
         $this->_logger->critical("The store for order '{order_id}' is configured with an invalid language code: '{language_code}'", $this->_logContext->getMetaData(__CLASS__, $logData));
         $result = '';
     }
     return $result;
 }
コード例 #17
0
 /**
  * Returns associative array with required parameters to API, used on CC method calls
  * @return array
  */
 public function getCreditCardApiCallParams(Mage_Sales_Model_Order $order, $payment)
 {
     $helper = Mage::helper('ricardomartins_pagseguro');
     $pHelper = Mage::helper('ricardomartins_pagseguro/params');
     //params helper - helper auxiliar de parametrização
     $params = array('email' => $helper->getMerchantEmail(), 'token' => $helper->getToken(), 'paymentMode' => 'default', 'paymentMethod' => 'creditCard', 'receiverEmail' => $helper->getMerchantEmail(), 'currency' => 'BRL', 'creditCardToken' => $payment['additional_information']['credit_card_token'], 'reference' => $order->getIncrementId(), 'extraAmount' => $pHelper->getExtraAmount($order), 'notificationURL' => Mage::getUrl('ricardomartins_pagseguro/notification'));
     $params = array_merge($params, $pHelper->getItemsParams($order));
     $params = array_merge($params, $pHelper->getSenderParams($order, $payment));
     $params = array_merge($params, $pHelper->getAddressParams($order, 'shipping'));
     $params = array_merge($params, $pHelper->getAddressParams($order, 'billing'));
     $params = array_merge($params, $pHelper->getCreditCardHolderParams($order, $payment));
     $params = array_merge($params, $pHelper->getCreditCardInstallmentsParams($order, $payment));
     return $params;
 }
コード例 #18
0
ファイル: Abstract.php プロジェクト: technomagegithub/olgo.nl
 /**
  * Add the customer variables to the request
  *
  * @param $vars
  * @param string $serviceName
  * @return mixed
  */
 protected function _addCustomerVariables(&$vars, $serviceName = 'creditmanagement')
 {
     if (Mage::helper('buckaroo3extended')->isAdmin()) {
         $additionalFields = Mage::getSingleton('core/session')->getData('additionalFields');
     } else {
         $additionalFields = Mage::getSingleton('checkout/session')->getData('additionalFields');
     }
     if (isset($additionalFields['BPE_Customergender'])) {
         $gender = $additionalFields['BPE_Customergender'];
     } else {
         $gender = 0;
     }
     if (isset($additionalFields['BPE_customerbirthdate'])) {
         $dob = $additionalFields['BPE_customerbirthdate'];
     } else {
         $dob = '';
     }
     if (isset($additionalFields['BPE_Customermail'])) {
         $mail = $additionalFields['BPE_Customermail'];
     } else {
         $mail = $this->_billingInfo['email'];
     }
     $customerId = $this->_order->getCustomerId() ? $this->_order->getCustomerId() : $this->_order->getIncrementId();
     $firstName = $this->_billingInfo['firstname'];
     $lastName = $this->_billingInfo['lastname'];
     $address = $this->_processAddressCM();
     $houseNumber = $address['house_number'];
     $houseNumberSuffix = $address['number_addition'];
     $street = $address['street'];
     $zipcode = $this->_billingInfo['zip'];
     $city = $this->_billingInfo['city'];
     $state = $this->_billingInfo['state'];
     $fax = $this->_billingInfo['fax'];
     $country = $this->_billingInfo['countryCode'];
     $processedPhoneNumber = $this->_processPhoneNumberCM();
     $customerLastNamePrefix = $this->_getCustomerLastNamePrefix();
     $customerInitials = $this->_getInitialsCM();
     $array = array('CustomerCode' => $customerId, 'CustomerFirstName' => $firstName, 'CustomerLastName' => $lastName, 'FaxNumber' => $fax, 'CustomerInitials' => $customerInitials, 'CustomerLastNamePrefix' => $customerLastNamePrefix, 'CustomerBirthDate' => $dob, 'Customergender' => $gender, 'Customeremail' => $mail, 'ZipCode' => array('value' => $zipcode, 'group' => 'address'), 'City' => array('value' => $city, 'group' => 'address'), 'State' => array('value' => $state, 'group' => 'address'), 'Street' => array('value' => $street, 'group' => 'address'), 'HouseNumber' => array('value' => $houseNumber, 'group' => 'address'), 'HouseNumberSuffix' => array('value' => $houseNumberSuffix, 'group' => 'address'), 'Country' => array('value' => $country, 'group' => 'address'));
     if (array_key_exists('customVars', $vars) && array_key_exists($serviceName, $vars['customVars']) && is_array($vars['customVars'][$serviceName])) {
         $vars['customVars'][$serviceName] = array_merge($vars['customVars'][$serviceName], $array);
     } else {
         $vars['customVars'][$serviceName] = $array;
     }
     if ($processedPhoneNumber['mobile']) {
         $vars['customVars'][$serviceName] = array_merge($vars['customVars'][$serviceName], array('MobilePhoneNumber' => $processedPhoneNumber['clean']));
     } else {
         $vars['customVars'][$serviceName] = array_merge($vars['customVars'][$serviceName], array('PhoneNumber' => $processedPhoneNumber['clean']));
     }
     return $vars;
 }
コード例 #19
0
ファイル: Direct.php プロジェクト: xiaoguizhidao/mydigibits
 /**
  * Processes payment for specified order
  * @param Mage_Sales_Model_Order $Order
  * @return
  */
 public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null)
 {
     if ($Order->getBaseGrandTotal() > 0) {
         $data = array('amount' => $Order->getBaseGrandTotal() * 100, 'invoice_reference' => $Order->getIncrementId());
         $eWayCustomerId = $this->getSubscription()->getRealId();
         try {
             $response = $this->getWebService()->createTransaction($eWayCustomerId, $data);
             $Order->getPayment()->setCcTransId(@$response->ewayResponse->ewayTrxnNumber);
         } catch (Exception $e) {
             Mage::throwException($e->getMessage());
             return $this;
         }
     }
     return $this;
 }
コード例 #20
0
ファイル: Client.php プロジェクト: igorvasiliev4/magento_code
 public function setOrder(Mage_Sales_Model_Order $order)
 {
     $this->_order = $order;
     $shippingAddress = $order->getShippingAddress();
     /* @var $helper Dhl_Intraship_Helper_Data */
     $helper = Mage::helper('intraship/data');
     $senderName1 = $shippingAddress->getFirstname() . " " . $shippingAddress->getLastname();
     $senderName2 = "";
     if ($shippingAddress->getCompany()) {
         $senderName2 = $senderName1;
         $senderName1 = $shippingAddress->getCompany();
     }
     $street = $helper->splitStreet($shippingAddress->getStreetFull());
     $this->setDeliveryName($this->_config->getDeliveryNameByCountry($shippingAddress->getCountryId()))->setSenderName1($senderName1)->setSenderName2($senderName2)->setSenderStreet($street['street_name'])->setSenderStreetNumber($street['street_number'])->setSenderCareOfName($street['care_of'])->setSenderPostalCode($shippingAddress->getPostcode())->setSenderCity($shippingAddress->getCity())->setCustomerReference($this->_order->getIncrementId());
     return $this;
 }
コード例 #21
0
 /**
  * Make prepaid credit card payloads for any payments
  * remaining in the list
  * @param Mage_Sales_Model_Order $order
  * @param IPaymentContainer      $paymentContainer
  * @param SplObjectStorage       $processedPayments
  */
 public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments)
 {
     foreach ($order->getAllPayments() as $payment) {
         if ($this->_shouldIgnorePayment($payment, $processedPayments)) {
             continue;
         }
         $iterable = $paymentContainer->getPayments();
         $payload = $iterable->getEmptyPayPalPayment();
         $additionalInfo = new Varien_Object($payment->getAdditionalInformation());
         // use the grand total since it has already been adjusted for redeemed giftcards
         // by the the giftcard module's total collector.
         $amount = $order->getGrandTotal();
         $payload->setAmount($amount)->setAmountAuthorized($amount)->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAuthorizationResponseCode(self::AUTH_RESPONSE_CODE)->setOrderId($order->getIncrementId())->setTenderType(self::TENDER_TYPE)->setPanIsToken(true)->setAccountUniqueId(self::ACCOUNT_UNIQUE_ID)->setPaymentRequestId($additionalInfo->getAuthRequestId());
         // add the new payload
         $iterable->OffsetSet($payload, $payload);
         // put the payment in the processed payments set
         $processedPayments->attach($payment);
     }
 }
コード例 #22
0
 /**
  * Make prepaid credit card payloads for any payments
  * remaining in the list
  * @param Mage_Sales_Model_Order $order
  * @param IPaymentContainer      $paymentContainer
  * @param SplObjectStorage       $processedPayments
  */
 public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments)
 {
     foreach ($order->getAllPayments() as $payment) {
         if ($this->_shouldIgnorePayment($payment, $processedPayments)) {
             continue;
         }
         $iterable = $paymentContainer->getPayments();
         $payload = $iterable->getEmptyCreditCardPayment();
         $additionalInfo = new Varien_Object($payment->getAdditionalInformation());
         $payload->setOrderId($order->getIncrementId())->setTenderType($additionalInfo->getTenderType())->setAccountUniqueId($this->_getAccountUniqueId($payment))->setPanIsToken($additionalInfo->getPanIsToken())->setPaymentRequestId($additionalInfo->getRequestId())->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAmount($payment->getAmountAuthorized())->setBankAuthorizationCode($additionalInfo->getBankAuthorizationCode())->setResponseCode($additionalInfo->getResponseCode())->setCVV2ResponseCode($additionalInfo->getCvv2ResponseCode())->setAVSResponseCode($additionalInfo->getAvsResponseCode())->setPhoneResponseCode($additionalInfo->getPhoneResponseCode())->setNameResponseCode($additionalInfo->getNameResponseCode())->setEmailResponseCode($additionalInfo->getEmailResponseCode())->setAmountAuthorized($additionalInfo->getAmountAuthorized())->setExpirationDate($this->_getExpirationDateTime($payment))->setExtendedAuthDescription($additionalInfo->getExtendedAuthDescription())->setExtendedAuthReasonCode($additionalInfo->getExtendedAuthReasonCode())->setIssueNumber($additionalInfo->getIssueNumber())->setAuthenticationAvailable($additionalInfo->getAuthenticationAvailable())->setAuthenticationStatus($additionalInfo->getAuthenticationStatus())->setCavvUcaf($additionalInfo->getCavvUcaf())->setTransactionId($additionalInfo->getTransactionId())->setECI($additionalInfo->getECI())->setPayerAuthenticationResponse($additionalInfo->getPayerAuthenticationResponse())->setPurchasePlanCode($additionalInfo->getPurchasePlanCode())->setPurchasePlanDescription($additionalInfo->getPurchasePlanDescription());
         if ($additionalInfo->getStartDate()) {
             // prevent death by type error if getStartDate returns null
             $payload->setStartDate($this->_getAsDateTime($additionalInfo->getStartDate()));
         }
         // add the new payload
         $iterable->OffsetSet($payload, $payload);
         // put the payment in the processed payments set
         $processedPayments->attach($payment);
     }
 }
コード例 #23
0
ファイル: Request.php プロジェクト: blazeriaz/youguess
 /**
  * Set entity data to request
  *
  * @param Mage_Sales_Model_Order $order
  * @param Mage_Authorizenet_Model_Directpost $paymentMethod
  * @return Mage_Authorizenet_Model_Directpost_Request
  */
 public function setDataFromOrder(Mage_Sales_Model_Order $order, Mage_Authorizenet_Model_Directpost $paymentMethod)
 {
     $payment = $order->getPayment();
     $this->setXFpSequence($order->getQuoteId());
     $this->setXInvoiceNum($order->getIncrementId());
     $this->setXAmount($payment->getBaseAmountAuthorized());
     $this->setXCurrencyCode($order->getBaseCurrencyCode());
     $this->setXTax(sprintf('%.2F', $order->getBaseTaxAmount()))->setXFreight(sprintf('%.2F', $order->getBaseShippingAmount()));
     //need to use strval() because NULL values IE6-8 decodes as "null" in JSON in JavaScript, but we need "" for null values.
     $billing = $order->getBillingAddress();
     if (!empty($billing)) {
         $this->setXFirstName(strval($billing->getFirstname()))->setXLastName(strval($billing->getLastname()))->setXCompany(strval($billing->getCompany()))->setXAddress(strval($billing->getStreet(1)))->setXCity(strval($billing->getCity()))->setXState(strval($billing->getRegion()))->setXZip(strval($billing->getPostcode()))->setXCountry(strval($billing->getCountry()))->setXPhone(strval($billing->getTelephone()))->setXFax(strval($billing->getFax()))->setXCustId(strval($billing->getCustomerId()))->setXCustomerIp(strval($order->getRemoteIp()))->setXCustomerTaxId(strval($billing->getTaxId()))->setXEmail(strval($order->getCustomerEmail()))->setXEmailCustomer(strval($paymentMethod->getConfigData('email_customer')))->setXMerchantEmail(strval($paymentMethod->getConfigData('merchant_email')));
     }
     $shipping = $order->getShippingAddress();
     if (!empty($shipping)) {
         $this->setXShipToFirstName(strval($shipping->getFirstname()))->setXShipToLastName(strval($shipping->getLastname()))->setXShipToCompany(strval($shipping->getCompany()))->setXShipToAddress(strval($shipping->getStreet(1)))->setXShipToCity(strval($shipping->getCity()))->setXShipToState(strval($shipping->getRegion()))->setXShipToZip(strval($shipping->getPostcode()))->setXShipToCountry(strval($shipping->getCountry()));
     }
     $this->setXPoNum(strval($payment->getPoNumber()));
     return $this;
 }
コード例 #24
0
ファイル: Request.php プロジェクト: hazaeluz/magento_connect
 /**
  * Get order request data as array
  *
  * @param Mage_Sales_Model_Order $order
  * @return array
  */
 protected function _getOrderData(Mage_Sales_Model_Order $order)
 {
     $request = array('subtotal' => $this->_formatPrice($this->_formatPrice($order->getPayment()->getBaseAmountAuthorized()) - $this->_formatPrice($order->getBaseTaxAmount()) - $this->_formatPrice($order->getBaseShippingAmount())), 'tax' => $this->_formatPrice($order->getBaseTaxAmount()), 'shipping' => $this->_formatPrice($order->getBaseShippingAmount()), 'invoice' => $order->getIncrementId(), 'address_override' => 'false', 'currency_code' => $order->getBaseCurrencyCode(), 'buyer_email' => $order->getCustomerEmail());
     // append to request billing address data
     if ($billingAddress = $order->getBillingAddress()) {
         $request = array_merge($request, $this->_getBillingAddress($billingAddress));
     }
     // append to request shipping address data
     if ($shippingAddress = $order->getShippingAddress()) {
         $request = array_merge($request, $this->_getShippingAddress($shippingAddress));
     }
     return $request;
 }
コード例 #25
0
ファイル: Order.php プロジェクト: anziv/Magento-modules
 /**
  * Process Payment Transaction
  * @param Mage_Sales_Model_Order $order
  * @param array                  $fields
  *
  * @return Mage_Sales_Model_Order_Payment_Transaction|null
  * @throws Exception
  */
 public function processPaymentTransaction(Mage_Sales_Model_Order $order, array $fields)
 {
     // Lookup Transaction
     $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()->addAttributeToFilter('txn_id', $fields['transactionNumber']);
     if (count($collection) > 0) {
         Mage::helper('payexautopay/tools')->addToDebug(sprintf('Transaction %s already processed.', $fields['transactionNumber']), $order->getIncrementId());
         return $collection->getFirstItem();
     }
     // Set Payment Transaction Id
     $payment = $order->getPayment();
     $payment->setTransactionId($fields['transactionNumber']);
     /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
     $transaction_status = isset($fields['transactionStatus']) ? (int) $fields['transactionStatus'] : null;
     switch ($transaction_status) {
         case 1:
             // From PayEx PIM:
             // "If PxOrder.Complete returns transactionStatus = 1, then check pendingReason for status."
             // See http://www.payexpim.com/payment-methods/paypal/
             if ($fields['pending'] === 'true') {
                 $message = Mage::helper('payexautopay')->__('Transaction Status: %s.', $transaction_status);
                 $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, true, $message);
                 $transaction->setIsClosed(0);
                 $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
                 $transaction->setMessage($message);
                 $transaction->save();
                 break;
             }
             $message = Mage::helper('payexautopay')->__('Transaction Status: %s.', $transaction_status);
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true, $message);
             $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
             $transaction->setMessage($message);
             $transaction->save();
             break;
         case 3:
             $message = Mage::helper('payexautopay')->__('Transaction Status: %s.', $transaction_status);
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, true, $message);
             $transaction->setIsClosed(0);
             $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
             $transaction->setMessage($message);
             $transaction->save();
             break;
         case 0:
         case 6:
             $message = Mage::helper('payexautopay')->__('Transaction Status: %s.', $transaction_status);
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, true, $message);
             $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
             $transaction->isFailsafe(true)->close(false);
             $transaction->setMessage($message);
             $transaction->save();
             break;
         case 2:
             $message = Mage::helper('payexautopay')->__('Detected an abnormal payment process (Transaction Status: %s).', $transaction_status);
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true, $message);
             $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
             $transaction->setMessage($message);
             $transaction->setIsCancel(true);
             $transaction->save();
             break;
         case 4:
             $message = Mage::helper('payexautopay')->__('Order automatically canceled. Transaction is canceled.');
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true);
             $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
             $transaction->setMessage($message);
             $transaction->setIsCancel(true);
             $transaction->save();
             break;
         case 5:
             $message = Mage::helper('payexautopay')->__('Order automatically canceled. Transaction is failed.');
             $message .= ' ' . Mage::helper('payexautopay/tools')->getVerboseErrorMessage($fields);
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true);
             $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
             $transaction->setMessage($message);
             $transaction->setIsCancel(true);
             $transaction->save();
             break;
         default:
             $message = Mage::helper('payexautopay')->__('Invalid transaction status.');
             $transaction = Mage::getModel('sales/order_payment_transaction');
             $transaction->setMessage($message);
             $transaction->setIsCancel(true);
             break;
     }
     try {
         $order->save();
         Mage::helper('payexautopay/tools')->addToDebug($message, $order->getIncrementId());
     } catch (Exception $e) {
         Mage::helper('payexautopay/tools')->addToDebug('Error: ' . $e->getMessage(), $order->getIncrementId());
     }
     return $transaction;
 }
コード例 #26
0
 /**
  * Build up the sale request
  *
  * @param $amount
  * @param array $paymentDataArray
  * @param Mage_Sales_Model_Order $order
  * @param bool $submitForSettlement
  * @param bool $deviceData
  * @param bool $storeInVault
  * @param bool $threeDSecure
  * @param array $extra
  *
  * @return array
  *
  * @throws Mage_Core_Exception
  */
 public function buildSale($amount, array $paymentDataArray, Mage_Sales_Model_Order $order, $submitForSettlement = true, $deviceData = false, $storeInVault = false, $threeDSecure = false, $extra = array())
 {
     // Check we always have an ID
     if (!$order->getIncrementId()) {
         Mage::throwException('Your order has become invalid, please try refreshing.');
     }
     // Store whether or not we created a new method
     $createdMethod = false;
     // Are we storing in the vault, from a guest customer account?
     if ($storeInVault && Mage::getSingleton('checkout/session')->getGuestBraintreeCustomerId() && ($token = Mage::getSingleton('checkout/session')->getGuestPaymentToken())) {
         if ($this->checkPaymentMethod($token)) {
             // Remove this from the session so it doesn't get deleted at the end of checkout
             Mage::getSingleton('checkout/session')->unsGuestBraintreeCustomerId();
             Mage::getSingleton('checkout/session')->unsGuestPaymentToken();
             // We no longer need this nonce
             unset($paymentDataArray['paymentMethodNonce']);
             // Instead use the token
             $paymentDataArray['paymentMethodToken'] = $token;
             // Create a flag for other methods
             $createdMethod = true;
         } else {
             // If the method doesn't exist, clear the token and re-build the sale
             Mage::getSingleton('checkout/session')->unsGuestPaymentToken();
             return $this->buildSale($amount, $paymentDataArray, $order, $submitForSettlement, $deviceData, $storeInVault, $threeDSecure, $extra);
         }
     } else {
         if ($storeInVault && $this->checkIsCustomer() && isset($paymentDataArray['paymentMethodNonce'])) {
             // If the user is already a customer and wants to store in the vault we've gotta do something a bit special
             // Do we already have a saved token in the session?
             if ($token = Mage::getSingleton('checkout/session')->getTemporaryPaymentToken()) {
                 if ($this->checkPaymentMethod($token)) {
                     // Remove this from the session so it doesn't get deleted at the end of checkout
                     Mage::getSingleton('checkout/session')->unsTemporaryPaymentToken();
                     // We no longer need this nonce
                     unset($paymentDataArray['paymentMethodNonce']);
                     // Instead use the token
                     $paymentDataArray['paymentMethodToken'] = $token;
                     // Create a flag for other methods
                     $createdMethod = true;
                 } else {
                     // If the method doesn't exist, clear the token and re-build the sale
                     Mage::getSingleton('checkout/session')->unsTemporaryPaymentToken();
                     return $this->buildSale($amount, $paymentDataArray, $order, $submitForSettlement, $deviceData, $storeInVault, $threeDSecure, $extra);
                 }
             } else {
                 // Create the payment method with this data
                 $paymentMethodCreate = array('customerId' => $this->getBraintreeId(), 'paymentMethodNonce' => $paymentDataArray['paymentMethodNonce'], 'billingAddress' => $this->buildAddress($order->getBillingAddress()));
                 // Log the create array
                 Gene_Braintree_Model_Debug::log(array('Braintree_PaymentMethod' => $paymentMethodCreate));
                 // Create a new billing method
                 $result = Braintree_PaymentMethod::create($paymentMethodCreate);
                 // Log the response from Braintree
                 Gene_Braintree_Model_Debug::log(array('Braintree_PaymentMethod:result' => $result));
                 // Verify the storing of the card was a success
                 if (isset($result->success) && $result->success == true) {
                     /* @var $paymentMethod Braintree_CreditCard */
                     $paymentMethod = $result->paymentMethod;
                     // Check to see if the token is set
                     if (isset($paymentMethod->token) && !empty($paymentMethod->token)) {
                         // We no longer need this nonce
                         unset($paymentDataArray['paymentMethodNonce']);
                         // Instead use the token
                         $paymentDataArray['paymentMethodToken'] = $paymentMethod->token;
                         // Create a flag for other methods
                         $createdMethod = true;
                     }
                 } else {
                     Mage::throwException($result->message . Mage::helper('gene_braintree')->__(' Please try again or attempt refreshing the page.'));
                 }
             }
         }
     }
     // Build up the initial request parameters
     $request = array('amount' => $amount, 'orderId' => $order->getIncrementId(), 'merchantAccountId' => $this->getMerchantAccountId($order), 'channel' => 'MagentoVZero', 'options' => array('submitForSettlement' => $submitForSettlement, 'storeInVault' => $storeInVault));
     // Input the allowed payment method info
     $allowedPaymentInfo = array('paymentMethodNonce', 'paymentMethodToken', 'token', 'cvv');
     foreach ($paymentDataArray as $key => $value) {
         if (in_array($key, $allowedPaymentInfo)) {
             if ($key == 'cvv') {
                 $request['creditCard']['cvv'] = $value;
             } else {
                 $request[$key] = $value;
             }
         } else {
             Mage::throwException($key . ' is not allowed within $paymentDataArray');
         }
     }
     // Include the customer if we're creating a new one
     if (!$this->checkIsCustomer() && (Mage::getSingleton('customer/session')->isLoggedIn() || (Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == 'login_in' || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER))) {
         $request['customer'] = $this->buildCustomer($order);
     } else {
         // If the customer exists but we aren't using the vault we want to pass a customer object with no ID
         $request['customer'] = $this->buildCustomer($order, false);
     }
     // Do we have any deviceData to send over?
     if ($deviceData) {
         $request['deviceData'] = $deviceData;
     }
     // Include the shipping address
     if ($order->getShippingAddress()) {
         $request['shipping'] = $this->buildAddress($order->getShippingAddress());
     }
     // Include the billing address
     if ($order->getBillingAddress()) {
         $request['billing'] = $this->buildAddress($order->getBillingAddress());
     }
     // Is 3D secure enabled?
     if ($threeDSecure !== false && !$createdMethod) {
         $request['options']['three_d_secure']['required'] = true;
     }
     // Any extra information we want to supply
     if (!empty($extra) && is_array($extra)) {
         $request = array_merge($request, $extra);
     }
     return $request;
 }
コード例 #27
0
 /**
  * Taking a 'sales/order' instance and an instance of 'OrderEvents\IOrderShipped' as parameters and then adding
  * the shipment and tracking information to the 'sales/order' instance. Reconcile any discrepancies
  * by validating the expected shipment data is indeed in the Magento order; otherwise, log the
  * discrepancies.
  * @param  Mage_Sales_Model_Order $order
  * @param  OrderEvents\IOrderShipped $payload
  * @return self
  */
 public function process(Mage_Sales_Model_Order $order, OrderEvents\IOrderShipped $payload)
 {
     $orderItems = $payload->getOrderItems();
     $qtys = $this->_buildShipmentQtys($orderItems, $order->getItemsCollection());
     if (!empty($qtys)) {
         $incrementId = $order->getIncrementId();
         $shipmentId = $this->_getNewShipmentIncrementId($order);
         $shipment = $this->_addShipmentToOrder($qtys, $order)->setData('increment_id', $shipmentId);
         $this->_addTrackingToShipment($orderItems, $shipment)->_registerShipment($shipment, $incrementId)->_saveShipment($shipment, $incrementId)->_reconcileShipment($orderItems, $shipmentId, $incrementId);
     }
     return $this;
 }
コード例 #28
0
 /**
  * Redirect and notify the customer of a successful or a fail
  * cancel order action.
  *
  * @param  Mage_Sales_Model_Order
  * @param  Mage_Core_Model_Session
  * @param  string
  * @return self
  */
 protected function _handleRomCancelResponse(Mage_Sales_Model_Order $order, Mage_Core_Model_Session $session, $redirectUrl)
 {
     $incrementId = $order->getIncrementId();
     if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
         $session->addSuccess(sprintf($this->_orderHelper->__(static::CANCEL_SUCCESS_MESSAGE), $incrementId));
     } else {
         $session->addError(sprintf($this->_orderHelper->__(static::CANCEL_FAIL_MESSAGE), $incrementId));
     }
     $this->_redirectUrl($redirectUrl);
     return $this;
 }
コード例 #29
0
 /**
  * @param Mage_Sales_Model_Order $order
  * @return string
  */
 public function getAdminOrderUrlHtml(Mage_Sales_Model_Order $order)
 {
     return sprintf('<a href="%s">#%s</a>', Mage::helper('adminhtml')->getUrl('*/sales_order/view', ['order_id' => $order->getId()]), $order->getIncrementId());
 }
コード例 #30
0
 /**
  * Do Void Request/Response
  *
  * @param  Mage_Sales_Model_Order
  * @return array
  * @throws EbayEnterprise_PayPal_Exception when the operation cannot be completed or fails.
  */
 public function doVoidOrder(Mage_Sales_Model_Order $order)
 {
     return $this->doVoid($order->getIncrementId(), $order->getOrderCurrencyCode());
 }