Update payment model description fields with custom translations and set the payment.

@param OxpsPaymorrowOxPayment|oxPayment $oxPayment
970822
protected function _updatePaymentDescription(oxPayment $oxPayment)
    {
        $oLang = oxRegistry::getLang();

        if ($oxPayment->getPaymorrowPaymentType() == 'pm_invoice') {
            $oxPayment->oxpayments__oxdesc = new oxField(
                $oLang->translateString('PAYMORROW_PAYMENT_METHOD_NAME_INVOICE')
            );
        } elseif ($oxPayment->getPaymorrowPaymentType() == 'pm_sdd') {
            $oxPayment->oxpayments__oxdesc = new oxField(
                $oLang->translateString('PAYMORROW_PAYMENT_METHOD_NAME_DIRECT_DEBIT')
            );
        }

        $this->_oPayment = $oxPayment;
    }
1050240
public function void(InfoInterface $payment)
    {
        try {
            $transactionId = $payment->getAdditionalInformation('real_transaction_id');

            if (empty($transactionId)) {
                throw new LocalizedException(
                    __('Please wait while transaction gets updated from Bolt.')
                );
            }

            //Get transaction data
            $transactionData = ['transaction_id' => $transactionId];
            $apiKey = $this->configHelper->getApiKey();

            //Request Data
            $requestData = $this->dataObjectFactory->create();
            $requestData->setApiData($transactionData);
            $requestData->setDynamicApiUrl(ApiHelper::API_VOID_TRANSACTION);
            $requestData->setApiKey($apiKey);
            //Build Request
            $request = $this->apiHelper->buildRequest($requestData);
            $result = $this->apiHelper->sendRequest($request);
            $response = $result->getResponse();

            if (empty($response)) {
                throw new LocalizedException(
                    __('Bad void response from boltpay')
                );
            }

            if (@$response->status != 'cancelled') {
                throw new LocalizedException(__('Payment void error.'));
            }

            $order = $payment->getOrder();

            $this->orderHelper->updateOrderPayment($order, null, $response->reference);

            return $this;
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }
209924
function paypalwpp() {
    include_once(zen_get_file_directory(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', 'paypalwpp.php', 'false'));
    global $order;
    $this->code = 'paypalwpp';
    $this->codeTitle = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_EC;
    $this->codeVersion = '1.5.1';
    $this->enableDirectPayment = FALSE;
    $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
    // Set the title & description text based on the mode we're in ... EC vs US/UK vs admin
    if (IS_ADMIN_FLAG === true) {
      $this->description = sprintf(MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_DESCRIPTION, ' (rev' . $this->codeVersion . ')');
      switch (MODULE_PAYMENT_PAYPALWPP_MODULE_MODE) {
        case ('PayPal'):
          $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_EC;
        break;
        case ('Payflow-UK'):
          $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_PRO20;
        break;
        case ('Payflow-US'):
          if (defined('MODULE_PAYMENT_PAYPALWPP_PAYFLOW_EC') && MODULE_PAYMENT_PAYPALWPP_PAYFLOW_EC == 'Yes') {
            $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_PF_EC;
          } else {
            $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_PF_GATEWAY;
          }
        break;
        default:
          $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_EC;
      }
      if ($this->enabled) {
        if ( (MODULE_PAYMENT_PAYPALWPP_MODULE_MODE == 'PayPal' && (MODULE_PAYMENT_PAYPALWPP_APISIGNATURE == '' || MODULE_PAYMENT_PAYPALWPP_APIUSERNAME == '' || MODULE_PAYMENT_PAYPALWPP_APIPASSWORD == ''))
          || (substr(MODULE_PAYMENT_PAYPALWPP_MODULE_MODE,0,7) == 'Payflow' && (MODULE_PAYMENT_PAYPALWPP_PFPARTNER == '' || MODULE_PAYMENT_PAYPALWPP_PFVENDOR == '' || MODULE_PAYMENT_PAYPALWPP_PFUSER == '' || MODULE_PAYMENT_PAYPALWPP_PFPASSWORD == ''))
          ) $this->title .= '<span class="alert"><strong> NOT CONFIGURED YET</strong></span>';
        if (MODULE_PAYMENT_PAYPALWPP_SERVER =='sandbox') $this->title .= '<strong><span class="alert"> (sandbox active)</span></strong>';
        if (MODULE_PAYMENT_PAYPALWPP_DEBUGGING =='Log File' || MODULE_PAYMENT_PAYPALWPP_DEBUGGING =='Log and Email') $this->title .= '<strong> (Debug)</strong>';
        if (!function_exists('curl_init')) $this->title .= '<strong><span class="alert"> CURL NOT FOUND. Cannot Use.</span></strong>';
      }
    } else {
      $this->description = MODULE_PAYMENT_PAYPALWPP_TEXT_DESCRIPTION;
      $this->title = MODULE_PAYMENT_PAYPALWPP_EC_TEXT_TITLE; //pp
    }

    if ((!defined('PAYPAL_OVERRIDE_CURL_WARNING') || (defined('PAYPAL_OVERRIDE_CURL_WARNING') && PAYPAL_OVERRIDE_CURL_WARNING != 'True')) && !function_exists('curl_init')) $this->enabled = false;

    $this->enableDebugging = (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log File' || MODULE_PAYMENT_PAYPALWPP_DEBUGGING =='Log and Email');
    $this->emailAlerts = (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log File' || MODULE_PAYMENT_PAYPALWPP_DEBUGGING =='Log and Email' || MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Alerts Only');
    $this->doDPonly = (MODULE_PAYMENT_PAYPALWPP_MODULE_MODE =='Payflow-US' && !(defined('MODULE_PAYMENT_PAYPALWPP_PAYFLOW_EC') && MODULE_PAYMENT_PAYPALWPP_PAYFLOW_EC == 'Yes'));
    $this->showPaymentPage = (MODULE_PAYMENT_PAYPALWPP_SKIP_PAYMENT_PAGE == 'No') ? true : false;
    $this->sort_order = MODULE_PAYMENT_PAYPALWPP_SORT_ORDER;

    $this->buttonSourceEC = 'ZenCart-EC_us';
    $this->buttonSourceDP = 'ZenCart-DP_us';
    if (MODULE_PAYMENT_PAYPALWPP_MODULE_MODE == 'Payflow-UK') {
      $this->buttonSourceEC = 'ZenCart-EC_uk';
      $this->buttonSourceDP = 'ZenCart-DP_uk';
    }
    if (MODULE_PAYMENT_PAYPALWPP_MODULE_MODE == 'Payflow-US') {
      $this->buttonSourceEC = 'ZenCart-ECGW_us';
      $this->buttonSourceDP = 'ZenCart-GW_us';
    }

    $this->order_pending_status = MODULE_PAYMENT_PAYPALWPP_ORDER_PENDING_STATUS_ID;
    if ((int)MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID > 0) {
      $this->order_status = MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID;
    }
    $this->new_acct_notify = MODULE_PAYMENT_PAYPALWPP_NEW_ACCT_NOTIFY;
    $this->zone = (int)MODULE_PAYMENT_PAYPALWPP_ZONE;
    if (is_object($order)) $this->update_status();

    if (PROJECT_VERSION_MAJOR != '1' && substr(PROJECT_VERSION_MINOR, 0, 3) != '5.0') $this->enabled = false;

    $this->cards = array();
    // if operating in markflow mode, start EC process when submitting order
    if (!$this->in_special_checkout()) {
      $this->form_action_url = zen_href_link('ipn_main_handler.php', 'type=ec&markflow=1&clearSess=1&stage=final', 'SSL', true, true, true);
    }

    // debug setup
    if (!@is_writable($this->_logDir)) $this->_logDir = DIR_FS_CATALOG . $this->_logDir;
    if (!@is_writable($this->_logDir)) $this->_logDir = DIR_FS_SQL_CACHE;
    // Regular mode:
    if ($this->enableDebugging) $this->_logLevel = 2;
    // DEV MODE:
    if (defined('PAYPAL_DEV_MODE') && PAYPAL_DEV_MODE == 'true') $this->_logLevel = 3;

    if (IS_ADMIN_FLAG === true) $this->tableCheckup();

  }
678426
private function setPaymentMethod($quote)
    {
        $quote->setPaymentMethod(Payment::METHOD_CODE);
        // Set Sales Order Payment
        $quote->getPayment()->importData(['method' => Payment::METHOD_CODE])->save();
    }
1110761
public function setPaymentMethod(ComSubscriptionsDomainPaymentMethodInterface $method)
    {
        $this->_payment_method = $method;
        $this->method = (string) $method;

        return $this;
    }
73596
public function SetActivePaymentMethod($oShopPayment)
    {
        $oldActivePaymentMethod = $this->GetActivePaymentMethod();
        $isPaymentSet = parent::SetActivePaymentMethod($oShopPayment);
        $newActivePaymentMethod = $this->GetActivePaymentMethod();
        if (null === $oldActivePaymentMethod || null === $newActivePaymentMethod) {
            return $isPaymentSet;
        }
        if (false === $oldActivePaymentMethod->IsSameAs($newActivePaymentMethod)) {
            return $isPaymentSet;
        }
        $activeCurrency = $this->getCurrencyService()->getObject();

        if (null === $newActivePaymentMethod->fieldValueOriginal && true == $activeCurrency->fieldIsBaseCurrency) {
            return $isPaymentSet;
        }

        if (null !== $newActivePaymentMethod->fieldValueOriginal) {
            $convertedValue = \TdbPkgShopCurrency::ConvertToActiveCurrency($newActivePaymentMethod->fieldValueOriginal);
            if ($convertedValue === $newActivePaymentMethod->GetPrice()) {
                return $isPaymentSet;
            }
        }

        $reloadedPayment = \TdbShopPaymentMethod::GetNewInstance($newActivePaymentMethod->id);
        parent::SetActivePaymentMethod($reloadedPayment);

        return $isPaymentSet;
    }
219198
public function isUserPaymentPaymorrowMethod()
    {
        $sPaymentId = $this->oxuserpayments__oxpaymentsid->value;

        /** @var OxpsPaymorrowOxPayment|oxPayment $oxPayment */
        $oxPayment = oxNew( 'oxPayment' );
        $oxPayment->load( $sPaymentId );

        return $oxPayment->isPaymorrowActiveAndMapped();
    }
997089
protected function addInvoice($money, $options)
    {
        $this->xml->TxnDetails(null, 'Transaction')
            ->merchantreference($options['order_id'], 'TxnDetails')
            ->amount($this->amount($money), 'TxnDetails', array('currency'=> static::$default_currency));
        $captureMethod = static::METHOD_ECOMM; # For 3D Secure or No 3D Secure transactions.
        if ($options['moto']) {# MOTO transactions.
            $captureMethod = static::METHOD_MOTO;
        }
        $this->xml->capturemethod($captureMethod, 'TxnDetails');
        if ($options['installments']) {
            $this->xml->Instalments(null, 'TxnDetails');
            $this->xml->number($options['installments'], 'Installments');
        }
    }
4371
public function SetActivePaymentMethod($oShopPayment)
    {
        // make sure the shop payment selected is valid for the shipping group selected
        $bMethodOk = false;
        if (!is_null($oShopPayment)) {
            $oList = $this->GetAvailablePaymentMethods();
            if (!is_null($oList) && $oList->IsInList($oShopPayment->id)) {
                $bMethodOk = true;
                $this->oActivePaymentMethod = $oShopPayment;
            } else {
                $this->oActivePaymentMethod = null;
            }
        }

        return $bMethodOk;
    }
637748
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CommerceOrderPayment addCommerceOrderPayment(
		CommerceOrderPayment commerceOrderPayment) {
		commerceOrderPayment.setNew(true);

		return commerceOrderPaymentPersistence.update(commerceOrderPayment);
	}
52163
public static com.liferay.commerce.model.CommerceOrderPayment updateCommerceOrderPayment(
		com.liferay.commerce.model.CommerceOrderPayment commerceOrderPayment) {
		return getService().updateCommerceOrderPayment(commerceOrderPayment);
	}
134274
private function setPayRequestDetails($data)
    {
        $this->post = $this->setRequestData([
            'actionType'   => 'PAY',
            'currencyCode' => $this->currency,
            'receiverList' => [
                'receiver' => $data['receivers'],
            ],
            'returnUrl'       => $data['return_url'],
            'cancelUrl'       => $data['cancel_url'],
            'requestEnvelope' => $this->setEnvelope(),
            'feesPayer'       => $data['payer'],
        ])->filter(function ($value, $key) {
            return (($key === 'feesPayer') && empty($value)) ? null : $value;
        });
    }
652126
public function addUpdateMandateRequest(string $payerNr, string $newPayerNr): void
    {
        $this->mandates[] = new Record(
            'UpdateMandateRequest',
            $this->payeeBgNode,
            new Number(0, $payerNr, 'PayerNumber'),
            $this->payeeBgNode,
            new Number(0, $newPayerNr, 'PayerNumber'),
            new Text(0, str_pad('', 26))
        );
    }
36919
protected function addInvoice($money, $options)
    {
        $this->xml->TxnDetails(null, 'Transaction')
            ->merchantreference($options['order_id'], 'TxnDetails')
            ->amount(
                $this->amount($money),
                'TxnDetails',
                array('currency' => self::$default_currency)
            );
        $this->addThreeDSecure($options);
    }
1170647
public static function enablePayPalRDFA()
    {
        // If PayPal activated on other sub shops do not change global RDF setting.
        if ('EE' == \OxidEsales\Eshop\Core\Registry::getConfig()->getEdition() && self::isPayPalActiveOnSubShops()) {
            return;
        }

        $query = "INSERT IGNORE INTO `oxobject2payment` (`OXID`, `OXPAYMENTID`, `OXOBJECTID`, `OXTYPE`) VALUES('oepaypalrdfa', 'oxidpaypal', 'PayPal', 'rdfapayment')";
        \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute($query);
    }
590801
private static function updatePaymentStatus($invoice)
    {
        if (! $invoice->payment || $invoice->getStatus() === 'payed') {
            return $invoice;
        }
        $receipt = $invoice->get_payment();
        Bank_Service::update($receipt);
        if ($invoice->get_payment()->isPayed()){
            $invoice->setStatus('payed');
            $invoice->update();
        }
        return $invoice;
    }
998615
public function updateOrderPayment($order, $transaction = null, $reference = null, $hookType = null)
    {
        // Fetch transaction info if transaction is not passed as a parameter
        if ($reference && !$transaction) {
            $transaction = $this->fetchTransactionInfo($reference);
        } else {
            $reference = $transaction->reference;
        }

        /** @var OrderPaymentInterface $payment */
        $payment = $order->getPayment();

        $this->checkPaymentMethod($payment);

        // Check for total amount mismatch between magento and bolt order.
        $this->holdOnTotalsMismatch($order, $transaction);

        // Get the last stored transaction parameters
        $prevTransactionState = $payment->getAdditionalInformation('transaction_state');
        $prevTransactionReference = $payment->getAdditionalInformation('transaction_reference');

        // Get the transaction state
        $transactionState = $this->getTransactionState($transaction, $payment, $hookType);

        $newCapture = in_array($transactionState, [self::TS_CAPTURED, self::TS_COMPLETED])
            ? $this->getUnprocessedCapture($payment, $transaction)
            : null;

        // Skip if there is no state change (i.e. fetch transaction call from admin panel / Payment model)
        // Reference check and $newCapture were added to support multiple refunds and captures,
        // valid same state transitions
        if (
            $transactionState == $prevTransactionState &&
            $reference == $prevTransactionReference &&
            !$newCapture
        ) {
            if ($this->isAnAllowedUpdateFromAdminPanel($order, $transactionState)){
                $payment->setIsTransactionApproved(true);
            }
            return;
        }

        if (!$this->validateTransition($prevTransactionState, $transactionState)) {
            throw new LocalizedException(__(
                'Invalid transaction state transition: %1 -> %2',
                $prevTransactionState,
                $transactionState
            ));
        }

        // preset default payment / transaction values
        // before more specific changes below
        if ($newCapture) {
            $amount = $newCapture->amount->amount;
        } else {
            $amount = $transaction->amount->amount;
        }
        $transactionId = $transaction->id;

        $realTransactionId = $parentTransactionId = $payment->getAdditionalInformation('real_transaction_id');
        $realTransactionId = $realTransactionId ?: $transaction->id;
        $paymentAuthorized = (bool)$payment->getAdditionalInformation('authorized');

        $processedCaptures = $this->getProcessedCaptures($payment);
        $processedRefunds = $this->getProcessedRefunds($payment);

        switch ($transactionState) {

            case self::TS_ZERO_AMOUNT:
                $orderState = OrderModel::STATE_PROCESSING;
                $transactionType = Transaction::TYPE_ORDER;
                break;

            case self::TS_PENDING:
                $orderState = OrderModel::STATE_PAYMENT_REVIEW;
                $transactionType = Transaction::TYPE_ORDER;
                break;

            case self::TS_AUTHORIZED:
                $orderState = OrderModel::STATE_PROCESSING;
                $transactionType = Transaction::TYPE_AUTH;
                $transactionId = $transaction->id.'-auth';
                break;

            case self::TS_CAPTURED:
                if (!$newCapture) return;
                $orderState = OrderModel::STATE_PROCESSING;
                $transactionType = Transaction::TYPE_CAPTURE;
                $transactionId = $transaction->id.'-capture-'.$newCapture->id;
                $parentTransactionId = $transaction->id.'-auth';
                break;

            case self::TS_PARTIAL_VOIDED:
                $authorizationTransaction = $payment->getAuthorizationTransaction();
                $authorizationTransaction->closeAuthorization();
                $order->addCommentToStatusHistory($this->getVoidMessage($payment));
                $order->save();
                return;

            case self::TS_COMPLETED:
                if (!$newCapture) return;
                $orderState = OrderModel::STATE_PROCESSING;
                $transactionType = Transaction::TYPE_CAPTURE;
                if ($paymentAuthorized) {
                    $transactionId = $transaction->id.'-capture-'.$newCapture->id;
                    $parentTransactionId = $transaction->id.'-auth';
                } else {
                    $transactionId = $transaction->id.'-payment';
                }
                break;

            case self::TS_CANCELED:
                $orderState = OrderModel::STATE_CANCELED;
                $transactionType = Transaction::TYPE_VOID;
                $transactionId = $transaction->id.'-void';
                $parentTransactionId = $paymentAuthorized ? $transaction->id.'-auth' : $transaction->id;
                break;

            case self::TS_REJECTED_REVERSIBLE:
                $orderState = OrderModel::STATE_HOLDED;
                $transactionType = Transaction::TYPE_ORDER;
                $transactionId = $transaction->id.'-rejected_reversible';
                break;

            case self::TS_REJECTED_IRREVERSIBLE:
                $orderState = OrderModel::STATE_CANCELED;
                $transactionType = Transaction::TYPE_ORDER;
                $transactionId = $transaction->id.'-rejected_irreversible';
                break;

            case self::TS_CREDIT_COMPLETED:
                if (in_array($transaction->id, $processedRefunds)) return;
                $transactionType = Transaction::TYPE_REFUND;
                $transactionId = $transaction->id.'-refund';
                if (Hook::$fromBolt) {
                    // Refunds need to be initiated from the store admin (Invoice -> Credit Memo)
                    // If called from Bolt merchant dashboard there is no enough info to sync the totals
                    $orderState = OrderModel::STATE_HOLDED;
                } else {
                    $orderState = OrderModel::STATE_PROCESSING;
                }
                break;

            default:
                throw new LocalizedException(__(
                    'Unhandled transaction state : %1',
                    $transactionState
                ));
                break;
        }

        // set order state and status
        $this->setOrderState($order, $orderState);

        // format the last transaction data for storing within the order payment record instance

        if ($newCapture) {
            array_push($processedCaptures, $newCapture->id);
        }

        if ($transactionState == self::TS_CREDIT_COMPLETED) {
            array_push($processedRefunds, $transaction->id);
        }

        $paymentData = [
            'real_transaction_id' => $realTransactionId,
            'transaction_reference' => $transaction->reference,
            'transaction_state' => $transactionState,
            'authorized' => $paymentAuthorized || in_array($transactionState, [self::TS_AUTHORIZED, self::TS_CAPTURED]),
            'captures' => implode(',', $processedCaptures),
            'refunds' => implode(',', $processedRefunds)
        ];

        // format the price with currency symbol
        $formattedPrice = $order->getBaseCurrency()->formatTxt($amount / 100);

        $message = __(
            'BOLTPAY INFO :: PAYMENT Status: %1 Amount: %2<br>Bolt transaction: %3',
            $this->getBoltTransactionStatus($transactionState),
            $formattedPrice,
            $this->formatReferenceUrl($transaction->reference)
        );

        $transactionData = $this->formatTransactionData($order, $transaction, $amount);

        // update order payment instance
        $payment->setParentTransactionId($parentTransactionId);
        $payment->setTransactionId($transactionId);
        $payment->setLastTransId($transactionId);
        $payment->setAdditionalInformation($paymentData);
        $payment->setIsTransactionClosed($transactionType != Transaction::TYPE_AUTH);

        // We will create an invoice if we have zero amount or new capture.
        if ($this->isCaptureHookRequest($newCapture) || $this->isZeroAmountHook($transactionState)) {
            $this->validateCaptureAmount($order, $amount / 100);
            $invoice = $this->createOrderInvoice($order, $realTransactionId, $amount / 100);
        }

        if (!$order->getTotalDue()) {
            $payment->setShouldCloseParentTransaction(true);
        }

        if ($newCapture && @$invoice) {
            $this->_eventManager->dispatch(
                'sales_order_payment_capture',
                ['payment' => $payment, 'invoice' => $invoice]
            );
        }

        // build a new transaction record and assign it to the order and payment
        /** @var Transaction $payment_transaction */
        $payment_transaction = $this->transactionBuilder->setPayment($payment)
            ->setOrder($order)
            ->setTransactionId($transactionId)
            ->setAdditionalInformation([
                Transaction::RAW_DETAILS => $transactionData
            ])
            ->setFailSafe(true)
            ->build($transactionType);

        $payment->addTransactionCommentsToOrder(
            $payment_transaction,
            $message
        );

        $payment_transaction->save();

        // save payment and order
        $payment->save();
        $order->save();
    }