HEX
Server: Apache/2
System: Linux bq-e705.pointdnshere.com 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User: wellmix (1103)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/wellmix/public_html/wp-content/plugins/pymntpl-paypal-woocommerce/src/Messages.php
<?php


namespace PaymentPlugins\WooCommerce\PPCP;


class Messages {

	private $messages = [];

	private $error_messages;

	public function __construct() {
		$this->initialize();
	}

	private function initialize() {
		add_filter( 'wc_ppcp_api_request_error_message', [ $this, 'get_error_message' ], 10, 2 );
		$this->messages = [
			'terms'             => __( 'Please check the terms and conditions before proceeding.', 'pymntpl-paypal-woocommerce' ),
			'invalid_client_id' => __( 'Invalid PayPal client ID. Please check your API Settings.', 'pymntpl-paypal-woocommerce' ),
			'invalid_currency'  => __( 'PayPal does not support currency %. Please use a supported currency.', 'pymntpl-paypal-woocommerce' )
		];

		$this->error_messages = [
			'REFUSED_MARK_REF_TXN_NOT_ENABLED' => __( 'This merchant account is not permitted to create Merchant Initiated Billing Agreements. Please contact PayPal support and request reference transaction access.', 'pymntpl-paypal-woocommerce' )
		];
	}

	public function get_messages() {
		return apply_filters( 'wc_ppcp_get_messages', $this->messages );
	}

	/**
	 * @param string                                           $msg
	 * @param \PaymentPlugins\PayPalSDK\Exception\ApiException $error
	 *
	 * @return void
	 */
	public function get_error_message( $msg, $error ) {
		if ( $error && isset( $this->error_messages[ $error->getErrorCode() ] ) ) {
			$msg = $this->error_messages[ $error->getErrorCode() ];
		}

		return $msg;
	}

}