本文整理匯總了PHP中Magento\Sales\Model\Order::getRemoteIp方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::getRemoteIp方法的具體用法?PHP Order::getRemoteIp怎麽用?PHP Order::getRemoteIp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::getRemoteIp方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getIPAddress
/**
* Getting the ip address of the order
* @param Order $order
* @return mixed
*/
protected function getIPAddress(Order $order)
{
if ($order->getRemoteIp()) {
if ($order->getXForwardedFor()) {
return $this->filterIp($order->getXForwardedFor());
}
return $this->filterIp($order->getRemoteIp());
}
/** @var $case \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress */
$remoteAddressHelper = $this->_objectManager->get('Magento\\Framework\\HTTP\\PhpEnvironment\\RemoteAddress');
return $this->filterIp($remoteAddressHelper->getRemoteAddress());
}
示例2: startTransaction
public function startTransaction(Order $order, UrlInterface $url)
{
$config = new Config($this->_scopeConfig);
$config->configureSDK();
$additionalData = $order->getPayment()->getAdditionalInformation();
$bankId = null;
if (isset($additionalData['bank_id'])) {
$bankId = $additionalData['bank_id'];
}
$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();
if ($arrBillingAddress) {
$arrBillingAddress = $arrBillingAddress->toArray();
$enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
$invoiceAddress = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname']);
$arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
$invoiceAddress['streetName'] = $arrAddress[0];
$invoiceAddress['houseNumber'] = $arrAddress[1];
$invoiceAddress['zipCode'] = $arrBillingAddress['postcode'];
$invoiceAddress['city'] = $arrBillingAddress['city'];
$invoiceAddress['country'] = $arrBillingAddress['country_id'];
}
$arrShippingAddress = $order->getShippingAddress();
if ($arrShippingAddress) {
$arrShippingAddress = $arrShippingAddress->toArray();
$shippingAddress = array('initials' => substr($arrShippingAddress['firstname'], 0, 1), 'lastName' => $arrShippingAddress['lastname']);
$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, 'bank' => $bankId, 'description' => $orderId, 'extra1' => $orderId, 'extra2' => $quoteId, 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
if (isset($shippingAddress)) {
$data['address'] = $shippingAddress;
}
if (isset($invoiceAddress)) {
$data['invoiceAddress'] = $invoiceAddress;
}
if (isset($enduser)) {
$data['enduser'] = $enduser;
}
$arrProducts = array();
foreach ($items as $item) {
$arrItem = $item->toArray();
if ($arrItem['price_incl_tax'] != null) {
// taxamount is not valid, because on discount it returns the taxamount after discount
$taxAmount = $arrItem['price_incl_tax'] - $arrItem['price'];
$product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty_ordered'], 'tax' => $taxAmount);
}
$arrProducts[] = $product;
}
//shipping
$shippingCost = $order->getShippingInclTax();
$shippingTax = $order->getShippingTaxAmount();
$shippingDescription = $order->getShippingDescription();
$arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
// kortingen
$discount = $order->getDiscountAmount();
$discountDescription = $order->getDiscountDescription();
if ($discount != 0) {
$arrProducts[] = array('id' => 'discount', 'name' => $discountDescription, 'price' => $discount, 'qty' => 1, 'tax' => $order->getDiscountTaxCompensationAmount() * -1);
}
$data['products'] = $arrProducts;
if ($config->isTestMode()) {
$data['testmode'] = 1;
}
$data['ipaddress'] = $order->getRemoteIp();
$transaction = \Paynl\Transaction::start($data);
return $transaction->getRedirectUrl();
}
示例3: getRemoteIp
/**
* Gets the remote IP address for the order.
*
* @return string|null Remote IP address.
*/
public function getRemoteIp()
{
return $this->order->getRemoteIp();
}
示例4: 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;
}
示例5: getFormFields
/**
* @return array
*/
public function getFormFields()
{
$formFields = [];
try {
if ($this->_order->getPayment()) {
$realOrderId = $this->_order->getRealOrderId();
$orderCurrencyCode = $this->_order->getOrderCurrencyCode();
$skinCode = trim($this->_adyenHelper->getAdyenHppConfigData('skin_code'));
$amount = $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $orderCurrencyCode);
$merchantAccount = trim($this->_adyenHelper->getAdyenAbstractConfigData('merchant_account'));
$shopperEmail = $this->_order->getCustomerEmail();
$customerId = $this->_order->getCustomerId();
$shopperIP = $this->_order->getRemoteIp();
$browserInfo = $_SERVER['HTTP_USER_AGENT'];
$deliveryDays = $this->_adyenHelper->getAdyenHppConfigData('delivery_days');
$shopperLocale = trim($this->_adyenHelper->getAdyenHppConfigData('shopper_locale'));
$shopperLocale = !empty($shopperLocale) ? $shopperLocale : $this->_resolver->getLocale();
$countryCode = trim($this->_adyenHelper->getAdyenHppConfigData('country_code'));
$countryCode = !empty($countryCode) ? $countryCode : false;
// if directory lookup is enabled use the billingadress as countrycode
if ($countryCode == false) {
if ($this->_order->getBillingAddress() && $this->_order->getBillingAddress()->getCountryId() != "") {
$countryCode = $this->_order->getBillingAddress()->getCountryId();
}
}
$formFields = [];
$formFields['merchantAccount'] = $merchantAccount;
$formFields['merchantReference'] = $realOrderId;
$formFields['paymentAmount'] = (int) $amount;
$formFields['currencyCode'] = $orderCurrencyCode;
$formFields['shipBeforeDate'] = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("j") + $deliveryDays, date("Y")));
$formFields['skinCode'] = $skinCode;
$formFields['shopperLocale'] = $shopperLocale;
$formFields['countryCode'] = $countryCode;
$formFields['shopperIP'] = $shopperIP;
$formFields['browserInfo'] = $browserInfo;
$formFields['sessionValidity'] = date(DATE_ATOM, mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y")));
$formFields['shopperEmail'] = $shopperEmail;
// recurring
$recurringType = trim($this->_adyenHelper->getAdyenAbstractConfigData('recurring_type'));
$brandCode = $this->_order->getPayment()->getAdditionalInformation("brand_code");
// Paypal does not allow ONECLICK,RECURRING only RECURRING
if ($brandCode == "paypal" && $recurringType == 'ONECLICK,RECURRING') {
$recurringType = "RECURRING";
}
$formFields['recurringContract'] = $recurringType;
$formFields['shopperReference'] = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId;
//blocked methods
$formFields['blockedMethods'] = "";
$baseUrl = $this->_storeManager->getStore($this->getStore())->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK);
$formFields['resURL'] = $baseUrl . 'adyen/process/result';
$hmacKey = $this->_adyenHelper->getHmac();
if ($brandCode) {
$formFields['brandCode'] = $brandCode;
}
$issuerId = $this->_order->getPayment()->getAdditionalInformation("issuer_id");
if ($issuerId) {
$formFields['issuerId'] = $issuerId;
}
$formFields = $this->setBillingAddressData($formFields);
$formFields = $this->setShippingAddressData($formFields);
$formFields = $this->setOpenInvoiceData($formFields);
$formFields['shopper.gender'] = $this->getGenderText($this->_order->getCustomerGender());
$dob = $this->_order->getCustomerDob();
if ($dob) {
$formFields['shopper.dateOfBirthDayOfMonth'] = trim($this->_getDate($dob, 'd'));
$formFields['shopper.dateOfBirthMonth'] = trim($this->_getDate($dob, 'm'));
$formFields['shopper.dateOfBirthYear'] = trim($this->_getDate($dob, 'Y'));
}
if ($this->_order->getPayment()->getAdditionalInformation(\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna") {
// // needed for DE and AT
$formFields['klarna.acceptPrivacyPolicy'] = 'true';
// don't allow editable shipping/delivery address
$formFields['billingAddressType'] = "1";
$formFields['deliveryAddressType'] = "1";
// make setting to make this optional
$adyFields['shopperType'] = "1";
}
// Sort the array by key using SORT_STRING order
ksort($formFields, SORT_STRING);
// Generate the signing data string
$signData = implode(":", array_map([$this, 'escapeString'], array_merge(array_keys($formFields), array_values($formFields))));
$merchantSig = base64_encode(hash_hmac('sha256', $signData, pack("H*", $hmacKey), true));
$formFields['merchantSig'] = $merchantSig;
$this->_adyenLogger->addAdyenDebug(print_r($formFields, true));
}
} catch (Exception $e) {
// do nothing for now
}
return $formFields;
}