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;
 }
 /**
  * @return TotalInterface
  */
 private function getTotal()
 {
     /** @var TotalInterface $total */
     $total = $this->totalFactory->create();
     $total->setBaseShippingAmount($this->order->getBaseShippingAmount());
     $total->setBaseShippingCanceled($this->order->getBaseShippingCanceled());
     $total->setBaseShippingDiscountAmount($this->order->getBaseShippingDiscountAmount());
     $total->setBaseShippingDiscountTaxCompensationAmnt($this->order->getBaseShippingDiscountTaxCompensationAmnt());
     $total->setBaseShippingInclTax($this->order->getBaseShippingInclTax());
     $total->setBaseShippingInvoiced($this->order->getBaseShippingInvoiced());
     $total->setBaseShippingRefunded($this->order->getBaseShippingRefunded());
     $total->setBaseShippingTaxAmount($this->order->getBaseShippingTaxAmount());
     $total->setBaseShippingTaxRefunded($this->order->getBaseShippingTaxRefunded());
     $total->setShippingAmount($this->order->getShippingAmount());
     $total->setShippingCanceled($this->order->getShippingCanceled());
     $total->setShippingDiscountAmount($this->order->getShippingDiscountAmount());
     $total->setShippingDiscountTaxCompensationAmount($this->order->getShippingDiscountTaxCompensationAmount());
     $total->setShippingInclTax($this->order->getShippingInclTax());
     $total->setShippingInvoiced($this->order->getShippingInvoiced());
     $total->setShippingRefunded($this->order->getShippingRefunded());
     $total->setShippingTaxAmount($this->order->getShippingTaxAmount());
     $total->setShippingTaxRefunded($this->order->getShippingTaxRefunded());
     return $total;
 }
Example #3
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 #4
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()))];
 }
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 getBaseShippingAmount()
 {
     return $this->_salesModel->getBaseShippingAmount();
 }