本文整理汇总了PHP中Magento\Framework\Object::getAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getAmount方法的具体用法?PHP Object::getAmount怎么用?PHP Object::getAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::getAmount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _registerCard
/**
* It sets card`s data into additional information of payment model
*
* @param \Magento\Framework\Object $response
* @param \Magento\Sales\Model\Order\Payment $payment
* @return string
*/
protected function _registerCard(\Magento\Framework\Object $response, \Magento\Sales\Model\Order\Payment $payment)
{
$cardsStorage = $this->getCardsStorage($payment);
$card = $cardsStorage->registerCard();
$card->setRequestedAmount($response->getRequestedAmount())->setBalanceOnCard($response->getBalanceOnCard())->setLastTransId($response->getTransactionId())->setProcessedAmount($response->getAmount())->setCcType($payment->getCcType())->setCcOwner($payment->getCcOwner())->setCcLast4($payment->getCcLast4())->setCcExpMonth($payment->getCcExpMonth())->setCcExpYear($payment->getCcExpYear())->setCcSsIssue($payment->getCcSsIssue())->setCcSsStartMonth($payment->getCcSsStartMonth())->setCcSsStartYear($payment->getCcSsStartYear());
$cardsStorage->updateCard($card);
$this->_clearAssignedData($payment);
return $card;
}
示例2: cmpShippingOptions
/**
* Compare two shipping options based on their amounts
*
* This function is used as a callback comparison function in shipping options sorting process
* @see self::_prepareShippingOptions()
*
* @param \Magento\Framework\Object $option1
* @param \Magento\Framework\Object $option2
* @return int
*/
protected static function cmpShippingOptions(\Magento\Framework\Object $option1, \Magento\Framework\Object $option2)
{
if ($option1->getAmount() == $option2->getAmount()) {
return 0;
}
return $option1->getAmount() < $option2->getAmount() ? -1 : 1;
}
示例3: getItemDetailsRowAmount
/**
* Getter for details row amount
*
* @param \Magento\Framework\Object $row
* @return string
*/
public function getItemDetailsRowAmount(\Magento\Framework\Object $row)
{
return $row->getAmount();
}
示例4: validate
/**
* Validate payment data
*
* This check is performed on payment information submission, as well as on placing order.
* Workflow state is stored validation state model
*
* @param \Magento\Framework\Object $data
* @return void
* @throws \Magento\Framework\Model\Exception
*/
public function validate($data)
{
$newChecksum = $this->_generateChecksum($data->getPaymentMethodCode(), $data->getCardType(), $data->getCardNumber(), $data->getCardExpMonth(), $data->getCardExpYear(), $data->getAmount(), $data->getCurrencyCode());
$validationState = $this->_getValidationState($data->getCardType());
if (!$validationState) {
$this->_resetValidationState();
return;
}
// check whether is authenticated before placing order
if ($this->getIsPlaceOrder()) {
if ($validationState->getChecksum() != $newChecksum) {
throw new \Magento\Framework\Model\Exception(__('Payment information error. Please start over.'));
}
if ($validationState->isAuthenticateSuccessful()) {
return;
}
throw new \Magento\Framework\Model\Exception(__('Please verify the card with the issuer bank before placing the order.'));
} else {
if ($validationState->getChecksum() != $newChecksum || !$validationState->isLookupSuccessful()) {
$this->lookup($data);
$validationState = $this->_getValidationState();
}
if ($validationState->isLookupSuccessful()) {
return;
}
throw new \Magento\Framework\Model\Exception(__('This card has failed validation and cannot be used.'));
}
}
示例5: buildRequest
/**
* Prepare request to gateway
*
* @param \Magento\Framework\Object|\Magento\Payment\Model\InfoInterface $payment
* @return \Magento\Authorizenet\Model\Request
* @link http://www.authorize.net/support/AIM_guide.pdf
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function buildRequest(\Magento\Framework\Object $payment)
{
/** @var \Magento\Sales\Model\Order $order */
$order = $payment->getOrder();
$this->setStore($order->getStoreId());
$request = $this->getRequest()->setXType($payment->getAnetTransType())->setXMethod(self::REQUEST_METHOD_CC);
if ($order && $order->getIncrementId()) {
$request->setXInvoiceNum($order->getIncrementId());
}
if ($payment->getAmount()) {
$request->setXAmount($payment->getAmount(), 2);
$request->setXCurrencyCode($order->getBaseCurrencyCode());
}
switch ($payment->getAnetTransType()) {
case self::REQUEST_TYPE_AUTH_CAPTURE:
$request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False');
break;
case self::REQUEST_TYPE_AUTH_ONLY:
$request->setXAllowPartialAuth($this->getConfigData('allow_partial_authorization') ? 'True' : 'False');
break;
case self::REQUEST_TYPE_CREDIT:
/**
* Send last 4 digits of credit card number to authorize.net
* otherwise it will give an error
*/
$request->setXCardNum($payment->getCcLast4());
$request->setXTransId($payment->getXTransId());
break;
case self::REQUEST_TYPE_VOID:
$request->setXTransId($payment->getXTransId());
break;
case self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE:
$request->setXTransId($payment->getXTransId());
break;
case self::REQUEST_TYPE_CAPTURE_ONLY:
$request->setXAuthCode($payment->getCcAuthCode());
break;
}
if (!empty($order)) {
$billing = $order->getBillingAddress();
if (!empty($billing)) {
$request->setXFirstName($billing->getFirstname())->setXLastName($billing->getLastname())->setXCompany($billing->getCompany())->setXAddress($billing->getStreetLine(1))->setXCity($billing->getCity())->setXState($billing->getRegion())->setXZip($billing->getPostcode())->setXCountry($billing->getCountry())->setXPhone($billing->getTelephone())->setXFax($billing->getFax())->setXCustId($order->getCustomerId())->setXCustomerIp($order->getRemoteIp())->setXCustomerTaxId($billing->getTaxId())->setXEmail($order->getCustomerEmail())->setXEmailCustomer($this->getConfigData('email_customer'))->setXMerchantEmail($this->getConfigData('merchant_email'));
}
$shipping = $order->getShippingAddress();
if (!empty($shipping)) {
$request->setXShipToFirstName($shipping->getFirstname())->setXShipToLastName($shipping->getLastname())->setXShipToCompany($shipping->getCompany())->setXShipToAddress($shipping->getStreetLine(1))->setXShipToCity($shipping->getCity())->setXShipToState($shipping->getRegion())->setXShipToZip($shipping->getPostcode())->setXShipToCountry($shipping->getCountry());
}
$request->setXPoNum($payment->getPoNumber())->setXTax($order->getBaseTaxAmount())->setXFreight($order->getBaseShippingAmount());
}
if ($payment->getCcNumber()) {
$request->setXCardNum($payment->getCcNumber())->setXExpDate(sprintf('%02d-%04d', $payment->getCcExpMonth(), $payment->getCcExpYear()))->setXCardCode($payment->getCcCid());
}
return $request;
}