本文整理汇总了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;
}