File "RequestProcessor.php"

Full Path: /home/romayxjt/public_html/wp-content/plugins/fluentform/app/Modules/Payments/PaymentMethods/Stripe/API/RequestProcessor.php
File size: 748 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace FluentForm\App\Modules\Payments\PaymentMethods\Stripe\API;

if (!defined('ABSPATH')) {
	exit;
}

trait RequestProcessor
{
	private static function processResponse($response)
	{
		if (!empty($response->error)) {
			$errorType = 'general';

			if (!empty($response->error->type)) {
				$errorType = $response->error->type;
			}

			$errorCode = '';

			if (!empty($response->error->code)) {
				$errorCode = $response->error->code . ' : ';
			}

			return static::errorHandler($errorType, $errorCode . $response->error->message);
		}

		if (false !== $response) {
			return $response;
		}

		return false;
	}

	private static function errorHandler($code, $message, $data = [])
	{
		return new \WP_Error($code, $message, $data);
	}
}