本文整理匯總了PHP中Magento\Sales\Model\Order::getIncrementId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::getIncrementId方法的具體用法?PHP Order::getIncrementId怎麽用?PHP Order::getIncrementId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::getIncrementId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* Receives webhook events from Roadrunner
*/
public function execute()
{
$this->_logger->addDebug('paystandmagento/webhook/paystand endpoint was hit');
$body = @file_get_contents('php://input');
$json = json_decode($body);
$this->_logger->addDebug(">>>>> body=" . print_r($body, TRUE));
if (isset($json->resource->meta->source) && $json->resource->meta->source == "magento 2") {
$quoteId = $json->resource->meta->quote;
$this->_logger->addDebug('magento 2 webhook identified with quote id = ' . $quoteId);
$this->_order->loadByAttribute('quote_id', $quoteId);
if (!empty($this->_order->getIncrementId())) {
$this->_logger->addDebug('current order increment id = ' . $this->_order->getIncrementId());
$state = $this->_order->getState();
$this->_logger->addDebug('current order state = ' . $state);
$status = $this->_order->getStatus();
$this->_logger->addDebug('current order status = ' . $status);
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
if ($this->scopeConfig->getValue(self::USE_SANDBOX, $storeScope)) {
$base_url = 'https://api.paystand.co/v3';
} else {
$base_url = 'https://api.paystand.com/v3';
}
$url = $base_url . "/events/" . $json->id . "/verify";
$auth_header = array("x-publishable-key: " . $this->scopeConfig->getValue(self::PUBLISHABLE_KEY, $storeScope));
$curl = $this->buildCurl("POST", $url, json_encode($json), $auth_header);
$response = $this->runCurl($curl);
$this->_logger->addDebug("http_response_code is " . $this->http_response_code);
if (FALSE !== $response && $this->http_response_code == 200) {
if ($json->resource->object = "payment") {
switch ($json->resource->status) {
case 'posted':
$state = 'pending';
$status = 'pending';
break;
case 'paid':
$state = 'processing';
$status = 'processing';
break;
case 'failed':
$state = 'closed';
$status = 'closed';
break;
case 'canceled':
$state = 'canceled';
$status = 'canceled';
break;
}
}
$this->_order->setState($state);
$this->_order->setStatus($status);
$this->_order->save();
$this->_logger->addDebug('new order state = ' . $state);
$this->_logger->addDebug('new order status = ' . $status);
} else {
$this->_logger->addDebug('event verify failed');
}
}
}
}
示例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: getLastRealOrder
/**
* Get order instance based on last order ID
*
* @return \Magento\Sales\Model\Order
*/
public function getLastRealOrder()
{
$orderId = $this->getLastRealOrderId();
if ($this->_order !== null && $orderId == $this->_order->getIncrementId()) {
return $this->_order;
}
$this->_order = $this->_orderFactory->create();
if ($orderId) {
$this->_order->loadByIncrementId($orderId);
}
return $this->_order;
}
示例4: getBasicData
/**
* @param \Magento\Sales\Model\Order $order
* @return array
*/
public function getBasicData(\Magento\Sales\Model\Order $order)
{
$incrementId = $order->getIncrementId();
$billingAddress = $order->getBillingAddress();
$data = ['amount' => $order->getGrandTotal() * 100, 'desc' => __('Order # %1', [$incrementId]), 'first_name' => $billingAddress->getFirstname(), 'last_name' => $billingAddress->getLastname(), 'email' => $order->getCustomerEmail(), 'session_id' => $this->extOrderIdHelper->generate($order), 'order_id' => $incrementId];
$paytype = $this->session->getPaytype();
if ($paytype) {
$data['pay_type'] = $paytype;
$this->session->setPaytype(null);
}
return $data;
}
示例5: setDataFromOrder
/**
* 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;
}
示例6: _getOrderData
/**
* Get order request data as array
*
* @param \Magento\Sales\Model\Order $order
* @return array
*/
protected function _getOrderData(\Magento\Sales\Model\Order $order)
{
$request = ['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;
}
示例7: 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])];
}
示例8: validateCoinGateCallback
/**
* @param Order $order
*/
public function validateCoinGateCallback(Order $order)
{
try {
if (!$order || !$order->getIncrementId()) {
$request_order_id = filter_input(INPUT_POST, 'order_id') ? filter_input(INPUT_POST, 'order_id') : filter_input(INPUT_GET, 'order_id');
throw new \Exception('Order #' . $request_order_id . ' does not exists');
}
$payment = $order->getPayment();
$get_token = filter_input(INPUT_GET, 'token');
$token1 = $get_token ? $get_token : '';
$token2 = $payment->getAdditionalInformation('coingate_order_token');
if ($token2 == '' || $token1 != $token2) {
throw new \Exception('Tokens do match.');
}
$request_id = filter_input(INPUT_POST, 'id') ? filter_input(INPUT_POST, 'id') : filter_input(INPUT_GET, 'id');
$this->coingate->getOrder($request_id);
if (!$this->coingate->success) {
throw new \Exception('CoinGate Order #' . $request_id . ' does not exist');
}
if (!is_array($this->coingate->response)) {
throw new \Exception('Something wrong with callback');
}
if ($this->coingate->response['status'] == 'paid') {
$order->setState(Order::STATE_PROCESSING, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING))->save();
} elseif (in_array($this->coingate->response['status'], array('invalid', 'expired', 'canceled'))) {
$order->setState(Order::STATE_CANCELED, TRUE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CANCELED))->save();
}
} catch (\Exception $e) {
exit('Error occurred: ' . $e);
}
}
示例9: addRequestOrderInfo
/**
* Add order details to payment request
* @param DataObject $request
* @param Order $order
* @return void
*/
public function addRequestOrderInfo(DataObject $request, Order $order)
{
$id = $order->getId();
// for auth request order id is not exists yet
if (!empty($id)) {
$request->setPonum($id);
}
$orderIncrementId = $order->getIncrementId();
$request->setCustref($orderIncrementId)->setInvnum($orderIncrementId)->setComment1($orderIncrementId);
}
示例10: getOrderIncrementId
/**
* Returns order increment id
*
* @return string
*/
public function getOrderIncrementId()
{
return $this->order->getIncrementId();
}
示例11: getHeader
/**
* Get data for Header esction of RSS feed
*
* @return array
*/
protected function getHeader()
{
$title = __('Order # %1 Notification(s)', $this->order->getIncrementId());
$newUrl = $this->urlBuilder->getUrl('sales/order/view', ['order_id' => $this->order->getId()]);
return ['title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8'];
}
示例12: 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);
}
}
示例13: getStatusUrlKey
/**
* Retrieve order status url key
*
* @param \Magento\Sales\Model\Order $order
* @return string
*/
public function getStatusUrlKey($order)
{
$data = array('order_id' => $order->getId(), 'increment_id' => $order->getIncrementId(), 'customer_id' => $order->getCustomerId());
return base64_encode(json_encode($data));
}
示例14: getUrlKey
/**
* Retrieve order status url key
*
* @param \Magento\Sales\Model\Order $order
* @return string
*/
protected function getUrlKey($order)
{
$data = ['order_id' => $order->getId(), 'increment_id' => $order->getIncrementId(), 'customer_id' => $order->getCustomerId()];
return base64_encode(json_encode($data));
}
示例15: testGetIncrementId
/**
* test method getIncrementId()
*/
public function testGetIncrementId()
{
$this->assertEquals($this->incrementId, $this->order->getIncrementId());
}