set the active payment method. return true on succes - false if the method is not allowed
Note: you hast set a shipping group first!

@param TdbShopPaymentMethod $oShopPayment

@return bool
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;
    }
629324
protected function _setPayment($sPaymentid)
    {
        $oPayment = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);

        if (!$oPayment->load($sPaymentid)) {
            return null;
        }

        $aDynvalue = $this->getDynamicValues();

        $oPayment->setDynValues(\OxidEsales\Eshop\Core\Registry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value));

        // collecting dynamic values
        $aDynVal = [];

        if (is_array($aPaymentDynValues = $oPayment->getDynValues())) {
            foreach ($aPaymentDynValues as $key => $oVal) {
                if (isset($aDynvalue[$oVal->name])) {
                    $oVal->value = $aDynvalue[$oVal->name];
                }

                //$oPayment->setDynValue($key, $oVal);
                $aPaymentDynValues[$key] = $oVal;
                $aDynVal[$oVal->name] = $oVal->value;
            }
        }

        // Store this payment information, we might allow users later to
        // reactivate already give payment information

        $oUserpayment = oxNew(\OxidEsales\Eshop\Application\Model\UserPayment::class);
        $oUserpayment->oxuserpayments__oxuserid = clone $this->oxorder__oxuserid;
        $oUserpayment->oxuserpayments__oxpaymentsid = new \OxidEsales\Eshop\Core\Field($sPaymentid, \OxidEsales\Eshop\Core\Field::T_RAW);
        $oUserpayment->oxuserpayments__oxvalue = new \OxidEsales\Eshop\Core\Field(\OxidEsales\Eshop\Core\Registry::getUtils()->assignValuesToText($aDynVal), \OxidEsales\Eshop\Core\Field::T_RAW);
        $oUserpayment->oxpayments__oxdesc = clone $oPayment->oxpayments__oxdesc;
        $oUserpayment->oxpayments__oxlongdesc = clone $oPayment->oxpayments__oxlongdesc;
        $oUserpayment->setDynValues($aPaymentDynValues);
        $oUserpayment->save();

        // storing payment information to order
        $this->oxorder__oxpaymentid = new \OxidEsales\Eshop\Core\Field($oUserpayment->getId(), \OxidEsales\Eshop\Core\Field::T_RAW);
        $this->oxorder__oxpaymenttype = clone $oUserpayment->oxuserpayments__oxpaymentsid;

        // returning user payment object which will be used later in code ...
        return $oUserpayment;
    }
465764
protected function setPaymorrowPaymentMethodId()
    {
        /** @var oxPayment|OxpsPaymorrowOxPayment $payment */
        $payment = oxNew('oxPayment');
        $paymentIdField = self::OXPS_PAYMENT_ID_FIELD;
        $paymentName = (string) $this->getConfig()->getRequestParameter(self::OXPS_PM_PAYMENT_NAME_FIELD);

        if ($payment->loadByPaymorrowName($paymentName) and
            !$this->getConfig()->getRequestParameter($paymentIdField)
        ) {
            $this->appendPostData(array($paymentIdField => (string) $payment->getId()));
        }
    }
1177342
public function setOrderPGroup($orderPGroup)
    {
        if (!is_array($orderPGroup)) {
            $this->orderPGroup = null;

            return false;
        }
        $isValid = true;
        $index = 0;
        while ($isValid && $index < count($orderPGroup)) {
            if (strlen($orderPGroup[$index]) > 155) {
                $isValid = false;
            } else {
                $isValid = true;
            }
            $index++;
        }
        if (!$isValid) {
            $this->orderPGroup = null;

            return false;
        }
        $this->orderPGroup = $orderPGroup;

        return true;
    }
1160
public function validatePayment($oBasket)
    {
        $paymentId = $oBasket->getPaymentId();

        if (!$this->isValidPaymentId($paymentId) || !$this->isValidPayment($oBasket)) {
            return self::ORDER_STATE_INVALIDPAYMENT;
        }
    }
634237
public function isActiveDefaultPayment()
    {
        return $this->scopeConfig->isSetFlag(
            self::XML_PAYMENT_DEFAULT_ACTIVE_DEFAULT_PAYMENT,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
    }
797174
public function isPayPalOrder()
    {
        $active = false;

        $order = $this->getEditObject();
        if ($order && $order->getFieldData('oxpaymenttype') == 'oxidpaypal') {
            $active = true;
        }

        return $active;
    }
1032824
public function setPaymentMethod($method)
    {
        try {
            if ($method instanceof PagSeguroDirectPaymentMethods) {
                $this->paymentMethod = $method;
            } else {
                $this->paymentMethod = new PagSeguroDirectPaymentMethods($method);
            }
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }
330112
public function setPayMethod($payMethod)
    {
        $payMethod = strtoupper($payMethod);
        switch ($payMethod) {
            case 'CCVISAMC':
                $this->payMethod = 'CCVISAMC';
                $retval = true;
                break;

            case 'CCAMEX':
                $this->payMethod = 'CCAMEX';
                $retval = true;
                break;

            case 'CCDINERS':
                $this->payMethod = 'CCDINERS';
                $retval = true;
                break;

            case 'CCJCB':
                $this->payMethod = 'CCJCB';
                $retval = true;
                break;

            case 'WIRE':
                $this->payMethod = 'WIRE';
                $retval = true;
                break;

            case 'CASH':
                $this->payMethod = 'CASH';
                $retval = true;
                break;

            default:
                $this->payMethod = null;
                $retval = false;
        }

        return $retval;
    }
13856
protected function GetSuccessURL($sStepName = '')
    {
        if (empty($sStepName)) {
            $sStepName = 'shipping';
        }
        $sURL = false;
        $oShippingStep = TdbShopOrderStep::GetStep($sStepName);
        /** @var $oShippingStep TdbShopOrderStep */
        if (!is_null($oShippingStep)) {
            $sURL = $oShippingStep->GetStepURL(true, true);
            if ('/' == substr($sURL, -1)) {
                $sURL = substr($sURL, 0, -1);
            }

            if ('shipping' == $sStepName) {
                $aResponse = array('module_fnc' => array(TGlobal::instance()->GetExecutingModulePointer()->sModuleSpotName => 'ExecuteStep'), MTShopOrderWizardCore::URL_PARAM_STEP_METHOD => '', 'aShipping' => array('shop_shipping_group_id' => TShopBasket::GetInstance()->GetActiveShippingGroup()->id, 'shop_payment_method_id' => $this->GetOwningPaymentMethodId()));
                $sURL .= '?'.str_replace('&amp;', '&', TTools::GetArrayAsURL($aResponse));
            }
        }

        return $sURL;
    }
393808
protected function isShortcutPayment()
    {
        $trigger = (int) \OxidEsales\Eshop\Core\Registry::getSession()->getVariable(self::OEPAYPAL_TRIGGER_NAME);
        return (bool) ($trigger == self::OEPAYPAL_SHORTCUT);
    }
162183
protected function JumpSelectPaymentMethod($sPaymentMethodId = null, $sPaymentMethodNameInternal = null)
    {
        $oPaymentMethod = null;
        if (is_null($sPaymentMethodId)) {
            $sPaymentMethodId = $this->global->GetUserData('sPaymentMethodId');
        }
        if (empty($sPaymentMethodId)) {
            $oPaymentMethod = TdbShopPaymentMethod::GetNewInstance();
            if (is_null($sPaymentMethodNameInternal)) {
                $sPaymentMethodNameInternal = $this->global->GetUserData('sPaymentMethodNameInternal');
            }
            $oPaymentMethod->LoadFromField('name_internal', $sPaymentMethodNameInternal);
        }

        if (is_null($oPaymentMethod)) {
            $oPaymentMethod = TdbShopPaymentMethod::GetNewInstance();
            $oPaymentMethod->Load($sPaymentMethodId);
        }

        if ($oPaymentMethod->IsAvailable()) {
            $oBasket = TShopBasket::GetInstance();
            $oBasket->SetActivePaymentMethod($oPaymentMethod);

            // check if payment method was set
            $oCheckPayment = $oBasket->GetActivePaymentMethod();
            if (!$oCheckPayment) {
                TTools::WriteLogEntry('JumpSelectPaymentMethod: unable to select payment method', 1, __FILE__, __LINE__);
            }

            // also set shipping type if not already set
            $oActiveShippingGroup = $oBasket->GetActiveShippingGroup();
            if (is_null($oActiveShippingGroup) || !$oPaymentMethod->isConnected('shop_shipping_group', $oActiveShippingGroup->id)) {
                $oMatchingShippingGroup = TdbShopShippingGroupList::GetShippingGroupsThatAllowPaymentWith($oPaymentMethod->fieldNameInternal);
                $oBasket->SetActiveShippingGroup($oMatchingShippingGroup);
                $oBasket->RecalculateBasket();
            }

            $oPaymentMethod->GetFieldShopPaymentHandler()->PostSelectPaymentHook(TCMSMessageManager::GLOBAL_CONSUMER_NAME);

            return true;
        } else {
            trigger_error('trying to access an unavailable payment method through JumpSelect', E_USER_WARNING);

            return false;
        }
    }
622870
public function postSelectPaymentHook(TdbShop $oShop, TShopBasket $oBasket, TdbDataExtranetUser $oUser, $sMessageConsumer)
    {
        return $this->GetFieldShopPaymentHandler()->PostSelectPaymentHook($sMessageConsumer);
    }
1004750
protected function _setPaymorrowTypeOfPayment()
    {
        /** @var OxpsPaymorrowOxPayment|oxPayment $oxPayment */
        $oxPayment = $this->getPayment();

        if (($oxPayment instanceof oxPayment) and $oxPayment->isPaymorrowActiveAndMapped()) {
            $this->_updatePaymentDescription($oxPayment);
        }
    }
382018
public function setPaymentStatus($status, \OxidEsales\Eshop\Application\Model\Order $order = null)
    {
        $this->setValue('oepaypal_paymentstatus', $status);

        // if payment completed, set order paid
        if ($status == \OxidEsales\PayPalModule\Model\PayPalOrder::PAYPAL_ORDER_STATE_COMPLETED) {
            if (is_null($order)) {
                $order = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
                $order->load($this->getOrderId());
            }
            $order->markOrderPaid();
        }
    }
659252
protected function SetShipToBillingAddress($sShipToBillingAddress)
    {
        $bAllowChange = true;
        if ('1' == $sShipToBillingAddress) {
            if (TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING == $this->AddressUsedAsPrimaryAddress()) {
                if ('1' == $this->GetShippingAddressData('is_dhl_packstation')) {
                    $bAllowChange = false;
                    $oMsgManager = TCMSMessageManager::GetInstance();
                    $oMsgManager->AddMessage(TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING, 'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION');
                }
            }
        }
        if ($bAllowChange) {
            parent::SetShipToBillingAddress($sShipToBillingAddress);
        }
    }
1214704
protected function _setPaymentStatus( MShop_Order_Item_Interface $invoice, array $response )
	{
		if( !isset( $response['PAYMENTSTATUS'] ) ) {
			return;
		}

		switch ( $response['PAYMENTSTATUS'] )
		{
			case 'Pending':
				if( isset( $response['PENDINGREASON'] ) )
				{
					if( $response['PENDINGREASON'] === 'authorization' )
					{
						$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_AUTHORIZED );
						break;
					}

					$str = 'PayPal Express: order ID = ' . $invoice->getId() . ', PENDINGREASON = ' . $response['PENDINGREASON'];
					$this->_getContext()->getLogger()->log( $str, MW_Logger_Abstract::INFO );
				}

				$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_PENDING );
				break;

			case 'In-Progress':
				$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_PENDING );
				break;

			case 'Completed':
			case 'Processed':
				$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_RECEIVED );
				break;

			case 'Failed':
			case 'Denied':
			case 'Expired':
				$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_REFUSED );
				break;

			case 'Refunded':
			case 'Partially-Refunded':
			case 'Reversed':
				$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_REFUND );
				break;

			case 'Canceled-Reversal':
			case 'Voided':
				$invoice->setPaymentStatus( MShop_Order_Item_Abstract::PAY_CANCELED );
				break;

			default:
				$str = 'PayPal Express: order ID = ' . $invoice->getId() . ', response = ' . print_r( $response, true );
				$this->_getContext()->getLogger()->log( $str, MW_Logger_Abstract::INFO );
		}
	}