<?php
/**
 * Handles Swish Errors
 *
 * @package flo-checkout
 */

namespace Flo_Checkout\Gateways\Swish;

/**
 * Swish Errors class.
 */
class Swish_Errors {

	/**
	 * Get the error message for an error code.
	 *
	 * @param string $code The error code.
	 *
	 * @return string
	 */
	public static function get_message_by_code( string $code ): string {
		$codes = array(
			'PA01'          => __( 'The technical supplier is not connected to the merchant, Please contact Northmill.', 'flo-checkout-plugin' ),
			'FF08'          => __( 'PayeePaymentReference is invalid', 'flo-checkout-plugin' ),
			'RP03'          => __( 'Callback URL is missing or does not use Https', 'flo-checkout-plugin' ),
			'BE18'          => __( 'Payer alias is invalid', 'flo-checkout-plugin' ),
			'RP01'          => __( 'Payee alias is missing or empty', 'flo-checkout-plugin' ),
			'PA02'          => __( 'Amount value is missing or not a valid number', 'flo-checkout-plugin' ),
			'AM06'          => __( 'Amount value is too low', 'flo-checkout-plugin' ),
			'AM02'          => __( 'Amount value is too large', 'flo-checkout-plugin' ),
			'AM03'          => __( 'Invalid or missing currency', 'flo-checkout-plugin' ),
			'RP02'          => __( 'Wrong formatted message', 'flo-checkout-plugin' ),
			'RP06'          => __( 'Another active request already exists for this swish number', 'flo-checkout-plugin' ),
			'ACMT03'        => __( 'Payer not Enrolled', 'flo-checkout-plugin' ),
			'ACMT01'        => __( 'Counterpart is not activated', 'flo-checkout-plugin' ),
			'ACMT07'        => __( 'Payee not Enrolled', 'flo-checkout-plugin' ),
			'ACMT17'        => __( 'Not a valid swish number', 'flo-checkout-plugin' ),
			'WAITING'       => __( 'Start your Swish-App and authorize the payment', 'flo-checkout-plugin' ),
			'PAID'          => __( 'Thank you for your payment', 'flo-checkout-plugin' ),
			'DECLINED'      => __( 'Payment declined', 'flo-checkout-plugin' ),
			'ERROR'         => __( 'An error has occurred', 'flo-checkout-plugin' ),
			'BANKIDCL'      => __( 'Payer cancelled BankId signing', 'flo-checkout-plugin' ),
			'FF10'          => __( 'Bank system processing error', 'flo-checkout-plugin' ),
			'TM01'          => __( 'Swish timed out before the payment was started', 'flo-checkout-plugin' ),
			'RF07'          => __( 'Check the payment with your Bank', 'flo-checkout-plugin' ),
			'RF02'          => __( 'Original payment not found or original payment is more than than 13 months old', 'flo-checkout-plugin' ),
			'DS24'          => __( 'Swish timed out waiting for an answer from the banks. Check with your bank about the status of this payment', 'flo-checkout-plugin' ),
			'BANKIDONGOING' => __( 'BankID already in use.', 'flo-checkout-plugin' ),
			'BANKIDUNKN'    => __( 'BankID is not able to authorize the payment', 'flo-checkout-plugin' ),
		);

		return $codes[ $code ] ?? __( 'Unknown error', 'flo-checkout-plugin' );
	}
}
