@param Boolean $success
@param string  $message
@param array   $response
@param array   $options

@return Merchant_Billing_Response
547415
protected function build_response($success, $message, $response, $options = array())
  {
      return new Merchant_Billing_Response($success, $message, $response, $options);
  }
983576
protected function success_or_failure( $response ) {
		list( $type, $msg ) = $response;

		if ( 'success' === $type ) {
			WP_CLI::success( $msg );
			$status = 0;
		} else {
			WP_CLI::warning( $msg );
			$status = 1;
		}

		return $status;
	}
998829
public function message($message, $options = null) {
		$options = $this->_mergeOptions($options);

		$this->set($message, $options);

		$this->_assertSessionStackSize($options);
	}
1158597
public function mapResponse($success, $response)
    {
        return (new Response())->setRaw($response)->map([
            'isRedirect'    => false,
            'success'       => $success,
            'reference'     => $success ? $response['id'] : null,
            'message'       => $success ? 'Transaction approved' : Arr::get($response, 'message'),
            'test'          => $this->getTest($response),
            'authorization' => $success ? $this->getAuthorization($response) : false,
            'status'        => $success ? $this->getStatus($response) : new Status('failed'),
            'errorCode'     => $success ? null : $this->getErrorCode(Arr::get($response, 'code')),
            'type'          => array_key_exists('type', $response) ? Arr::get($response, 'type') : Arr::get($response, 'object'),
        ]);
    }
1151797
protected function respond($success, $request, $response, $options)
    {
        $success = isset($response['ACK']) && in_array($response['ACK'], ['Success', 'SuccessWithWarning']);

        if (array_key_exists('INVALID', $response) || array_key_exists('VERIFIED', $response)) {
            $response = array_merge($response, $request);
        }

        $response['isRedirect'] = Arr::get($options, 'isRedirect', false);

        return $this->mapResponse($success, $response);
    }
888217
protected function isSuccess($response, $code)
    {
        if (in_array(Arr::get($response, 'status'), $this->successPaymentStatuses)) {
            return true;
        }

        // Account::info() case
        if (isset($response['site_id'])) {
            return true;
        }

        $success = false;

        // Checking refund, docs say 200 but 201 is currently returned
        // https://www.mercadopago.com.mx/developers/en/solutions/payments/basic-checkout/refund-cancel/
        if ($code === 200 || $code === 201) {
            $success = isset($response['id'])
                && isset($response['payment_id'])
                && isset($response['amount'])
                && isset($response['metadata'])
                && isset($response['source']);
        }

        return $success;
    }
531175
public function commit($method, $url, $params = [], $options = [])
    {
        $success = false;
        $response = [];

        if ($params['transaction'] == 'success') {
            $success = true;
        }

        return $this->mapResponse($success, $response);
    }
1134075
public function publish(array $message, array $options = [])
    {
        $options      = $this->mergeOptions($options);
        $publishStart = microtime(true);

        if (!$this->queueExists()) {
            $this->create();
        }

        $result = $this->ironmq->postMessage(
            $this->getNameWithPrefix(),
            json_encode($message + ['_qpush_queue' => $this->name]),
            [
                'timeout'       => $options['message_timeout'],
                'delay'         => $options['message_delay'],
                'expires_in'    => $options['message_expiration']
            ]
        );

        $context = [
            'message_id'    => $result->id,
            'publish_time'  => microtime(true) - $publishStart
        ];
        $this->log(200, "Message has been published.", $context);

        return (int) $result->id;
    }
798610
public function success($message = null, $data = array(), $return = false)
    {
        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->add($key, $value);
            }
        }
        $json = $this->jsonEncode(
            array(
                'success' => true,
                'message' => $message,
                'data' => $this->_data,
            )
        );
        if (!$return) {
            echo $json;
            Yii::app()->end();
        } else {
            return $json;
        }
    }
159773
protected function respond($response, $request, $options, $statusCode)
    {
        if (array_key_exists('webhooks', $response)) {
            $results = [];
            foreach ($response['webhooks'] as $result) {
                $results[] = $this->mapResponse($result, $statusCode);
            }

            return $results;
        }

        // IPN response
        if (in_array(Arr::get($response, 'body'), ['VERIFIED', 'INVALID'])) {
            $response = array_merge($request, $response);
        }
        // charge request
        elseif (array_key_exists('continue_url', $options)) {
            $response['continue_url'] = $options['continue_url'];
            $response['is_redirect'] = true;
        }

        return $this->mapResponse($response, $statusCode);
    }
1092411
public function post(
        ResponseInterface $response,
        string $transactionId,
        array $options = []
    ): CancellablePromiseInterface {
        if ($response->getBody() instanceof ReadableStreamInterface) {
            return resolve($response);
        }

        if (!isset($options[self::class]) &&
        strpos($response->getHeaderLine('Content-Type'), 'text/xml') !== 0) {
            return resolve($response);
        }

        if (isset($options[self::class][Options::CONTENT_TYPE]) &&
        $response->getHeaderLine('Content-Type') !== $options[self::class][Options::CONTENT_TYPE]) {
            return resolve($response);
        }

        $body = (string)$response->getBody();
        if ($body === '') {
            $stream = new BufferStream(0);
            $stream->write($body);

            return resolve($response->withBody($stream));
        }

        return $this->xmlDecodeService->decode($body)->then(function (array $xml) use ($response) {
            return resolve($response->withBody(new XmlStream($xml)));
        });
    }
208467
public function startRead($message, array $options = null) {
		return $this->startEvent($message, ProfileInterface::TYPE_READ, $options);
	}
514979
public function purchaseIncomplete($email, array $items, $message_id, array $options = [ ]) {
        return $this->purchase($email, $items, 1, $message_id, $options);
    }
865313
public function mapResponse($success, $response)
    {
        $rawResponse = $response;

        unset($rawResponse['isRedirect']);

        if (array_key_exists('INVALID', $response) || array_key_exists('VERIFIED', $response)) {
            $success = array_key_exists('VERIFIED', $response);

            return (new Response())->setRaw($rawResponse)->map([
                'isRedirect'      => false,
                'success'         => $success ? true : false,
                'reference'       => $success ? Arr::get($response, 'invoice') : false,
                'message'         => $success ? 'VERIFIED' : 'INVALID',
                'test'            => $this->config['test'],
                'authorization'   => $success ? Arr::get($response, 'txn_id') : '',
                'status'          => $success ? $this->getPaymentStatus($response) : new Status('failed'),
                'errorCode'       => null,
                'type'            => $success ? Arr::get($response, 'txn_type') : null,
            ]);
        }

        return (new Response())->setRaw($rawResponse)->map([
            'isRedirect'      => $response['isRedirect'],
            'success'         => $response['isRedirect'] ? false : $success,
            'reference'       => $success ? $this->getReference($response, $response['isRedirect']) : false,
            'message'         => $success ? Arr::get($response, 'ACK', 'Transaction approved') : $response['L_LONGMESSAGE0'],
            'test'            => $this->config['test'],
            'authorization'   => $this->getAuthorization($response, $success, $response['isRedirect']),
            'status'          => $success ? $this->getStatus($response, $response['isRedirect']) : new Status('failed'),
            'errorCode'       => $success ? null : $this->getErrorCode($response['L_ERRORCODE0']),
            'type'            => null,
        ]);
    }
1143826
public function success(string $message, string $title = '', array $options = []): self
    {
        return $this->addNotification(self::SUCCESS, $message, $title, $options);
    }
762882
public function send($request, $response, $options = [])
    {
        $this->push($request, $response, $options);
        $result = $this->flush(10, $options);
        return $response;
    }
977962
protected function doTransact(Transaction $transaction, array $options = array())
    {
        $this->validateTransaction($transaction);
        $params = $this->buildParams($transaction, $options);
        $result = $transaction->getResult();
        $result->setTransactor($this);

        $postUrl = $options['post_url'];
        $client = $this->getClient();

        $request = $client->post($postUrl)
            ->addPostFields($params);

        try {
            $response = $request->send();
            $data = array();
            parse_str($response->getBody(true), $data);
        } catch (BadResponseException $e) {
            $data = array(
                'response' => '3',
                'message' => $e->getMessage()
            );
        }

        if (empty($data['response']) || '1' != $data['response']) {
            $result->setStatus(new Result\ResultStatus((!empty($data['response']) && '2' == $data['response']) ? Result\ResultStatus::DECLINED : Result\ResultStatus::ERROR));
            $result->setMessage(empty($data['responsetext']) ? 'An error occurred while processing the payment. Please try again.' : $data['responsetext']);

            if (!empty($data['transactionid'])) {
                $result->setExternalId($data['transactionid']);
            }
        } else {
            $result->setStatus(new Result\ResultStatus(Result\ResultStatus::APPROVED));
            $result->setExternalId($data['transactionid']);
        }

        $result->setData('request', $params);
        $result->setData('response', $data);

        return $result;
    }