本文整理匯總了PHP中Magento\Checkout\Model\Session::getPaypalTransactionData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::getPaypalTransactionData方法的具體用法?PHP Session::getPaypalTransactionData怎麽用?PHP Session::getPaypalTransactionData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Checkout\Model\Session
的用法示例。
在下文中一共展示了Session::getPaypalTransactionData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: order
/**
* Order payment
*
* @param \Magento\Framework\DataObject|\Magento\Payment\Model\InfoInterface|Payment $payment
* @param float $amount
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function order(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
$paypalTransactionData = $this->_checkoutSession->getPaypalTransactionData();
if (!is_array($paypalTransactionData)) {
$this->_placeOrder($payment, $amount);
} else {
$this->_importToPayment($this->_pro->getApi()->setData($paypalTransactionData), $payment);
}
$payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true);
if ($payment->getIsFraudDetected()) {
return $this;
}
$order = $payment->getOrder();
$orderTransactionId = $payment->getTransactionId();
$api = $this->_callDoAuthorize($amount, $payment, $orderTransactionId);
$state = \Magento\Sales\Model\Order::STATE_PROCESSING;
$status = true;
$formattedPrice = $order->getBaseCurrency()->formatTxt($amount);
if ($payment->getIsTransactionPending()) {
$message = __('The ordering amount of %1 is pending approval on the payment gateway.', $formattedPrice);
$state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW;
} else {
$message = __('Ordered amount of %1', $formattedPrice);
}
$transaction = $this->transactionBuilder->setPayment($payment)->setOrder($order)->setTransactionId($payment->getTransactionId())->build(Transaction::TYPE_ORDER);
$payment->addTransactionCommentsToOrder($transaction, $message);
$this->_pro->importPaymentInfo($api, $payment);
if ($payment->getIsTransactionPending()) {
$message = __('We\'ll authorize the amount of %1 as soon as the payment gateway approves it.', $formattedPrice);
$state = \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW;
if ($payment->getIsFraudDetected()) {
$status = \Magento\Sales\Model\Order::STATUS_FRAUD;
}
} else {
$message = __('The authorized amount is %1.', $formattedPrice);
}
$payment->resetTransactionAdditionalInfo();
$payment->setTransactionId($api->getTransactionId());
$payment->setParentTransactionId($orderTransactionId);
$transaction = $this->transactionBuilder->setPayment($payment)->setOrder($order)->setTransactionId($payment->getTransactionId())->build(Transaction::TYPE_AUTH);
$payment->addTransactionCommentsToOrder($transaction, $message);
$order->setState($state)->setStatus($status);
$payment->setSkipOrderProcessing(true);
return $this;
}