本文整理匯總了PHP中Magento\Sales\Model\Order\Payment::getOrder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Payment::getOrder方法的具體用法?PHP Payment::getOrder怎麽用?PHP Payment::getOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order\Payment
的用法示例。
在下文中一共展示了Payment::getOrder方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getOrder
/**
* {@inheritdoc}
*/
public function getOrder()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getOrder');
if (!$pluginInfo) {
return parent::getOrder();
} else {
return $this->___callPlugins('getOrder', func_get_args(), $pluginInfo);
}
}
示例2: aroundIsCaptureFinal
public function aroundIsCaptureFinal(\Magento\Sales\Model\Order\Payment $subject, \Closure $proceed, $amountToCapture)
{
$result = $proceed($amountToCapture);
if (!$result) {
$order = $subject->getOrder();
$invoices = $order->getInvoiceCollection();
$invoice = $invoices->getFirstItem();
$grandTotalBase = $invoice->getBaseGrandTotal();
/* validate with partial amount if exists */
$result = $grandTotalBase == $amountToCapture;
}
return $result;
}
示例3: setOrder
/**
* Set order instance for transaction depends on transaction behavior
* If $order equals to true, method isn't loading new order instance.
*
* @param \Magento\Sales\Model\Order|null|boolean $order
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function setOrder($order = null)
{
if (null === $order || $order === true) {
if (null !== $this->_paymentObject && $this->_paymentObject->getOrder()) {
$this->_order = $this->_paymentObject->getOrder();
} elseif ($this->getOrderId() && $order === null) {
$this->_order = $this->_orderFactory->create()->load($this->getOrderId());
} else {
$this->_order = false;
}
} elseif (!$this->getId() || $this->getOrderId() == $order->getId()) {
$this->_order = $order;
} else {
throw new \Magento\Framework\Exception\LocalizedException(__('Set order for existing transactions not allowed'));
}
return $this;
}
示例4: df_order_by_payment
/**
* 2016-05-07
* @param OP $payment
* @return O|DFO
* @throws LE
*/
function df_order_by_payment(OP $payment)
{
/** @var O|DFO $result */
$result = $payment->getOrder();
/**
* 2016-05-08
* Раньше здесь стояла проверка !$result->getId()
* Это оказалось не совсем правильным, потому что в оплаты размещаемого в данный момент заказа
* у этого заказа ещё нет идентификатора (потому что он не сохранён),
* но вот increment_id для него создаётся заранее
* (в том числе, чтобы другие объекты, да и платёжные модули могли к нему привязываться).
*/
if (!$result->getIncrementId()) {
throw new LE(__('The order no longer exists.'));
}
/**
* 2016-03-26
* Очень важно! Иначе order создаст свой экземпляр payment:
* @used-by \Magento\Sales\Model\Order::getPayment()
*/
$result[IO::PAYMENT] = $payment;
return $result;
}
示例5: _placeOrder
/**
* Place an order with authorization or capture action
*
* @param Payment $payment
* @param float $amount
* @return $this
*/
protected function _placeOrder(Payment $payment, $amount)
{
$order = $payment->getOrder();
/** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */
$billingAgreement = $this->_agreementFactory->create()->load($payment->getAdditionalInformation(\Magento\Paypal\Model\Payment\Method\Billing\AbstractAgreement::TRANSPORT_BILLING_AGREEMENT_ID));
$cart = $this->_cartFactory->create(array('salesModel' => $order));
$proConfig = $this->_pro->getConfig();
$api = $this->_pro->getApi()->setReferenceId($billingAgreement->getReferenceId())->setPaymentAction($proConfig->getConfigValue('paymentAction'))->setAmount($amount)->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/'))->setPaypalCart($cart)->setIsLineItemsEnabled($proConfig->getConfigValue('lineItemsEnabled'))->setInvNum($order->getIncrementId());
// call api and import transaction and other payment information
$api->callDoReferenceTransaction();
$this->_pro->importPaymentInfo($api, $payment);
$api->callGetTransactionDetails();
$this->_pro->importPaymentInfo($api, $payment);
$payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0);
if ($api->getBillingAgreementId()) {
$order->addRelatedObject($billingAgreement);
$billingAgreement->setIsObjectChanged(true);
$billingAgreement->addOrderRelation($order);
}
return $this;
}
示例6: _placeOrder
/**
* Place an order with authorization or capture action
*
* @param Payment $payment
* @param float $amount
* @return $this
*/
protected function _placeOrder(Payment $payment, $amount)
{
$order = $payment->getOrder();
$api = $this->_pro->getApi()->setPaymentAction($this->_pro->getConfig()->getConfigValue('paymentAction'))->setIpAddress($this->_requestHttp->getClientIp(false))->setAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode())->setInvNum($order->getIncrementId())->setEmail($order->getCustomerEmail())->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/'))->setCreditCardType($payment->getCcType())->setCreditCardNumber($payment->getCcNumber())->setCreditCardExpirationDate($this->_getFormattedCcExpirationDate($payment->getCcExpMonth(), $payment->getCcExpYear()))->setCreditCardCvv2($payment->getCcCid())->setMaestroSoloIssueNumber($payment->getCcSsIssue());
if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) {
$year = sprintf('%02d', substr($payment->getCcSsStartYear(), -2, 2));
$api->setMaestroSoloIssueDate($this->_getFormattedCcExpirationDate($payment->getCcSsStartMonth(), $year));
}
if ($this->getIsCentinelValidationEnabled()) {
$this->getCentinelValidator()->exportCmpiData($api);
}
// add shipping and billing addresses
if ($order->getIsVirtual()) {
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
} else {
$api->setAddress($order->getShippingAddress());
$api->setBillingAddress($order->getBillingAddress());
}
// add line items
$cart = $this->_cartFactory->create(array('salesModel' => $order));
$api->setPaypalCart($cart)->setIsLineItemsEnabled($this->_pro->getConfig()->getConfigValue('lineItemsEnabled'));
// call api and import transaction and other payment information
$api->callDoDirectPayment();
$this->_importResultToPayment($api, $payment);
try {
$api->callGetTransactionDetails();
} catch (\Magento\Framework\Model\Exception $e) {
// if we receive errors, but DoDirectPayment response is Success, then set Pending status for transaction
$payment->setIsTransactionPending(true);
}
$this->_importResultToPayment($api, $payment);
return $this;
}
示例7: _buildTokenRequest
/**
* Build request for getting token
*
* @param \Magento\Sales\Model\Order\Payment $payment
* @return \Magento\Framework\DataObject
*/
protected function _buildTokenRequest(\Magento\Sales\Model\Order\Payment $payment)
{
$request = $this->buildBasicRequest();
$request->setCreatesecuretoken('Y')->setSecuretokenid($this->mathRandom->getUniqueHash())->setTrxtype($this->_getTrxTokenType());
$order = $payment->getOrder();
$request->setAmt(sprintf('%.2F', $order->getBaseTotalDue()))->setCurrency($order->getBaseCurrencyCode());
$this->addRequestOrderInfo($request, $order);
$request = $this->fillCustomerContacts($order, $request);
//pass store Id to request
$request->setData('USER1', $order->getStoreId());
$request->setData('USER2', $this->_getSecureSilentPostHash($payment));
return $request;
}
示例8: importOrderPayment
/**
* Import payment data to billing agreement
*
* $payment->getBillingAgreementData() contains array with following structure :
* [billing_agreement_id] => string
* [method_code] => string
*
* @param Payment $payment
* @return $this
*/
public function importOrderPayment(Payment $payment)
{
$baData = $payment->getBillingAgreementData();
$this->_paymentMethodInstance = isset($baData['method_code']) ? $this->_paymentData->getMethodInstance($baData['method_code']) : $payment->getMethodInstance();
$this->_paymentMethodInstance->setStore($payment->getMethodInstance()->getStore());
$this->setCustomerId($payment->getOrder()->getCustomerId())->setMethodCode($this->_paymentMethodInstance->getCode())->setReferenceId($baData['billing_agreement_id'])->setStatus(self::STATUS_ACTIVE)->setAgreementLabel($this->_paymentMethodInstance->getTitle());
return $this;
}
示例9: _placeOrder
/**
* Place an order with authorization or capture action
*
* @param Payment $payment
* @param float $amount
* @return $this
*/
protected function _placeOrder(Payment $payment, $amount)
{
$order = $payment->getOrder();
// prepare api call
$token = $payment->getAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_TOKEN);
$cart = $this->_cartFactory->create(['salesModel' => $order]);
$api = $this->getApi()->setToken($token)->setPayerId($payment->getAdditionalInformation(ExpressCheckout::PAYMENT_INFO_TRANSPORT_PAYER_ID))->setAmount($amount)->setPaymentAction($this->_pro->getConfig()->getValue('paymentAction'))->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/'))->setInvNum($order->getIncrementId())->setCurrencyCode($order->getBaseCurrencyCode())->setPaypalCart($cart)->setIsLineItemsEnabled($this->_pro->getConfig()->getValue('lineItemsEnabled'));
if ($order->getIsVirtual()) {
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
} else {
$api->setAddress($order->getShippingAddress());
$api->setBillingAddress($order->getBillingAddress());
}
// call api and get details from it
$api->callDoExpressCheckoutPayment();
$this->_importToPayment($api, $payment);
return $this;
}
示例10: addStatusCommentOnUpdate
/**
* @param \Magento\Sales\Model\Order\Payment $payment
* @param \Magento\Framework\DataObject $response
* @param string $transactionId
* @return $this
*/
protected function addStatusCommentOnUpdate(\Magento\Sales\Model\Order\Payment $payment, \Magento\Framework\DataObject $response, $transactionId)
{
if ($payment->getIsTransactionApproved()) {
$message = __('Transaction %1 has been approved. Amount %2. Transaction status is "%3"', $transactionId, $payment->getOrder()->getBaseCurrency()->formatTxt($payment->getAmountAuthorized()), $this->dataHelper->getTransactionStatusLabel($response->getTransactionStatus()));
$payment->getOrder()->addStatusHistoryComment($message);
} elseif ($payment->getIsTransactionDenied()) {
$message = __('Transaction %1 has been voided/declined. Transaction status is "%2". Amount %3.', $transactionId, $this->dataHelper->getTransactionStatusLabel($response->getTransactionStatus()), $payment->getOrder()->getBaseCurrency()->formatTxt($payment->getAmountAuthorized()));
$payment->getOrder()->addStatusHistoryComment($message);
}
return $this;
}
示例11: testGetOrderDefault
public function testGetOrderDefault()
{
$this->orderRepository->expects($this->never())->method('get');
$this->assertSame($this->orderMock, $this->payment->getOrder());
}
示例12: _buildTokenRequest
/**
* Build request for getting token
*
* @param \Magento\Sales\Model\Order\Payment $payment
* @return \Magento\Framework\Object
*/
protected function _buildTokenRequest(\Magento\Sales\Model\Order\Payment $payment)
{
$request = $this->buildBasicRequest();
$request->setCreatesecuretoken('Y')->setSecuretokenid($this->mathRandom->getUniqueHash())->setTrxtype($this->_getTrxTokenType())->setAmt(sprintf('%.2F', $payment->getOrder()->getBaseTotalDue()))->setCurrency($payment->getOrder()->getBaseCurrencyCode())->setInvnum($payment->getOrder()->getIncrementId())->setCustref($payment->getOrder()->getIncrementId())->setPonum($payment->getOrder()->getId());
$order = $payment->getOrder();
if (empty($order)) {
return $request;
}
$billing = $order->getBillingAddress();
if (!empty($billing)) {
$request = $this->setBilling($request, $billing);
$request->setEmail($order->getCustomerEmail());
}
$shipping = $order->getShippingAddress();
if (!empty($shipping)) {
$request = $this->setShipping($request, $shipping);
}
//pass store Id to request
$request->setData('USER1', $order->getStoreId());
$request->setData('USER2', $this->_getSecureSilentPostHash($payment));
return $request;
}