pay/pay.go
func (s *Server) handlePay(
	w http.ResponseWriter, r *http.Request, ctx *srv.Context) {
	logger := s.logger.Add("method", "handlePay", "sender", r.RemoteAddr)

	payload := &paymentPayload{}
	if !s.ParseRequest(logger, w, r, payload) {
		return
	}
	logger = logger.Add("payload", *payload)

	ch, ok := s.findChannel(logger, w,
		payload.OfferingHash,
		payload.AgentAddress, payload.OpenBlockNumber)

	logger = logger.Add("channel", ch)

	if ok && s.isServiceTerminated(logger, w, ch) {
		return
	}

	if !ok || !s.validateChannelForPayment(logger, w, ch, payload) ||
		!s.updateChannelWithPayment(logger, w, ch, payload) {
		return
	}

	s.RespondResult(logger, w, struct{}{})

	logger.Info(fmt.Sprintf("received payment: %d, from: %s", payload.Balance, ch.Client))
}
func (s *Server) handlePay(
	w http.ResponseWriter, r *http.Request, ctx *srv.Context) {
	logger := s.logger.Add("method", "handlePay", "sender", r.RemoteAddr)

	payload := &paymentPayload{}
	if !s.ParseRequest(logger, w, r, payload) {
		return
	}
	logger = logger.Add("payload", *payload)

	ch, ok := s.findChannel(logger, w,
		payload.OfferingHash,
		payload.AgentAddress, payload.OpenBlockNumber)

	logger = logger.Add("channel", ch)

	if ok && s.isServiceTerminated(logger, w, ch) {
		return
	}

	if !ok || !s.validateChannelForPayment(logger, w, ch, payload) ||
		!s.updateChannelWithPayment(logger, w, ch, payload) {
		return
	}

	s.RespondResult(logger, w, struct{}{})

	logger.Info(fmt.Sprintf("received payment: %d, from: %s", payload.Balance, ch.Client))
}
func ( s * Server ) handlePay ( w http . ResponseWriter , r * http . Request , ctx * srv . Context ) { logger := s . logger . Add ( " " , " " , " " , r . RemoteAddr ) payload := & paymentPayload { } if ! s . ParseRequest ( logger , w , r , payload ) { return } logger = logger . Add ( " " , * payload ) ch , ok := s . findChannel ( logger , w , payload . OfferingHash , payload . AgentAddress , payload . OpenBlockNumber ) logger = logger . Add ( " " , ch ) if ok && s . isServiceTerminated ( logger , w , ch ) { return } if ! ok || ! s . validateChannelForPayment ( logger , w , ch , payload ) || ! s . updateChannelWithPayment ( logger , w , ch , payload ) { return } s . RespondResult ( logger , w , struct { } { } ) logger . Info ( fmt . Sprintf ( " " , payload . Balance , ch . Client ) ) }
// handlePay handles clients balance proof informations.
handlePay handles clients balance proof informations .