Example #1
0
 /**
  * Set entity data to request
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \Magento\Authorizenet\Model\Directpost $paymentMethod
  * @return $this
  */
 public function setDataFromOrder(\Magento\Sales\Model\Order $order, \Magento\Authorizenet\Model\Directpost $paymentMethod)
 {
     $payment = $order->getPayment();
     $this->setXType($payment->getAnetTransType());
     $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->getStreetLine(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->getStreetLine(1)))->setXShipToCity(strval($shipping->getCity()))->setXShipToState(strval($shipping->getRegion()))->setXShipToZip(strval($shipping->getPostcode()))->setXShipToCountry(strval($shipping->getCountry()));
     }
     $this->setXPoNum(strval($payment->getPoNumber()));
     return $this;
 }
Example #2
0
 /**
  * Get order request data as array
  *
  * @param \Magento\Sales\Model\Order $order
  * @return array
  */
 protected function _getOrderData(\Magento\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' => 'true', '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;
 }
Example #3
0
 /**
  * Get payment amount data with excluded tax
  * @param \Magento\Sales\Model\Order $order
  * @return array
  */
 private function getNonTaxableAmount(Order $order)
 {
     return ['subtotal' => $this->_formatPrice($order->getBaseSubtotal()), 'total' => $this->_formatPrice($order->getPayment()->getBaseAmountAuthorized()), 'tax' => $this->_formatPrice($order->getBaseTaxAmount()), 'shipping' => $this->_formatPrice($order->getBaseShippingAmount()), 'discount' => $this->_formatPrice(abs($order->getBaseDiscountAmount()))];
 }
 /**
  * Repeat sql formula from \Magento\SalesRule\Model\Resource\Report\Rule\Createdat::_aggregateByOrder
  *
  * @param \Magento\Sales\Model\Order $order
  * @return float
  */
 private function getTotalAmount(\Magento\Sales\Model\Order $order)
 {
     return ($order->getBaseSubtotal() - $order->getBaseSubtotalCanceled() - (abs($order->getBaseDiscountAmount()) - abs($order->getBaseDiscountCanceled())) + ($order->getBaseTaxAmount() - $order->getBaseTaxCanceled())) * $order->getBaseToGlobalRate();
 }
Example #5
0
 /**
  * Get payment amount data with excluded tax
  * @param \Magento\Sales\Model\Order $order
  * @return array
  */
 private function getNonTaxableAmount(Order $order)
 {
     // PayPal denied transaction with 0 amount
     $subtotal = $order->getBaseSubtotal() ?: $order->getPayment()->getBaseAmountAuthorized();
     return ['subtotal' => $this->formatPrice($subtotal), 'total' => $this->formatPrice($order->getPayment()->getBaseAmountAuthorized()), 'tax' => $this->formatPrice($order->getBaseTaxAmount()), 'shipping' => $this->formatPrice($order->getBaseShippingAmount()), 'discount' => $this->formatPrice(abs($order->getBaseDiscountAmount()))];
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function getBaseTaxAmount()
 {
     return $this->_salesModel->getBaseTaxAmount();
 }