Process logic by payment Type

@throws ProcessorException
779018
private function doProcessType()
	{
		$type = new Type($this->payment->type, $this->payment->toArray());

		switch ($type->sid()) {

			case Type::CITY:

				break;

			case Type::FEE:

				break;

			case Type::CHECK:

				// todo check 'check' request

				// register check request
				$this->payment->status = Status::ENABLED;

				break;

			case Type::PAY:


				// pay after 'check' request
				$payment = self::findCheck(
					$this->payment->term,
					$this->payment->city,
					$this->payment->amount,
					$this->payment->to,
					Status::ENABLED
				);

				if (!$payment) {
					throw new ProcessorException(ProcessorException::RC_CHECK_NOT_FOUND);
				}

				// close 'check' request
				$payment->status = Status::PAY;
				$payment->saveByType();

				// processed 'payment' request
				$this->payment->status = Status::PROCESSED;
				$this->payment->code = uniqid();

				break;

			case Type::CANCEL:

				// find pay in status 'processed'
				$payment = self::findPayTo(
					$this->payment->term,
					$this->payment->code,
					$this->payment->to,
					Status::PROCESSED
				);

				if ($payment) {

					// cancel 'pay' request
					$payment->status = Status::CANCELED;
					$payment->saveByType();

					// save cancel request in 'processed'
					$this->payment->status = Status::PROCESSED;
					$this->payment->amount = $payment->amount;
					$this->payment->name = $payment->name;
					$this->payment->to = $payment->to;

				} else {
					throw new ProcessorException(ProcessorException::RC_PAY_NOT_FOUND);
				}

				break;

			case Type::STATUS:

				// status for pay
				$payment = self::findPayTo(
					$this->payment->term,
					$this->payment->code,
					$this->payment->to
				);

				// init data from 'pay' request into current 'status' request
				if ($payment) {
					$this->payment->id = $payment->id;
					$this->payment->status = $payment->status;
					$this->payment->amount = $payment->amount;
					$this->payment->to = $payment->to;
					$this->payment->name = $payment->name;
				} else {
					throw new ProcessorException(ProcessorException::RC_PAY_NOT_FOUND);
				}

				break;

		}

		return '00';

	}
735961
public function processPayment(StripeMethod $paymentMethod, $amount)
    {
        /**
         * check and set payment data.
         */
        $chargeParams = $this->prepareData(
            $paymentMethod,
            $amount
        );

        /**
         * make payment.
         */
        $transaction = $this
            ->transactionFactory
            ->create($chargeParams);

        /**
         * Payment paid done.
         *
         * Paid process has ended ( No matters result )
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderDone(
                $this->paymentBridge,
                $paymentMethod
            );

        /**
         * when a transaction is successful, it is marked as 'closed'.
         */
        if ($transaction['paid'] != 1) {

            /**
             * Payment paid failed.
             *
             * Paid process has ended failed
             */
            $this
                ->paymentEventDispatcher
                ->notifyPaymentOrderFail(
                    $this->paymentBridge,
                    $paymentMethod
                );

            throw new PaymentException();
        }

        $paymentMethod
            ->setTransactionId($transaction['id'])
            ->setTransactionStatus('paid')
            ->setTransactionResponse($transaction);

        /**
         * Payment paid successfully.
         *
         * Paid process has ended successfully
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderSuccess(
                $this->paymentBridge,
                $paymentMethod
            );

        return $this;
    }
912963
private function processTransaction(Transaction $transaction, PaymillMethod $paymentMethod)
    {
        /**
         * Payment paid done
         *
         * Paid process has ended ( No matters result )
         */
        $this->paymentEventDispatcher->notifyPaymentOrderDone($this->paymentBridge, $paymentMethod);

        /**
         * when a transaction is successful, it is marked as 'closed'
         */
        $transactionStatus = $transaction->getStatus();
        if (empty($transactionStatus) || $transactionStatus != 'closed') {

            /**
             * Payment paid failed
             *
             * Paid process has ended failed
             */
            $paymentMethod->setTransaction($transaction);
            $this->paymentEventDispatcher->notifyPaymentOrderFail($this->paymentBridge, $paymentMethod);

            throw new PaymentException();
        }

        /**
         * Adding to PaymentMethod transaction information
         *
         * This information is only available in PaymentOrderSuccess event
         */
        $paymentMethod
            ->setTransactionId($transaction->getId())
            ->setTransactionStatus($transactionStatus)
            ->setTransaction($transaction);

        /**
         * Payment paid successfully
         *
         * Paid process has ended successfully
         */
        $this->paymentEventDispatcher->notifyPaymentOrderSuccess($this->paymentBridge, $paymentMethod);

        return $this;
    }
1201754
private void processPredecessors() throws SQLException
   {
      List<Row> rows = getRows("select * from " + m_schema + "taskpred where proj_id=? and delete_date is null", m_projectID);
      m_reader.processPredecessors(rows);
   }
980818
protected function ProcessStep()
    {
        if ($this->IsChangeShipToBillingStateRequest() || $this->PreventProcessStepMethodFromExecuting()) {
            $bContinue = false;
        } else {
            $bContinue = parent::ProcessStep();

            $bContinue = $this->ValidateStepData() && $bContinue;

            if ($bContinue) {
                $this->UpdateUser($this->GetUserData());
                // if we ship to billing address, we update only the primary address and change the secondary address to match this
                if ('1' == $this->GetShipToBillingAddress()) {
                    $oUser = self::getExtranetUserProvider()->getActiveUser();
                    switch ($this->AddressUsedAsPrimaryAddress()) {
                        case TdbDataExtranetUserAddress::FORM_DATA_NAME_SHIPPING:
                            $this->UpdateShippingAddress($this->GetShippingAddressData());
                            if (false == $oUser->ShipToBillingAddress()) {
                                // we need to set the billing address based on the shipping address
                                if (!empty($oUser->id)) {
                                    $oUser->SetAddressAsBillingAddress($oUser->fieldDefaultShippingAddressId);
                                } else {
                                    $oShippingAddress = $oUser->GetShippingAddress(true);
                                    if (null !== $oShippingAddress) {
                                        $oUser->UpdateBillingAddress($oShippingAddress->sqlData);
                                    }
                                }
                                $oUser->GetBillingAddress(true);
                            }
                            break;
                        default:
                        case TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING:
                            $this->UpdateBillingAddress($this->GetBillingAddressData());
                            // we need to set the billing address based on the shipping address
                            if (!empty($oUser->id)) {
                                $oUser->SetAddressAsShippingAddress($oUser->fieldDefaultBillingAddressId);
                            } else {
                                $oBillingAddress = $oUser->GetBillingAddress(true);
                                if (null !== $oBillingAddress) {
                                    $oUser->UpdateShippingAddress($oBillingAddress->sqlData);
                                }
                            }
                            $oUser->GetShippingAddress(true);
                            break;
                    }
                } else {
                    $this->UpdateBillingAddress($this->GetBillingAddressData());
                    $this->UpdateShippingAddress($this->GetShippingAddressData());
                }
            }
        }

        return $bContinue;
    }
887341
protected function setPaymentProcessing($sTxnId = null, $iFee = null)
    {
        //  Ensure we have a payment
        if (empty($this->oPayment)) {
            throw new RequestException('No payment selected.');
        }

        //  Update the payment
        $aData = ['txn_id' => $sTxnId ? $sTxnId : null];

        if (!is_null($iFee)) {
            $aData['fee'] = $iFee;
        }

        if (!$this->oPaymentModel->setComplete($this->oPayment->id, $aData)) {
            throw new RequestException('Failed to update existing payment.');
        }

        //  Has the invoice been paid in full? If so, mark it as paid and fire the invoice.paid.processing event
        if ($this->oInvoiceModel->isPaid($this->oInvoice->id, true)) {

            //  Mark Invoice as PAID_PROCESSING
            if (!$this->oInvoiceModel->setPaidProcessing($this->oInvoice->id)) {
                throw new RequestException('Failed to mark invoice as paid (processing).');
            }
        }

        //  Send receipt email
        $this->oPaymentModel->sendReceipt($this->oPayment->id);
        return $this;
    }
201024
public function setPaymentType($paymentType)
    {
        $allowedPaymentTypes = [
            self::PAYMENT_TYPE_ONLINE_BANKING, self::PAYMENT_TYPE_QR_PAYMENT, self::PAYMENT_TYPE_QUICK_PAYMENT
        ];

        if (in_array($paymentType, $allowedPaymentTypes)) {
            $this->payment_type = $paymentType;

            return $this;
        }

        throw new InvalidArgument(
            'Invalid value for payment_type. Allowed values are ' . implode(', ', $allowedPaymentTypes)
        );
    }
285962
public function checkEntityPayments($payments = array())
    {
        $requestReferenceDetails = new Structure\RequestEntityPayments();
        if ($payments) {
            foreach ($payments as $key => $value) {
                $requestPayment = new Structure\RequestReferenceDetails($value);
                $requestReferenceDetails->addPayment($requestPayment);
            }
        }

        $this->response = parent::checkEntityPayments($this->entity, $requestReferenceDetails);

        /**
         * Checks the state of the platform integration.
         */
        if (Exception\IntegrationState::check($this->response->state)) {
            throw new Exception\IntegrationState($this->response->state);
        }

        if ($this->response->state->state == 0) {
            throw new Exception\IntegrationResponse($this->response->state->message, $this->response->state->code);
        }

        return $this->response;
    }
164907
def process_callback(payment_transaction, callback_response)
      payment_transaction.processor_type = PaymentTransaction::PROCESSOR_CALLBACK
      payment_transaction.processor_name = @callback_type

      super payment_transaction, callback_response
    end
300090
public function process()
    {
        $rule = $this->getComponent();
        $context = $this->getContext();

        $processor = $this->getRuleProcessorFactory()->createProcessor($rule);
        $processor->setState($context);
        $processor->process();

        $this->trace($rule->getQtiClassName());
    }
992836
def process(self, processor:PreProcessors=None):
        ""
        if processor is not None: self.processor = processor
        self.processor = listify(self.processor)
        for p in self.processor: p.process(self)
        return self
180123
public function process()
	{
		$view = $this->getView();
		$context = $this->getContext();

		if( $view->param( 'c_step' ) !== 'process'
			|| $view->get( 'standardErrorList', [] ) !== []
			|| $view->get( 'standardStepActive' ) !== null
		) {
			return;
		}

		try
		{
			$orderCntl = \Aimeos\Controller\Frontend::create( $context, 'order' );
			$basketCntl = \Aimeos\Controller\Frontend::create( $context, 'basket' );


			if ( $view->param( 'cs_order', null ) !== null )
			{
				parent::process();

				$basket = $basketCntl->store();
				$orderItem = $orderCntl->add( $basket->getId(), ['order.type' => 'web'] )->store();

				$context->getSession()->set( 'aimeos/orderid', $orderItem->getId() );
			}
			elseif ( $view->param( 'cp_payment', null ) !== null )
			{
				$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL;
				$orderItem = $orderCntl->get( $context->getSession()->get( 'aimeos/orderid' ), false );
				$basket = $basketCntl->load( $orderItem->getBaseId(), $parts, false );
			}
			else
			{
				return;
			}

			$total = $basket->getPrice()->getValue() + $basket->getPrice()->getCosts();
			$services = $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );

			if( $services === [] || $total <= 0 && $this->isSubscription( $basket->getProducts() ) === false )
			{
				$orderCntl->save( $orderItem->setPaymentStatus( \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED ) );
			}
			elseif( ( $form = $this->processPayment( $basket, $orderItem ) ) !== null )
			{
				$view->standardUrlNext = $form->getUrl();
				$view->standardMethod = $form->getMethod();
				$view->standardProcessParams = $form->getValues();
				$view->standardUrlExternal = $form->getExternal();
				$view->standardHtml = $form->getHtml();

				return;
			}

			$view->standardUrlNext = $this->getUrlConfirm( $view, [], [] );
			$view->standardMethod = 'POST';
		}
		catch( \Aimeos\Client\Html\Exception $e )
		{
			$error = array( $context->getI18n()->dt( 'client', $e->getMessage() ) );
			$view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error;
		}
		catch( \Aimeos\Controller\Frontend\Exception $e )
		{
			$error = array( $context->getI18n()->dt( 'controller/frontend', $e->getMessage() ) );
			$view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error;
		}
		catch( \Aimeos\MShop\Exception $e )
		{
			$error = array( $context->getI18n()->dt( 'mshop', $e->getMessage() ) );
			$view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error;
		}
		catch( \Exception $e )
		{
			$error = array( $context->getI18n()->dt( 'client', 'A non-recoverable error occured' ) );
			$view->standardErrorList = $view->get( 'standardErrorList', [] ) + $error;
			$this->logException( $e );
		}
	}
1176233
protected function doProcess(Exchange $exchange, SerializableArray $processingContext)
    {
        try {
            return $this->processor->process($exchange);
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(
                'Processor could not process exchange: '.$e->getMessage(),
                $e->getCode(),
                $e
            );
        }
    }
932829
def process(self, request, item):
        """"""
        warn_untested()
        from paypal.pro.helpers import PayPalWPP

        wpp = PayPalWPP(request)
        params = self.cleaned_data
        params['creditcardtype'] = self.fields['acct'].card_type
        params['expdate'] = self.cleaned_data['expdate'].strftime("%m%Y")
        params['ipaddress'] = request.META.get("REMOTE_ADDR", "")
        params.update(item)

        try:
            # Create single payment:
            if 'billingperiod' not in params:
                wpp.doDirectPayment(params)
            # Create recurring payment:
            else:
                wpp.createRecurringPaymentsProfile(params, direct=True)
        except PayPalFailure:
            return False
        return True
1254932
public function processPayment()
    {
        $bankwireMethod = $this
            ->methodFactory
            ->create();

        /**
         * At this point, order must be created given a cart, and placed in PaymentBridge.
         *
         * So, $this->paymentBridge->getOrder() must return an object
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderLoad(
                $this->paymentBridge,
                $bankwireMethod
            );

        /**
         * Order Not found Exception must be thrown just here.
         */
        if (!$this->paymentBridge->getOrder()) {
            throw new PaymentOrderNotFoundException();
        }

        /**
         * Order exists right here.
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderCreated(
                $this->paymentBridge,
                $bankwireMethod
            );

        /**
         * Payment paid done.
         *
         * Paid process has ended ( No matters result )
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderDone(
                $this->paymentBridge,
                $bankwireMethod
            );

        return $this;
    }
1356039
public function run()
	{
		$context = $this->getContext();
		$config = $context->getConfig();
		$logger = $context->getLogger();

		/** controller/common/subscription/process/processors
		 * List of processor names that should be executed for subscriptions
		 *
		 * For each subscription a number of processors for different tasks can be executed.
		 * They can for example add a group to the customers' account during the customer
		 * has an active subscribtion.
		 *
		 * @param array List of processor names
		 * @since 2018.04
		 * @category Developer
		 * @see controller/common/subscription/process/payment-status
		 * @see controller/common/subscription/process/payment-days
		 */
		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );

		/** controller/common/subscription/process/payment-status
		 * Minimum payment status that will activate the subscription
		 *
		 * Subscriptions will be activated if the payment status of the order is
		 * at least the configured payment constant. The default payment status
		 * is "authorized" so orders with a payment status of "authorized" (5) and
		 * "received" (6) will cause the subscription to be activated. Lower
		 * payment status values, e.g. "pending" (4) won't activate the subscription.
		 *
		 * @param integer Payment status constant
		 * @since 2018.07
		 * @category Developer
		 * @category User
		 * @see controller/common/subscription/process/processors
		 * @see controller/common/subscription/process/payment-days
		 */
		$status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED;
		$status = $config->get( 'controller/common/subscription/process/payment-status', $status );

		/** controller/common/subscription/process/payment-days
		 * Number of days to wait for the payment until subscription is removed
		 *
		 * Subscriptions wait for the confiugrable number of days until the payment
		 * status changes to a valid payment (by default: "authorized" and "received").
		 * If the payment arrives within this time frame, the subscription is activated.
		 * Otherwise, the subscription is removed from the list of subscriptions that
		 * will be checked for activation.
		 *
		 * @param float Number of days
		 * @since 2018.07
		 * @category Developer
		 * @category User
		 * @see controller/common/subscription/process/processors
		 * @see controller/common/subscription/process/payment-status
		 */
		$days = (float) $config->get( 'controller/common/subscription/process/payment-days', 3 );


		$processors = $this->getProcessors( $names );
		$orderManager = \Aimeos\MShop::create( $context, 'order' );
		$manager = \Aimeos\MShop::create( $context, 'subscription' );

		$search = $manager->createSearch( true );
		$expr = [
			$search->compare( '==', 'subscription.datenext', null ),
			$search->getConditions(),
		];
		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );

		$date = date( 'Y-m-d H:i:s', time() - 86400 * $days );
		$start = 0;

		do
		{
			$ordBaseIds = $payStatus = [];

			$search->setSlice( $start, 100 );
			$items = $manager->searchItems( $search );

			foreach( $items as $item ) {
				$ordBaseIds[] = $item->getOrderBaseId();
			}

			$orderSearch = $orderManager->createSearch()->setSlice( 0, $search->getSliceSize() );
			$orderSearch->setConditions( $orderSearch->compare( '==', 'order.base.id', $ordBaseIds ) );
			$orderSearch->setSortations( [$orderSearch->sort( '+', 'order.id' )] );

			foreach( $orderManager->searchItems( $orderSearch ) as $orderItem ) {
				$payStatus[$orderItem->getBaseId()] = $orderItem->getPaymentStatus();
			}

			foreach( $items as $item )
			{
				try
				{
					if( isset( $payStatus[$item->getOrderBaseId()] ) && $payStatus[$item->getOrderBaseId()] >= $status )
					{
						foreach( $processors as $processor ) {
							$processor->begin( $item );
						}

						$interval = new \DateInterval( $item->getInterval() );
						$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
					}
					elseif( $item->getTimeCreated() < $date )
					{
						$item->setStatus( 0 );
					}

					$manager->saveItem( $item );
				}
				catch( \Exception $e )
				{
					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
					$logger->log( $e->getTraceAsString() );
				}
			}

			$count = count( $items );
			$start += $count;
		}
		while( $count === $search->getSliceSize() );
	}
1149310
def _processor(self):
        """"""
        self.store.cleanup(self._config.timeout)
        self._load()