本文整理汇总了PHP中Magento\Sales\Model\Order::getOrderCurrencyCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getOrderCurrencyCode方法的具体用法?PHP Order::getOrderCurrencyCode怎么用?PHP Order::getOrderCurrencyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::getOrderCurrencyCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setOpenInvoiceData
/**
* @param $formFields
* @return mixed
*/
protected function setOpenInvoiceData($formFields)
{
$count = 0;
$currency = $this->_order->getOrderCurrencyCode();
foreach ($this->_order->getAllVisibleItems() as $item) {
++$count;
$linename = "line" . $count;
$formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currency;
$formFields['openinvoicedata.' . $linename . '.description'] = str_replace("\n", '', trim($item->getName()));
$formFields['openinvoicedata.' . $linename . '.itemAmount'] = $this->_adyenHelper->formatAmount($item->getPrice(), $currency);
$formFields['openinvoicedata.' . $linename . '.itemVatAmount'] = $item->getTaxAmount() > 0 && $item->getPriceInclTax() > 0 ? $this->_adyenHelper->formatAmount($item->getPriceInclTax(), $currency) - $this->_adyenHelper->formatAmount($item->getPrice(), $currency) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency);
// $product = $item->getProduct();
// Calculate vat percentage
$percentageMinorUnits = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent());
$formFields['openinvoicedata.' . $linename . '.itemVatPercentage'] = $percentageMinorUnits;
$formFields['openinvoicedata.' . $linename . '.numberOfItems'] = (int) $item->getQtyOrdered();
if ($this->_order->getPayment()->getAdditionalInformation(\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna") {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
} else {
$formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
}
}
$formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference'];
$formFields['openinvoicedata.numberOfLines'] = $count;
return $formFields;
}
示例2: startTransaction
public function startTransaction(Order $order, UrlInterface $url)
{
$config = new Config($this->_scopeConfig);
$config->configureSDK();
$total = $order->getGrandTotal();
$items = $order->getAllVisibleItems();
$orderId = $order->getIncrementId();
$quoteId = $order->getQuoteId();
$currency = $order->getOrderCurrencyCode();
$returnUrl = $url->getUrl('paynl/checkout/finish/');
$exchangeUrl = $url->getUrl('paynl/checkout/exchange/');
$paymentOptionId = $this->getPaymentOptionId();
$arrBillingAddress = $order->getBillingAddress()->toArray();
$arrShippingAddress = $order->getShippingAddress()->toArray();
$enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
$address = array();
$arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
$address['streetName'] = $arrAddress[0];
$address['houseNumber'] = $arrAddress[1];
$address['zipCode'] = $arrBillingAddress['postcode'];
$address['city'] = $arrBillingAddress['city'];
$address['country'] = $arrBillingAddress['country_id'];
$shippingAddress = array();
$arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']);
$shippingAddress['streetName'] = $arrAddress2[0];
$shippingAddress['houseNumber'] = $arrAddress2[1];
$shippingAddress['zipCode'] = $arrShippingAddress['postcode'];
$shippingAddress['city'] = $arrShippingAddress['city'];
$shippingAddress['country'] = $arrShippingAddress['country_id'];
$data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra2' => $quoteId, 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
$data['address'] = $address;
$data['shippingAddress'] = $shippingAddress;
$data['enduser'] = $enduser;
$arrProducts = array();
foreach ($items as $item) {
$arrItem = $item->toArray();
if ($arrItem['price_incl_tax'] != null) {
$product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty_ordered'], 'tax' => $arrItem['tax_amount']);
}
$arrProducts[] = $product;
}
//shipping
$shippingCost = $order->getShippingAddress()->getShippingInclTax();
$shippingTax = $order->getShippingAddress()->getShippingTaxAmount();
$shippingDescription = $order->getShippingAddress()->getShippingDescription();
$arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
// kortingen
$discount = $order->getSubtotal() - $order->getSubtotalWithDiscount();
if ($discount > 0) {
$arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0);
}
$data['products'] = $arrProducts;
if ($config->isTestMode()) {
$data['testmode'] = 1;
}
$data['ipaddress'] = $order->getRemoteIp();
$transaction = \Paynl\Transaction::start($data);
return $transaction->getRedirectUrl();
}
示例3: getCoinGateRequest
/**
* @param Order $order
* @return array
*/
public function getCoinGateRequest(Order $order)
{
$token = substr(md5(rand()), 0, 32);
$payment = $order->getPayment();
$payment->setAdditionalInformation('coingate_order_token', $token);
$payment->save();
$description = array();
foreach ($order->getAllItems() as $item) {
$description[] = number_format($item->getQtyOrdered(), 0) . ' × ' . $item->getName();
}
$params = array('order_id' => $order->getIncrementId(), 'price' => number_format($order->getGrandTotal(), 2, '.', ''), 'currency' => $order->getOrderCurrencyCode(), 'receive_currency' => $this->getConfigData('receive_currency'), 'callback_url' => $this->urlBuilder->getUrl('coingate/payment/callback') . '?token=' . $payment->getAdditionalInformation('coingate_order_token'), 'cancel_url' => $this->urlBuilder->getUrl('checkout/onepage/failure'), 'success_url' => $this->urlBuilder->getUrl('checkout/onepage/success'), 'title' => $this->storeManager->getWebsite()->getName(), 'description' => join($description, ', '));
$this->coingate->createOrder($params);
if ($this->coingate->success) {
return array('status' => true, 'payment_url' => $this->coingate->response['payment_url']);
} else {
return array('status' => false);
}
}
示例4: initFromOrder
/**
* Initialize creation data from existing order
*
* @param \Magento\Sales\Model\Order $order
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function initFromOrder(\Magento\Sales\Model\Order $order)
{
$session = $this->getSession();
$session->setData($order->getReordered() ? 'reordered' : 'order_id', $order->getId());
$session->setCurrencyId($order->getOrderCurrencyCode());
/* Check if we edit guest order */
$session->setCustomerId($order->getCustomerId() ?: false);
$session->setStoreId($order->getStoreId());
/* Initialize catalog rule data with new session values */
$this->initRuleData();
foreach ($order->getItemsCollection($this->_salesConfig->getAvailableProductTypes(), true) as $orderItem) {
/* @var $orderItem \Magento\Sales\Model\Order\Item */
if (!$orderItem->getParentItem()) {
$qty = $orderItem->getQtyOrdered();
if (!$order->getReordered()) {
$qty -= max($orderItem->getQtyShipped(), $orderItem->getQtyInvoiced());
}
if ($qty > 0) {
$item = $this->initFromOrderItem($orderItem, $qty);
if (is_string($item)) {
throw new \Magento\Framework\Exception\LocalizedException(__($item));
}
}
}
}
$shippingAddress = $order->getShippingAddress();
if ($shippingAddress) {
$addressDiff = array_diff_assoc($shippingAddress->getData(), $order->getBillingAddress()->getData());
unset($addressDiff['address_type'], $addressDiff['entity_id']);
$shippingAddress->setSameAsBilling(empty($addressDiff));
}
$this->_initBillingAddressFromOrder($order);
$this->_initShippingAddressFromOrder($order);
$quote = $this->getQuote();
if (!$quote->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) {
$this->setShippingAsBilling(1);
}
$this->setShippingMethod($order->getShippingMethod());
$quote->getShippingAddress()->setShippingDescription($order->getShippingDescription());
$paymentData = $order->getPayment()->getData();
unset($paymentData['cc_type'], $paymentData['cc_last_4']);
unset($paymentData['cc_exp_month'], $paymentData['cc_exp_year']);
$quote->getPayment()->addData($paymentData);
$orderCouponCode = $order->getCouponCode();
if ($orderCouponCode) {
$quote->setCouponCode($orderCouponCode);
}
if ($quote->getCouponCode()) {
$quote->collectTotals();
}
$this->_objectCopyService->copyFieldsetToTarget('sales_copy_order', 'to_edit', $order, $quote);
$this->_eventManager->dispatch('sales_convert_order_to_quote', ['order' => $order, 'quote' => $quote]);
if (!$order->getCustomerId()) {
$quote->setCustomerIsGuest(true);
}
if ($session->getUseOldShippingMethod(true)) {
/*
* if we are making reorder or editing old order
* we need to show old shipping as preselected
* so for this we need to collect shipping rates
*/
$this->collectShippingRates();
} else {
/*
* if we are creating new order then we don't need to collect
* shipping rates before customer hit appropriate button
*/
$this->collectRates();
}
$this->quoteRepository->save($quote);
return $this;
}
示例5: getBasicData
/**
* @param \Magento\Sales\Model\Order $order
* @return array
*/
public function getBasicData(\Magento\Sales\Model\Order $order)
{
$incrementId = $order->getIncrementId();
return ['currencyCode' => $order->getOrderCurrencyCode(), 'totalAmount' => $order->getGrandTotal() * 100, 'extOrderId' => $this->extOrderIdHelper->generate($order), 'description' => __('Order # %1', [$incrementId])];
}
示例6: makePurchase
/**
* @param $order Order
* @return Purchase
*/
protected function makePurchase(Order $order)
{
// Get all of the purchased products
$items = $order->getAllItems();
$purchase = SignifydModel::Make("\\Signifyd\\Models\\Purchase");
$purchase->orderChannel = "WEB";
$purchase->products = array();
foreach ($items as $item) {
$purchase->products[] = $this->makeProduct($item);
}
$purchase->totalPrice = $order->getGrandTotal();
$purchase->currency = $order->getOrderCurrencyCode();
$purchase->orderId = $order->getIncrementId();
$purchase->paymentGateway = $order->getPayment()->getMethod();
$purchase->shippingPrice = floatval($order->getShippingAmount());
$purchase->avsResponseCode = $order->getPayment()->getCcAvsStatus();
$purchase->cvvResponseCode = $order->getPayment()->getCcSecureVerify();
$purchase->createdAt = date('c', strtotime($order->getCreatedAt()));
$purchase->browserIpAddress = $this->getIPAddress($order);
return $purchase;
}
示例7: build
/**
* Loads the order info from a Magento order model.
*
* @param Order $order the order model.
* @return \NostoOrder
*/
public function build(Order $order)
{
$nostoOrder = new \NostoOrder();
try {
$nostoCurrency = new NostoCurrencyCode($order->getOrderCurrencyCode());
$nostoOrder->setOrderNumber($order->getId());
$nostoOrder->setExternalRef($order->getRealOrderId());
$nostoOrder->setCreatedDate(new NostoDate(strtotime($order->getCreatedAt())));
$nostoOrder->setPaymentProvider(new NostoOrderPaymentProvider($order->getPayment()->getMethod()));
if ($order->getStatus()) {
$nostoStatus = new NostoOrderStatus();
$nostoStatus->setCode($order->getStatus());
$nostoStatus->setLabel($order->getStatusLabel());
$nostoOrder->setStatus($nostoStatus);
}
foreach ($order->getAllStatusHistory() as $item) {
if ($item->getStatus()) {
$nostoStatus = new NostoOrderStatus();
$nostoStatus->setCode($item->getStatus());
$nostoStatus->setLabel($item->getStatusLabel());
$nostoStatus->setCreatedAt(new NostoDate(strtotime($item->getCreatedAt())));
$nostoOrder->addHistoryStatus($nostoStatus);
}
}
// Set the buyer information
$nostoBuyer = new NostoOrderBuyer();
$nostoBuyer->setFirstName($order->getCustomerFirstname());
$nostoBuyer->setLastName($order->getCustomerLastname());
$nostoBuyer->setEmail($order->getCustomerEmail());
$nostoOrder->setBuyer($nostoBuyer);
// Add each ordered item as a line item
/** @var Item $item */
foreach ($order->getAllVisibleItems() as $item) {
$nostoItem = new NostoOrderItem();
$nostoItem->setItemId((int) $this->buildItemProductId($item));
$nostoItem->setQuantity((int) $item->getQtyOrdered());
$nostoItem->setName($this->buildItemName($item));
try {
$nostoItem->setUnitPrice(new NostoPrice($this->_priceHelper->getItemFinalPriceInclTax($item)));
} catch (\NostoInvalidArgumentException $E) {
$nostoItem->setUnitPrice(new NostoPrice(0));
}
$nostoItem->setCurrency($nostoCurrency);
$nostoOrder->addItem($nostoItem);
}
// Add discounts as a pseudo line item
if (($discount = $order->getDiscountAmount()) < 0) {
$nostoItem = new NostoOrderItem();
$nostoItem->setItemId(-1);
$nostoItem->setQuantity(1);
$nostoItem->setName($this->buildDiscountRuleDescription($order));
$nostoItem->setUnitPrice(new NostoPrice($discount));
$nostoItem->setCurrency($nostoCurrency);
$nostoOrder->addItem($nostoItem);
}
// Add shipping and handling as a pseudo line item
if (($shippingInclTax = $order->getShippingInclTax()) > 0) {
$nostoItem = new NostoOrderItem();
$nostoItem->setItemId(-1);
$nostoItem->setQuantity(1);
$nostoItem->setName('Shipping and handling');
$nostoItem->setUnitPrice(new NostoPrice($shippingInclTax));
$nostoItem->setCurrency($nostoCurrency);
$nostoOrder->addItem($nostoItem);
}
} catch (Exception $e) {
$this->_logger->error($e, ['exception' => $e]);
}
return $nostoOrder;
}
示例8: validateKhipuCallback
/**
* @param Order $order
*/
public function validateKhipuCallback(Order $order)
{
try {
if (!$order || !$order->getIncrementId()) {
throw new \Exception('Order #' . $_REQUEST['order_id'] . ' does not exists');
}
$payment = $order->getPayment();
$notificationToken = isset($_POST['notification_token']) ? $_POST['notification_token'] : '';
if ($notificationToken == '') {
throw new \Exception('Invalid notification token.');
}
$configuration = new \Khipu\Configuration();
$configuration->setSecret($this->getConfigData('merchant_secret'));
$configuration->setReceiverId($this->getConfigData('merchant_id'));
$configuration->setPlatform('magento2-khipu', Payment::KHIPU_MAGENTO_VERSION);
$client = new \Khipu\ApiClient($configuration);
$payments = new \Khipu\Client\PaymentsApi($client);
try {
$paymentResponse = $payments->paymentsGet($notificationToken);
} catch (\Khipu\ApiException $exception) {
throw new \Exception(print_r($exception->getResponseObject(), TRUE));
}
if ($paymentResponse->getReceiverId() != $this->getConfigData('merchant_id')) {
throw new \Exception('Invalid receiver id');
}
if ($paymentResponse->getTransactionId() != $payment->getAdditionalInformation('khipu_order_token')) {
throw new \Exception('Invalid transaction id');
}
if ($paymentResponse->getStatus() != 'done') {
throw new \Exception('Payment not done');
}
if ($paymentResponse->getAmount() != number_format($order->getGrandTotal(), $this->getDecimalPlaces($order->getOrderCurrencyCode()), '.', '')) {
throw new \Exception('Amount mismatch');
}
if ($paymentResponse->getCurrency() != $order->getOrderCurrencyCode()) {
throw new \Exception('Currency mismatch');
}
$order->setState(Order::STATE_PROCESSING, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))->save();
} catch (\Exception $e) {
exit('Error occurred: ' . $e);
}
}
示例9: _setPaymentAuthorized
/**
* @param bool $manualReviewComment
* @param bool $createInvoice
* @throws Exception
*/
protected function _setPaymentAuthorized($manualReviewComment = true, $createInvoice = false)
{
$this->_adyenLogger->addAdyenNotificationCronjob('Set order to authorised');
// if full amount is captured create invoice
$currency = $this->_order->getOrderCurrencyCode();
$amount = $this->_value;
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
// create invoice for the capture notification if you are on manual capture
if ($createInvoice == true && $amount == $orderAmount) {
$this->_adyenLogger->addAdyenNotificationCronjob('amount notification:' . $amount . ' amount order:' . $orderAmount);
$this->_createInvoice();
}
// if you have capture on shipment enabled don't set update the status of the payment
$captureOnShipment = $this->_getConfigData('capture_on_shipment', 'adyen_abstract', $this->_order->getStoreId());
if (!$captureOnShipment) {
$status = $this->_getConfigData('payment_authorized', 'adyen_abstract', $this->_order->getStoreId());
}
// virtual order can have different status
if ($this->_order->getIsVirtual()) {
$this->_adyenLogger->addAdyenNotificationCronjob('Product is a virtual product');
$virtualStatus = $this->_getConfigData('payment_authorized_virtual');
if ($virtualStatus != "") {
$status = $virtualStatus;
}
}
// check for boleto if payment is totally paid
if ($this->_paymentMethodCode() == "adyen_boleto") {
// check if paid amount is the same as orginal amount
$orginalAmount = $this->_boletoOriginalAmount;
$paidAmount = $this->_boletoPaidAmount;
if ($orginalAmount != $paidAmount) {
// not the full amount is paid. Check if it is underpaid or overpaid
// strip the BRL of the string
$orginalAmount = str_replace("BRL", "", $orginalAmount);
$orginalAmount = floatval(trim($orginalAmount));
$paidAmount = str_replace("BRL", "", $paidAmount);
$paidAmount = floatval(trim($paidAmount));
if ($paidAmount > $orginalAmount) {
$overpaidStatus = $this->_getConfigData('order_overpaid_status', 'adyen_boleto');
// check if there is selected a status if not fall back to the default
$status = !empty($overpaidStatus) ? $overpaidStatus : $status;
} else {
$underpaidStatus = $this->_getConfigData('order_underpaid_status', 'adyen_boleto');
// check if there is selected a status if not fall back to the default
$status = !empty($underpaidStatus) ? $underpaidStatus : $status;
}
}
}
$comment = "Adyen Payment Successfully completed";
// if manual review is true use the manual review status if this is set
if ($manualReviewComment == true && $this->_fraudManualReview) {
// check if different status is selected
$fraudManualReviewStatus = $this->_getFraudManualReviewStatus();
if ($fraudManualReviewStatus != "") {
$status = $fraudManualReviewStatus;
$comment = "Adyen Payment is in Manual Review check the Adyen platform";
}
}
$status = !empty($status) ? $status : $this->_order->getStatus();
$this->_order->addStatusHistoryComment(__($comment), $status);
$this->_adyenLogger->addAdyenNotificationCronjob('Order status is changed to authorised status, status is ' . $status);
}
示例10: _getReceiptOrderLines
/**
* @param \Magento\Sales\Model\Order $order
* @return string
*/
protected function _getReceiptOrderLines(\Magento\Sales\Model\Order $order)
{
$myReceiptOrderLines = "";
$currency = $order->getOrderCurrencyCode();
$formattedAmountValue = $this->_currencyFactory->create()->format($order->getGrandTotal(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$taxAmount = $order->getTaxAmount();
$formattedTaxAmount = $this->_currencyFactory->create()->format($taxAmount, ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$myReceiptOrderLines .= "---||C\n" . "====== YOUR ORDER DETAILS ======||CB\n" . "---||C\n" . " No. Description |Piece Subtotal|\n";
foreach ($order->getItemsCollection() as $item) {
//skip dummies
if ($item->isDummy()) {
continue;
}
$singlePriceFormat = $this->_currencyFactory->create()->format($item->getPriceInclTax(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$itemAmount = $item->getPriceInclTax() * (int) $item->getQtyOrdered();
$itemAmountFormat = $this->_currencyFactory->create()->format($itemAmount, ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$myReceiptOrderLines .= " " . (int) $item->getQtyOrdered() . " " . trim(substr($item->getName(), 0, 25)) . "| " . $currency . " " . $singlePriceFormat . " " . $currency . " " . $itemAmountFormat . "|\n";
}
//discount cost
if ($order->getDiscountAmount() > 0 || $order->getDiscountAmount() < 0) {
$discountAmountFormat = $this->_currencyFactory->create()->format($order->getDiscountAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$myReceiptOrderLines .= " " . 1 . " " . $this->__('Total Discount') . "| " . $currency . " " . $discountAmountFormat . "|\n";
}
//shipping cost
if ($order->getShippingAmount() > 0 || $order->getShippingTaxAmount() > 0) {
$shippingAmountFormat = $this->_currencyFactory->create()->format($order->getShippingAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$myReceiptOrderLines .= " " . 1 . " " . $order->getShippingDescription() . "| " . $currency . " " . $shippingAmountFormat . "|\n";
}
if ($order->getPaymentFeeAmount() > 0) {
$paymentFeeAmount = $this->_currencyFactory->create()->format($order->getPaymentFeeAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
$myReceiptOrderLines .= " " . 1 . " " . $this->__('Payment Fee') . "| " . $currency . " " . $paymentFeeAmount . "|\n";
}
$myReceiptOrderLines .= "|--------|\n" . "|Order Total: " . $currency . " " . $formattedAmountValue . "|B\n" . "|Tax: " . $currency . " " . $formattedTaxAmount . "|B\n" . "||C\n";
/*
* New header for card details section!
* Default location is After Header so simply add to Order Details as separator
*/
$myReceiptOrderLines .= "---||C\n" . "====== YOUR PAYMENT DETAILS ======||CB\n" . "---||C\n";
return $myReceiptOrderLines;
}