executes payment for order - in this case, we commit the paypal payment.

@param TdbShopOrder $oOrder
@param string       $sMessageConsumer - send error messages here

@return bool
508167
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder);

        $oCurrency = null;
        if (method_exists($oOrder, 'GetFieldPkgShopCurrency')) {
            $oCurrency = $oOrder->GetFieldPkgShopCurrency();
        }
        $sCurrency = $this->GetCurrencyIdentifier($oCurrency);
        $request = $this->getCurrentRequest();
        $aCommand = array(
            'TOKEN' => $this->sPayPalToken,
            'PAYERID' => $this->aCheckoutDetails['PAYERID'],
            'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
            'PAYMENTREQUEST_0_AMT' => round($oOrder->fieldValueTotal, 2),
            'PAYMENTREQUEST_0_CURRENCYCODE' => $sCurrency,
            'IPADDRESS' => null === $request ? '' : $request->getClientIp(),
            'PAYMENTREQUEST_0_INVNUM' => $this->GetOrderNumber($oOrder),
            'PAYMENTREQUEST_0_CUSTOM' => $this->id.','.$oOrder->id,
        );
        $sIPNURL = $this->GetInstantPaymentNotificationListenerURL($oOrder);
        if (!empty($sIPNURL)) {
            $aCommand['PAYMENTREQUEST_0_NOTIFYURL'] = $sIPNURL;
        }

        $aAnswer = $this->ExecutePayPalCall('DoExpressCheckoutPayment', $aCommand);
        $ack = strtoupper($aAnswer['ACK']);
        if ('SUCCESS' == $ack) {
            $bPaymentOk = true;
            // add the response data to the order
            foreach ($aAnswer as $sKey => $sVal) {
                if (!array_key_exists($sKey, $this->aPaymentUserData)) {
                    $this->aPaymentUserData[$sKey] = $sVal;
                }
            }
            //        $this->SaveUserPaymentDataToOrder($oOrder->id);

            if (array_key_exists('PAYMENTINFO_0_PAYMENTSTATUS', $aAnswer) && 'COMPLETED' == strtoupper($aAnswer['PAYMENTINFO_0_PAYMENTSTATUS'])) {
                $oOrder->SetStatusPaid();
            }
        } else {
            $bPaymentOk = false;
        }

        if (!$bPaymentOk) {
            // error!
            $oMsgManager = TCMSMessageManager::GetInstance();
            $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-PAYMENT-ERROR', array('errorMsg' => self::GetPayPalErrorMessage($aAnswer)));
            $logContext = array(
                'Command' => $aCommand,
                'PayPalAnswer' => $aAnswer,
            );
            $this->getPaypalLogger()->critical('PayPal payment could not be executed for order id '.$oOrder->id, $logContext);
        }

        return $bPaymentOk;
    }
760387
public function onCharge($order)
    {
        $this->statusCode = 'pending';

        // Begin paypal
        try {

            if ($order->total <= 0) {
            
                $this->statusCode = 'completed';

                $this->detail = 'Order total is 0; no PayPal transaction required.';

                $this->transactionId = uniqid();

                return true;
            }

            $this->setContext();

            $payer = new Payer();
        
            $payer->setPaymentMethod('paypal');

            $list = new ItemList();
            
            $list->setItems($this->toPayPalItems($order));
            
            $details = new Details();
            
            $details->setShipping($order->totalShipping)
                ->setTax($order->totalTax)
                ->setSubtotal($order->totalPrice);

            $amount = new Amount();

            $amount->setCurrency(Config::get('shop.currency'))
                ->setTotal($order->total)
                ->setDetails($details);

            $transaction = new Transaction();

            $transaction->setAmount($amount)
                ->setItemList($list)
                ->setDescription(sprintf(
                    '%s payment, Order #%d',
                    Config::get('shop.name'),
                    $order->id
                ))
                ->setInvoiceNumber($order->id);

            $redirectUrls = new RedirectUrls();
            
            $redirectUrls->setReturnUrl($this->callbackSuccess)
                ->setCancelUrl($this->callbackFail);

            $payment = new Payment();

            $payment->setIntent('sale')
                ->setPayer($payer)
                ->setRedirectUrls($redirectUrls)
                ->setTransactions([$transaction]);

            //$request = clone $payment;

            $payment->create($this->apiContext);

            $this->approvalUrl = $payment->getApprovalLink();

            $this->detail = sprintf('Pending approval: %s', $this->approvalUrl);

            return true;

        } catch (PayPalConnectionException $e) {

            $response = json_decode($e->getData());

            throw new GatewayException(
                sprintf(
                    '%s: %s',
                    $response->name,
                    isset($response->message) ? $response->message : 'Paypal payment Failed.'
                ),
                1001,
                $e
            );

        } catch (\Exception $e) {

            throw new GatewayException(
                $e->getMessage(),
                1000,
                $e
            );

        }

        return false;
    }
453358
function execute(Observer $ob) {
		/** @var OP $op */
		if (dfp_my($op = $ob['payment'])) {
			$op->getOrder()->setState(O::STATE_CLOSED)->setStatus(df_order_ds(O::STATE_CLOSED));
		}
	}
968431
public function onCharge($order)
    {
        if (!isset($this->omnipay))
            throw new ShopException('Omnipay gateway not set.', 0);

        try {

            $response = $this->omnipay->purchase(array_merge([
                'amount'    => $order->total,
                'currency'  => Config::get('shop.currency'),
                'card'      => $this->isCreditCard ? $this->creditCard : [],
                'returnUrl' => $this->callbackSuccess,
                'cancelUrl' => $this->callbackFail,
            ], $this->options))->send();

            if ($response->isSuccessful()) {

                $this->transactionId = $response->getTransactionReference();

                $this->detail = 'Success';


            } elseif ($response->isRedirect()) {

                $this->statusCode = 'pending';

                $this->approvalUrl = $response->getRedirectUrl();

                $this->detail = sprintf('Pending approval: %s', $response->getRedirectUrl());

            } else {

                throw new GatewayException($response->getMessage(), 1);

            }

            return true;

        } catch (Exception $e) {

            throw new ShopException(
                $e->getMessage(),
                1000,
                $e
            );

        }

        return false;
    }
861282
protected function handleTransactionHook(IPkgShopPaymentIPNHandler $oHandler, TPkgShopPaymentIPNRequest $oRequest)
    {
        $oOrder = $oRequest->getOrder();
        if (null === $oOrder) {
            return;
        }

        $oTransactionDetails = $oHandler->getIPNTransactionDetails($oRequest);
        if (null === $oTransactionDetails) {
            return;
        }

        $oTransactionManager = new TPkgShopPaymentTransactionManager($oOrder);

        $sStatus = '';
        $oStatus = $oRequest->getIpnStatus();
        if (null !== $oStatus) {
            $sStatus = $oStatus->fieldCode;
        }

        $oTransaction = null;
        // try to update the corresponding transaction first
        if (null !== $oTransactionDetails->getSequenceNumber()) {
            $oTransaction = $oTransactionManager->confirmTransaction(
                $oTransactionDetails->getSequenceNumber(),
                $oTransactionDetails->getTransactionTimestamp()
            );
        }

        if (null === $oTransaction) {
            \ChameleonSystem\CoreBundle\ServiceLocator::get('monolog.logger.order_payment_ipn')->warning(
                "IPN had transaction data but no matching transaction was found. order-id: {$oOrder->id}, ordernumber: {$oOrder->fieldOrdernumber}",
                array('request' => $oRequest->getRequestPayload())
            );
        }
    }
1356879
public function AllowSendingMailForOrder($oUser, $aOrder)
    {
        $bAllowSendingMail = true;

        // make sure the order is a DE order
        if ($aOrder['cms_language_id'] != $this->sLanguageID) {
            $bAllowSendingMail = false;
        }

        if ($this->SendCustomersMailOnlyOnce()) {
            $query = "SELECT * FROM `pkg_shop_rating_service_history`
                   WHERE `data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oUser->id)."'
                 ";

            if ($this->bDebug) {
                echo __LINE__.': '.$query."\n<br />\n";
            }

            $tRes = MySqlLegacySupport::getInstance()->query($query);
            if (MySqlLegacySupport::getInstance()->num_rows($tRes) > 0) {
                $bAllowSendingMail = false;
            }
        }

        if ($this->bDebug) {
            if ($bAllowSendingMail) {
                echo __LINE__.': bAllowSendingMail = true'."\n<br />\n";
            } else {
                echo __LINE__.': bAllowSendingMail = false'."\n<br />\n";
            }
        }

        return $bAllowSendingMail;
    }
108115
protected function _OxpsPaymorrowOxOrder_finalizeOrder_parent( oxBasket $oBasket, $oUser,
                                                                   $blRecalculatingOrder = false )
    {
        return parent::finalizeOrder( $oBasket, $oUser, $blRecalculatingOrder );
    }
440050
protected function SendFailureSettlementMail(TdbShopOrder &$oOrder)
    {
        $bSendMail = false;
        $oMail = TdbDataMailProfile::GetProfile('payment_datatrans_error_settlement');
        if (!is_null($oMail)) {
            $sInfo = TGlobal::OutHTML(TGlobal::Translate('chameleon_system_shop.payment_data_trans.settlement_failure_mail_info',
                    array(
                        '%ordernumber%' => $oOrder->fieldOrdernumber,
                        '%ref%' => $this->GetRefNoParameter(false),
                    )
                ));
            $oMail->AddData('sInfo', $sInfo);
            $bSendMail = $oMail->SendUsingObjectView('emails', 'Customer');
        }

        return $bSendMail;
    }
843133
protected function getArticleList(TdbShopOrder $oOrder, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aArticleList = array();
        $oOrderItemList = &$oOrder->GetFieldShopOrderItemList();
        while ($oOrderItem = &$oOrderItemList->Next()) {
            if ($bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oOrderItem->table, $oOrderItem->id);
            }
            $aArticleList[] = $this->getArticle($oOrderItem, $oCacheTriggerManager, $bCachingEnabled);
        }

        return $aArticleList;
    }
1291877
protected function GetNextAvailableVoucher($sVoucherCode, $sSeriesId, $sMessageConsumer)
    {
        $oNextAvailableVoucher = null;
        $oVoucher = TdbShopVoucher::GetNewInstance();
        if ($oVoucher->LoadFromFields(array('code' => $sVoucherCode, 'is_used_up' => '0', 'shop_voucher_series_id' => $sSeriesId))) {
            $oNextAvailableVoucher = $oVoucher;
        }

        return $oNextAvailableVoucher;
    }
918898
protected function getAddress(TdbShopOrder $oOrder, $iAddressType, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aAddress = array();

        if (self::ADDRESS_TYPE_BILLING === $iAddressType) {
            $oSalutation = $oOrder->GetFieldAdrBillingSalutation();
            if ($oSalutation && $bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oSalutation->table, $oSalutation->id);
            }
            $aAddress['sSalutation'] = (null !== $oSalutation) ? ($oSalutation->GetName()) : ('');

            $aAddress['sFirstName'] = $oOrder->fieldAdrBillingFirstname;
            $aAddress['sLastName'] = $oOrder->fieldAdrBillingLastname;
            $aAddress['sAdditionalInfo'] = $oOrder->fieldAdrBillingAdditionalInfo;
            $aAddress['sAddressStreet'] = $oOrder->fieldAdrBillingStreet;
            $aAddress['sAddressStreetNr'] = $oOrder->fieldAdrBillingStreetnr;
            $aAddress['sAddressZip'] = $oOrder->fieldAdrBillingPostalcode;
            $aAddress['sAddressCity'] = $oOrder->fieldAdrBillingCity;
            $aAddress['sAddressTelephone'] = $oOrder->fieldAdrBillingTelefon;
            $aAddress['sAddressFax'] = $oOrder->fieldAdrBillingFax;

            $oCountry = $oOrder->GetFieldAdrBillingCountry();
            if (null !== $oCountry) {
                if ($bCachingEnabled) {
                    $oCacheTriggerManager->addTrigger($oCountry->table, $oCountry->id);
                }
                $aAddress['sAddressCountry'] = (null !== $oCountry) ? ($oCountry->GetName()) : ('');
            }
        } elseif (self::ADDRESS_TYPE_SHIPPING === $iAddressType) {
            $oSalutation = $oOrder->GetFieldAdrShippingSalutation();
            if ($oSalutation && $bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oSalutation->table, $oSalutation->id);
            }
            $aAddress['sSalutation'] = (null !== $oSalutation) ? ($oSalutation->GetName()) : ('');

            $aAddress['sFirstName'] = $oOrder->fieldAdrShippingFirstname;
            $aAddress['sLastName'] = $oOrder->fieldAdrShippingLastname;
            $aAddress['sAdditionalInfo'] = $oOrder->fieldAdrShippingAdditionalInfo;
            $aAddress['sAddressStreet'] = $oOrder->fieldAdrShippingStreet;
            $aAddress['sAddressStreetNr'] = $oOrder->fieldAdrShippingStreetnr;
            $aAddress['sAddressZip'] = $oOrder->fieldAdrShippingPostalcode;
            $aAddress['sAddressCity'] = $oOrder->fieldAdrShippingCity;
            $aAddress['sAddressTelephone'] = $oOrder->fieldAdrShippingTelefon;
            $aAddress['sAddressFax'] = $oOrder->fieldAdrShippingFax;

            $oCountry = $oOrder->GetFieldAdrShippingCountry();
            if (null !== $oCountry) {
                if ($bCachingEnabled) {
                    $oCacheTriggerManager->addTrigger($oCountry->table, $oCountry->id);
                }
                $aAddress['sAddressCountry'] = (null !== $oCountry) ? ($oCountry->GetName()) : ('');
            }
        }

        return $aAddress;
    }
160258
protected function GetPaymentPayload($oOrder, $dPaymentAmount = null)
    {
        $aPayload = parent::GetPaymentPayload($oOrder, $dPaymentAmount);
        $aPayload['AccNr'] = str_replace(' ', '', $this->aPaymentUserData['accountNr']);
        $aPayload['AccIBAN'] = str_replace(' ', '', $this->aPaymentUserData['bankNr']);
        $aPayload['AccBank'] = $this->aPaymentUserData['bankName'];
        $aPayload['AccOwner'] = $this->aPaymentUserData['accountOwner'];

        return $aPayload;
    }
907856
protected function _savePaymorrowUserPaymentData( oxOrder $oOrder, $oPmResponseHandler )
    {
        $aPmResponse = $oPmResponseHandler->getResponse();

        $oUserPaymentId = $oOrder->oxorder__oxpaymentid->value;

        /** @var OxpsPaymorrowOxUserPayment|oxUserPayment $oUserPayment */
        $oUserPayment = oxNew( 'oxuserpayment' );
        $oUserPayment->load( $oUserPaymentId );

        $sPmBankName = $aPmResponse[self::PAYMORROW_RESPONSE_BANK_NAME];
        $sPmIbanCode = $aPmResponse[self::PAYMORROW_RESPONSE_SDD_IBAN];
        $sPmBicCode  = $aPmResponse[self::PAYMORROW_RESPONSE_SDD_BIC];
        $sPmOrderId  = $aPmResponse[self::PAYMORROW_RESPONSE_ORDER_ID];

        $oUserPayment->setPaymorrowBankName( $sPmBankName );
        $oUserPayment->setPaymorrowIBAN( $sPmIbanCode );
        $oUserPayment->setPaymorrowBIC( $sPmBicCode );
        $oUserPayment->setPaymorrowOrderId( $sPmOrderId );

        return $oUserPayment->save();
    }
1196050
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $creditmemo = $observer->getEvent()->getCreditmemo();
        $storeId = $creditmemo->getStoreId();
        $order = $creditmemo->getOrder();
        $orderId = $order->getEntityId();
        $quoteId = $order->getQuoteId();

        try {
            /*
             * Reimport transactional data.
             */
            $emailOrder = $this->emailOrderFactory->create()
                ->loadByOrderId($orderId, $quoteId, $storeId);
            if (!$emailOrder->getId()) {
                $this->helper->log(
                    'ERROR Creditmemmo Order not found :'
                    . $orderId . ', quote id : ' . $quoteId . ', store id '
                    . $storeId
                );

                return $this;
            }

            $emailOrder->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED);
            $this->orderResource->save($emailOrder);
        } catch (\Exception $e) {
            $this->helper->debug((string)$e, []);
        }

        return $this;
    }
667981
protected function SaveOrderIdAsLastCreatedOrderInSession($oOrder)
    {
        $_SESSION[self::SESSION_KEY_LAST_CREATED_ORDER_ID] = $oOrder->id;
        $myOrderHistory = $this->myOrderDetailHandlerFactory();
        $myOrderHistory->addOrderIdToMyList($oOrder->id, ('' !== $oOrder->fieldDataExtranetUserId) ? $oOrder->fieldDataExtranetUserId : null);
    }
500360
public function sendShopownerConfirmation(
        $recipient,
        ApiOrderInterface $apiOrder,
        ContactInterface $customerContact = null
    ) {
        if (!$this->sendEmailConfirmationToShopowner) {
            return false;
        }

        if (empty($recipient)) {
            // fallback address for shop-owner order confirmations
            $recipient = $this->confirmationRecipientEmailAddress;
        }

        return $this->sendConfirmationEmail(
            $recipient,
            $apiOrder,
            $this->templateShopownerConfirmationPath,
            $customerContact
        );
    }
609671
public function sendCustomerConfirmation(
        $recipient,
        ApiOrderInterface $apiOrder,
        ContactInterface $customerContact = null
    ) {
        if (!$this->sendEmailConfirmationToCustomer) {
            return false;
        }

        return $this->sendConfirmationEmail(
            $recipient,
            $apiOrder,
            $this->templateCustomerConfirmationPath,
            $customerContact
        );
    }