<?php

namespace SugarCalendarBookings\Payments\Gateways;

use Exception;
use SugarCalendarBookings\Payments\PaymentModel;

/**
 * Class AbstractPaymentProcessor.
 *
 * @since 1.0.0
 */
abstract class AbstractPaymentProcessor {

	/**
	 * Get processing rules for authorization_data data.
	 *
	 * @since 1.1.0
	 *
	 * @return array
	 */
	public function get_authorization_data_processing_rules() {

		return [];
	}

	/**
	 * Authorize payment without capturing.
	 *
	 * @since 1.0.0
	 *
	 * @param PaymentModel $payment            Payment model instance.
	 * @param array        $authorization_data Authorization data.
	 *
	 * @return array Authorization data.
	 *
	 * @throws Exception If payment cannot be authorized.
	 */
	abstract public function authorize_payment( $payment, $authorization_data );

	/**
	 * Get processing rules for capture data.
	 *
	 * @since 1.1.0
	 *
	 * @return array
	 */
	public function get_capture_data_processing_rules() {

		return [];
	}

	/**
	 * Capture previously authorized payment.
	 *
	 * @since 1.0.0
	 *
	 * @param PaymentModel $payment      Payment model instance.
	 * @param array        $capture_data Payment data.
	 *
	 * @return array Capture data.
	 *
	 * @throws Exception If payment cannot be captured.
	 */
	abstract public function capture_payment( $payment, $capture_data );

	/**
	 * Refund a completed payment.
	 *
	 * @since 1.1.0
	 *
	 * @param PaymentModel $payment Payment model instance.
	 *
	 * @return array Refund data.
	 *
	 * @throws Exception If payment cannot be refunded.
	 */
	abstract public function refund_payment( $payment );
}
