public function execute(\Magento\Framework\Event\Observer $observer) { /** @var \Magento\Sales\Model\Order $order */ $payment = $observer->getData(self::DATA_PAYMENT); assert($payment instanceof \Magento\Sales\Model\Order\Payment); $order = $payment->getOrder(); $quoteId = $order->getQuoteId(); $regQuote = $this->_repoPartialQuote->getById($quoteId); if ($regQuote) { $orderId = $order->getId(); $customerId = $order->getCustomerId(); $amount = $regQuote->getBasePartialAmount(); $req = new \Praxigento\Wallet\Service\Operation\Request\PayForSaleOrder(); $req->setOrderId($orderId); $req->setCustomerId($customerId); $req->setBaseAmountToPay($amount); $this->_callOperation->payForSaleOrder($req); } }
public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount) { parent::capture($payment, $amount); /* collect data */ assert($payment instanceof \Magento\Sales\Model\Order\Payment); /** @var \Magento\Sales\Model\Order $order */ $order = $payment->getOrder(); $orderId = $order->getId(); $customerId = $order->getCustomerId(); /* perform payment */ $req = new \Praxigento\Wallet\Service\Operation\Request\PayForSaleOrder(); $req->setCustomerId($customerId); $req->setOrderId($orderId); $req->setBaseAmountToPay($amount); $resp = $this->callOperation->payForSaleOrder($req); /* TODO: add transaction ID to payment */ $operId = $resp->getOperationId(); $payment->setTransactionId($operId); return $this; }
/** * @param $updates [$custId=>[$rankId=>$bonus, ...], ...] * * @return \Praxigento\Wallet\Service\Operation\Response\AddToWalletActive */ private function _createBonusOperation($updates) { $asCustId = 'asCid'; $asAmount = 'asAmnt'; $asRef = 'asRef'; $transData = []; foreach ($updates as $custId => $ranks) { foreach ($ranks as $rankId => $amount) { $item = [$asCustId => $custId, $asAmount => $amount, $asRef => $rankId]; $transData[] = $item; } } $req = new WalletOperationAddToWalletActiveRequest(); $req->setAsCustomerId($asCustId); $req->setAsAmount($asAmount); $req->setAsRef($asRef); $req->setOperationTypeCode(Cfg::CODE_TYPE_OPER_BONUS); $req->setTransData($transData); $result = $this->_callWalletOperation->addToWalletActive($req); return $result; }