Process the request here
@param Varien_Object $payment
@param unknown_type $amount
@param unknown_type $request
@param unknown_type $responseData
546944
protected function _processRequest(Varien_Object $payment, $amount, $request, $pspReference = null)
    {

        if (Mage::app()->getStore()->isAdmin()) {
            $storeId = $payment->getOrder()->getStoreId();
        } else {
            $storeId = null;
        }

        $this->_initService($storeId);
        $merchantAccount = Mage::helper('adyen')->getAdyenMerchantAccount($this->_paymentMethod, $storeId);
        $recurringType = $this->_getConfigData('recurringtypes', 'adyen_abstract', $storeId);
        $recurringPaymentType = $this->_getConfigData('recurring_payment_type', 'adyen_oneclick', $storeId);
        $enableMoto = (int)$this->_getConfigData('enable_moto', 'adyen_cc', $storeId);
        $modificationResult = Mage::getModel('adyen/adyen_data_modificationResult');
        $requestData = Mage::getModel('adyen/adyen_data_modificationRequest')
            ->create($payment, $amount, $merchantAccount, $pspReference);

        try {
            switch ($request) {
                case "authorise":
                    $requestData = Mage::getModel('adyen/adyen_data_paymentRequest')
                        ->create(
                            $payment, $amount, $this->_paymentMethod, $merchantAccount, $recurringType,
                            $recurringPaymentType, $enableMoto
                        );

                    $response = $this->_service->authorise(array('paymentRequest' => $requestData));
                    break;
                case "authorise3d":
                    $requestData = Mage::getModel('adyen/adyen_data_paymentRequest3d')
                        ->create($payment, $merchantAccount);

                    $response = $this->_service->authorise3d(array('paymentRequest3d' => $requestData));
                    break;
                case "capture":
                    $response = $this->_service->capture(
                        array(
                            'modificationRequest' => $requestData,
                            'modificationResult' => $modificationResult
                        )
                    );
                    break;
                case "refund":
                    $response = $this->_service->refund(
                        array(
                            'modificationRequest' => $requestData,
                            'modificationResult' => $modificationResult
                        )
                    );
                    break;
                case "cancel_or_refund":
                    $response = $this->_service->cancelorrefund(
                        array(
                            'modificationRequest' => $requestData,
                            'modificationResult' => $modificationResult
                        )
                    );
                    break;
                case "cancel":
                    $response = $this->_service->cancel(
                        array(
                            'modificationRequest' => $requestData,
                            'modificationResult' => $modificationResult
                        )
                    );
                    break;
            }
        } catch (SoapFault $e) {
            // log the request
            $this->_debugAdyen();
            Mage::log($this->_pci()->obscureSensitiveData($requestData), self::DEBUG_LEVEL, "$request.log", true);


            if (isset($response)) {
                Mage::getResourceModel('adyen/adyen_debug')->assignData($response);
                $this->_debugAdyen();
            }

            throw $e;
        }


        // log the request
        Mage::getResourceModel('adyen/adyen_debug')->assignData($response);
        $this->_debugAdyen();
        Mage::log($this->_pci()->obscureSensitiveData($requestData), self::DEBUG_LEVEL, "$request.log", true);


        if (!empty($response)) {
            // log the result
            Mage::log("Response from Adyen:", self::DEBUG_LEVEL, "$request.log", true);
            Mage::log($this->_pci()->obscureSensitiveData($response), self::DEBUG_LEVEL, "$request.log", true);

            $this->_processResponse($payment, $response, $request, $pspReference);
        }

        /*
         * clear the cache for recurring payments so new card will be added
         */
        $cacheKey = $merchantAccount . "|" . $payment->getOrder()->getCustomerId() . "|" . $recurringType;
        Mage::app()->getCache()->remove($cacheKey);

        //return $this;
        return $response;
    }
964766
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        //$model = ArrayObject::ensureArrayObject($request->getModel());

        $this->gateway->execute(new PaymentResponse($request->getModel()));
    }
1308837
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        $model = ArrayObject::ensureArrayObject($request->getModel());

        // invalidate:
        // - we process only replied and notified payments
        if (!isset($model['state']) ||
            !in_array(
                $model['state'],
                array(
                    StateInterface::STATE_REPLIED,
                    StateInterface::STATE_NOTIFIED,
                    StateInterface::STATE_CONFIRMED,
                )
            )
        ) {
            // return;
        }

        $httpRequest = new GetHttpRequest;
        $this->gateway->execute($httpRequest);

        if ($httpRequest->method != 'POST') {
            return;
        }

        $status = Api::STATUS_OK;
        $model['state'] = StateInterface::STATE_NOTIFIED;
        $notification = $httpRequest->request;
        $redirectUrl = $model['afterUrl'];
        // check signature hash
        
        if ($this->api->tamperingDetected((array) $notification, (array) $model->toUnsafeArray())) {
            $status = Api::STATUS_INVALID;
            $statusDetails = "Tampering detected. Wrong hash.";
        } else {
            if ($notification['Status'] == Api::STATUS_OK) {
                $model['state'] = StateInterface::STATE_CONFIRMED;
            } elseif ($notification['Status'] == Api::STATUS_PENDING) {
                $model['state'] = StateInterface::STATE_REPLIED;
            } else {
                $model['state'] = StateInterface::STATE_ERROR;
            }

            $statusDetails = 'Transaction processed';

            if ($notification['Status'] == Api::STATUS_ERROR
                && isset($notification['Vendor'])
                && isset($notification['VendorTxCode'])
                && isset($notification['StatusDetail'])
            ) {
                $status = Api::STATUS_ERROR;
                $statusDetails = 'Status of ERROR is seen, together with your Vendor, VendorTxCode and the StatusDetail.';
            }

        }

        $model['notification'] = (array) $notification;
        $model->replace(
            $model->toUnsafeArray()
        );

        $params = array(
            'Status' => $status,
            'StatusDetails' => $statusDetails,
            'RedirectURL' => $redirectUrl,
            );

        throw new NotifyResponse($params);
    }
628162
protected static function deletePaymentTransactionByIdAsyncWithHttpInfo($payment_transaction_id) 
    {
        $returnType = '';  
        $request = self::deletePaymentTransactionByIdRequest($payment_transaction_id); 

        return self::getHttpClient()
            ->sendAsync($request, self::createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }
191618
public function onCallbackSuccess($order, $data = null)
    {
        $paymentId  = is_array($data) ? $data['paymentId'] : $data->paymentId;

        $payerId    = is_array($data) ? $data['PayerID'] : $data->PayerID;

        $this->statusCode = 'failed';

        $this->detail = sprintf('Payment failed. Ref: %s', $paymentId);

        // Begin paypal
        try {

            $this->setContext();

            $payment = Payment::get($paymentId, $this->apiContext);
            
            $execution = new PaymentExecution();

            $execution->setPayerId($payerId);

            $payment->execute($execution, $this->apiContext);

            $payment = Payment::get($paymentId, $this->apiContext);

            $this->statusCode = 'completed';

            $this->transactionId = $payment->id;

            $this->detail = 'Success';

        } 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
            );

        }
    }
303591
public function create($data)
    {
        $res = $this->request(self::PAYMENTS_PATH)->setRequestBody($data)->post();

        if ($res->isError()) {
            throw new RequestError($res->errorMessage, null, $res);
        }

        return new Payment($res->json);
    }
1228240
public function onPaymentPrepare(PaymentEvent $event)
    {
        $payment = $event->getPayment();
        if (!$payment instanceof OrderPayment) {
            return;
        }

        if (null === $order = $payment->getOrder()) {
            throw new LogicException('You must assign the payment to the order first.');
        }

        if ($order->isEmpty()) {
            throw new LogicException('Empty order.');
        }

        if ($order->getLocked()) {
            $event->addMessage(new ResourceMessage('ekyna_order.event.locked', ResourceMessage::TYPE_ERROR));
            return;
        }
        $order->setLocked(true);

        if (0 >= $payment->getAmount()) {
            $payment->setAmount(
                $this->calculator->calculateOrderRemainingTotal($order)
            );
        }

        $this->updateOrder($order, $event, true);
    }
629221
protected function updatePaymentDetailAfterAuthorization(SpyPaymentPayone $paymentEntity, AuthorizationResponseContainer $responseContainer)
    {
        $paymentDetailEntity = $paymentEntity->getSpyPaymentPayoneDetail();

        $paymentDetailEntity->setClearingBankAccountHolder($responseContainer->getClearingBankaccountholder());
        $paymentDetailEntity->setClearingBankCountry($responseContainer->getClearingBankcountry());
        $paymentDetailEntity->setClearingBankAccount($responseContainer->getClearingBankaccount());
        $paymentDetailEntity->setClearingBankCode($responseContainer->getClearingBankcode());
        $paymentDetailEntity->setClearingBankIban($responseContainer->getClearingBankiban());
        $paymentDetailEntity->setClearingBankBic($responseContainer->getClearingBankbic());
        $paymentDetailEntity->setClearingBankCity($responseContainer->getClearingBankcity());
        $paymentDetailEntity->setClearingBankName($responseContainer->getClearingBankname());

        if ($responseContainer->getMandateIdentification()) {
            $paymentDetailEntity->setMandateIdentification($responseContainer->getMandateIdentification());
        }

        if ($paymentEntity->getPaymentMethod() == PayoneApiConstants::PAYMENT_METHOD_INVOICE) {
            $paymentDetailEntity->setInvoiceTitle($this->getInvoiceTitle($paymentEntity->getTransactionId()));
        }

        $paymentDetailEntity->save();
    }
159753
public function process(Request $request, Transaction $transaction, Delivery $delivery)
    {
        
        // in your controller
        $transactionService = $this->get('transaction');
        $data = $request->get('braintree');
        $nonce = $data['payment_method_nonce'];

        $result = $transactionService::sale([
            'amount' => $transaction->getTotalPrice(),
            'paymentMethodNonce' => $nonce
        ]);
        
        
        $em = $this->container->get('doctrine')->getManager();
        $pm = $em->getRepository('EcommerceBundle:PaymentMethod')->findOneBySlug('braintree');
        if ($result->success || !is_null($result->transaction)) {
                        
            //UPDATE TRANSACTION
            $transaction->setStatus(Transaction::STATUS_PAID);
            $transaction->setPaymentMethod($pm);
            
            //details
            $details = new stdClass();
            $details->id = $result->transaction->id;
            $details->status = $result->transaction->status;
            $details->type = $result->transaction->type;
            $details->currencyIsoCode = $result->transaction->currencyIsoCode;
            $details->amount = $result->transaction->amount;
            $details->merchantAccountId = $result->transaction->merchantAccountId;
            $details->createdAt = $result->transaction->createdAt;
            $details->updatedAt = $result->transaction->updatedAt;
            $details->customer = $result->transaction->customer;
            $details->billing = $result->transaction->billing;
            $details->shipping = $result->transaction->shipping;
            
            $transaction->setPaymentDetails(json_encode($details));
            $em->persist($transaction);
            $em->flush();

            //confirmation payment
            $answer = new stdClass();
            $answer->redirectUrl = $this->container->get('router')->generate('ecommerce_checkout_confirmationpayment');

            return $answer;
       }else{
            //UPDATE TRANSACTION
            $transaction->setStatus(Transaction::STATUS_CANCELLED);
            $transaction->setPaymentMethod($pm);
            
            //details
            $errorString = "";
            foreach($result->errors->deepAll() as $error) {
               $errorString .= 'Error: ' . $error->code . ": " . $error->message . "\n";
            }
            $this->container->get('session')->getFlashBag()->add('error', $errorString);
            
            $transaction->setPaymentDetails(json_encode($errorString));
            $em->persist($transaction);
            $em->flush();

            //cancel payment
            $answer = new stdClass();
            $answer->redirectUrl = $this->container->get('router')->generate('ecommerce_checkout_cancelationpayment');

            return $answer;
        }
 
    }
502947
public function payment(Payment $payment, &$paymentParams)
    {
        if (!$this->checkCurrency($payment->currency)) {
            Yii::$app->session->setFlash(Yii::t('payment', 'The gateway does not support the current currency!'));
        } else {
            $params = $this->buildPaymentParameter([
                'out_trade_no' => $payment->id,
                'subject' => !empty($payment->model_id) ? $payment->model_id . '付款' : '账号充值',
                'total_fee' => round($payment->money, 2),
            ]);
            //签名结果与签名方式加入请求提交参数组中
            $paraFilter = $this->paraFilter($params);
            $paraSort = $this->argSort($paraFilter);
            //把数组所有元素，按照“参数=参数值”的模式用“&”字符拼接成字符串
            $preStr = $this->createLinkString($paraSort);

            $params['sign'] = $this->createSign($preStr);
            $params['sign_type'] = strtoupper($this->signType);
            $this->getRedirectResponse($params);
        }
    }
594582
public function onPaymentDone(PaymentEvent $event)
    {
        $payment = $event->getPayment();
        if (!$payment instanceof OrderPayment) {
            return;
        }

        $order = $payment->getOrder();
        if ($order->getLocked()) {
            $order->setLocked(false);
            $this->updateOrder($order, $event);
        }

        $returnPath = null;
        $details = $payment->getDetails();
        if (array_key_exists('done_redirect_path', $details)) {
            $returnPath = $details['done_redirect_path'];
        } else {
            $type = $order->getType();
            if ($type === OrderTypes::TYPE_CART) {
                $returnPath = $this->urlGenerator->generate('ekyna_cart_payment');
            } elseif ($type === OrderTypes::TYPE_QUOTE) {
                throw new \BadMethodCallException('Not yet implemented');
            } elseif ($type === OrderTypes::TYPE_ORDER) {
                if ($this->authorization->isGranted('ROLE_ADMIN')) {
                    $returnPath = $this->urlGenerator->generate(
                        'ekyna_order_order_admin_show',
                        array('orderId' => $order->getId())
                    );
                } else {
                    $returnPath = $this->urlGenerator->generate(
                        'ekyna_cart_confirmation',
                        array(
                            'orderKey' => $order->getKey(),
                            'paymentId' => $payment->getId(),
                        )
                    );
                }
            }
        }

        if (null === $returnPath) {
            throw new LogicException('Unable to determine return path.');
        }

        $event->setResponse(new RedirectResponse($returnPath));
    }
908383
public function process()
    {
        $lang = $this->getLang();
        $request = $this->getRequest();
        $paymentBuilder = $this->getPaymentBuilder();
        $payPalOrderManager = $this->getOrderManager();

        // Create Payment from Request.
        $paymentBuilder->setLang($lang);
        $paymentBuilder->setRequest($request);
        $orderPayment = $paymentBuilder->buildPayment();

        $payPalOrderManager->setOrderPayment($orderPayment);
        $processSuccess = $payPalOrderManager->updateOrderStatus();

        return $processSuccess;
    }
1217536
public function sendData($data)
    {
        $httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data)->send();

        return $this->response = new PaymentResponse($this, $httpResponse);
    }
1249756
public function pay($amount, $parameters) {
        $payment = new InvoicePayment();
        $payment->amount = $amount;

        $payment->setPreCommitMetadataArray($parameters['metadata']);

        $payment->invoice()->associate($this);
        $payment->type()->associate($parameters['type']);

        if(isset($parameters['id'])) {
            $payment->payment_id = $parameters['id'];
        }

        $payment->save();
        return $payment;
    }
422186
def payment_request(options, &block)
      set_options(options, &block)
      post('payment-requests', options)
      @response.success? ? Instamojo::PaymentRequest.new(@response.body[:payment_request], self) : @response
    end
885030
public function handle(ServerRequestInterface $request, Factory $payments, ExceptionHandler $handler)
    {
        try {
            return $payments->driver((string)Request::route('shop'))->callback($request);
        } catch (Exception $exception) {
            $handler->report($exception);
            return new Response($exception->getMessage(), 500);
        }
    }
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';

	}