Receive and analyze request from payment service with information on payment status change.
555551
def online(cls, payload, ip, req_sig):
        

        from getpaid.models import Payment

        params = json.loads(payload)
        order_data = params.get('order', {})
        pos_id = order_data.get('merchantPosId')
        payment_id = order_data.get('extOrderId')

        key2 = cls.get_backend_setting('key2')

        if pos_id != cls.get_backend_setting('pos_id'):
            logger.warning('Received message for different pos: {}'.format(pos_id))
            return 'ERROR'

        req_sig_dict = cls.parse_payu_sig(req_sig)
        sig = cls.compute_sig(payload, key2, algorithm=req_sig_dict.get('algorithm', 'md5'))

        if sig != req_sig_dict['signature']:
            logger.warning('Received message with malformed signature. Payload: {}'.format(payload))
            return 'ERROR'

        try:
            payment = Payment.objects.get(id=payment_id)
        except Payment.DoesNotExist:
            logger.warning('Received message for nonexistent payment: {}.\nPayload: {}'.format(payment_id, payload))
            return 'ERROR'
        status = order_data['status']
        if payment.status != 'paid':
            if status == 'COMPLETED':
                payment.external_id = order_data['orderId']
                payment.amount = Decimal(order_data['totalAmount']) / Decimal(100)
                payment.amount_paid = payment.amount
                payment.currenct = order_data['currencyCode']
                payment.paid_on = pendulum.parse(params['localReceiptDateTime']).in_tz('utc')
                payment.description = order_data['description']
                payment.change_status('paid')

            elif status == 'PENDING':
                payment.change_status('in_progress')
            elif status in ['CANCELED', 'REJECTED']:
                payment.change_status('cancelled')
        return 'OK'
871662
def update_req(req):
    """"""

    if not req.name:
        return req, None

    info = get_package_info(req.name)

    if info['info'].get('_pypi_hidden'):
        print('{} is hidden on PyPI and will not be updated.'.format(req))
        return req, None

    if _is_pinned(req) and _is_version_range(req):
        print('{} is pinned to a range and will not be updated.'.format(req))
        return req, None

    newest_version = _get_newest_version(info)
    current_spec = next(iter(req.specifier)) if req.specifier else None
    current_version = current_spec.version if current_spec else None
    new_spec = Specifier(u'=={}'.format(newest_version))
    if not current_spec or current_spec._spec != new_spec._spec:
        req.specifier = new_spec
        update_info = (
            req.name,
            current_version,
            newest_version)
        return req, update_info
    return req, None
803851
def process_response(self, request, response):
        """"""
        if tldap.transaction.is_managed():
            tldap.transaction.commit()
            tldap.transaction.leave_transaction_management()
        return response
1003119
def get_payment(payment_id, options = {})
      request_params = {}
      response_xml = http_get(client, "#{@xero_url}/Payments/#{payment_id}", request_params)
      parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/payments'})
    end
413119
def statusEnquiry():
    """"""
    a = TpPd(pd=0x3)
    b = MessageType(mesType=0x34)  # 00110100
    packet = a / b
    return packet
244712
def request_payment(options = {})
      response = JSON.parse(@client.patch("items/#{send(:id)}/request_payment", options).body)
      @attributes = response['items']
      true
    end
756501
def update_status(self, card_id, code, reimburse_status):
        
        return self._post(
            'platform/updatestatus',
            data={
                'card_id': card_id,
                'code': code,
                'reimburse_status': reimburse_status,
            },
        )
608969
def receive_request_reverse(self, transaction):
        
        path = str("/" + transaction.request.uri_path)
        transaction.response = Response()
        transaction.response.destination = transaction.request.source
        transaction.response.token = transaction.request.token
        if path == defines.DISCOVERY_URL:
            transaction = self._server.resourceLayer.discover(transaction)
        else:
            new = False
            if transaction.request.code == defines.Codes.POST.number:
                new_paths = self._server.root.with_prefix(path)
                new_path = "/"
                for tmp in new_paths:
                    if len(tmp) > len(new_path):
                        new_path = tmp
                if path != new_path:
                    new = True
                path = new_path
            try:
                resource = self._server.root[path]
            except KeyError:
                resource = None
            if resource is None or path == '/':
                # Not Found
                transaction.response.code = defines.Codes.NOT_FOUND.number
            else:
                transaction.resource = resource
                transaction = self._handle_request(transaction, new)
        return transaction
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);
    }
515101
def complete_request(self, account_id, request_id, **params):
        """"""
        response = self._post(
            'v2', 'accounts', account_id, 'transactions', request_id,
            'complete', data=params)
        return self._make_api_object(response, APIObject)
808542
public function postChangeCard(BillingRequest $request)
    {
        try {
            $payload = $request->all();
            $creditCardToken = $payload['stripeToken'];
            auth()->user()->meta->updateCard($creditCardToken);
            return redirect('user/billing/details')->with('message', 'Your subscription has been updated!');
        } catch (Exception $e) {
            Log::error($e->getMessage());
            return back()->withErrors(['Could not process the billing please try again.']);
        }

        return back()->withErrors(['Could not complete billing, please try again.']);
    }
809303
def process(self, request, item):
        """"""
        warn_untested()
        from paypal.pro.helpers import PayPalWPP

        wpp = PayPalWPP(request)

        # Change the model information into a dict that PayPal can understand.
        params = model_to_dict(self, exclude=self.ADMIN_FIELDS)
        params['acct'] = self.acct
        params['creditcardtype'] = self.creditcardtype
        params['expdate'] = self.expdate
        params['cvv2'] = self.cvv2
        params.update(item)

        # Create recurring payment:
        if 'billingperiod' in params:
            return wpp.createRecurringPaymentsProfile(params, direct=True)
        # Create single payment:
        else:
            return wpp.doDirectPayment(params)
1322274
def get_payments(options = {})
      request_params = {}
      request_params[:PaymentID]     = options[:payment_id] if options[:payment_id]
      request_params[:ModifiedAfter] = options[:modified_since] if options[:modified_since]
      request_params[:order]         = options[:order] if options[:order]
      request_params[:where]         = options[:where] if options[:where]

      response_xml = http_get(@client, "#{@xero_url}/Payments", request_params)
      parse_response(response_xml, {:request_params => request_params}, {:request_signature => 'GET/payments'})
    end
1228396
public function getPaymentStatus()
    {
        if (isset($this->data->ewallet->status)) {
            return (string)$this->data->ewallet->status;
        }
    }
230499
def get_customer_request_status(self, issue_id_or_key):
        
        request = self.get('rest/servicedeskapi/request/{}/status'.format(issue_id_or_key)).get('values')
        status = request[0].get('status')

        return status
1352987
public Result processPayment(Payment payment) throws PaytrailException {
		try {
			String data = marshaller.objectToString(payment);
			String url = serviceUrl + "/api-payment/create";
			
			IOHandlerResult requestResult = postJsonRequest(url, data);
			
			if (requestResult.getCode() != 201) {
				JsonError jsonError = marshaller.stringToObject(JsonError.class, requestResult.getResponse());
				throw new PaytrailException(jsonError.getErrorMessage());
	  	}
			
			return marshaller.stringToObject(Result.class, requestResult.getResponse());
		} catch (IOException e) {
			throw new PaytrailException(e);
		}
	}
710493
def receive_request(self, transaction):
        

        transaction.cached_element = self.cache.search_response(transaction.request)
        if transaction.cached_element is None:
            transaction.cacheHit = False
        else:
            transaction.response = transaction.cached_element.cached_response
            transaction.response.mid = transaction.request.mid
            transaction.cacheHit = True

            age = transaction.cached_element.creation_time + transaction.cached_element.max_age - time.time()
            if transaction.cached_element.freshness is True:
                if age <= 0:
                    logger.debug("resource not fresh")
                    """
                    if the resource is not fresh, its Etag must be added to the request so that the server might validate it instead of sending a new one
                    """
                    transaction.cached_element.freshness = False
                    """
                    ensuring that the request goes to the server
                    """
                    transaction.cacheHit = False
                    logger.debug("requesting etag %s", transaction.response.etag)
                    transaction.request.etag = transaction.response.etag
                else:
                    transaction.response.max_age = age
            else:
                transaction.cacheHit = False
        return transaction