| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Integration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @author    Pronamic <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright 2005-2020 Pronamic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license   GPL-3.0-or-later | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @package   Pronamic\WordPress\Pay\Gateways\Adyen | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Pronamic\WordPress\Pay\Gateways\Adyen; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Pronamic\WordPress\Pay\Dependencies\PhpExtensionDependency; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Pronamic\WordPress\Pay\AbstractGatewayIntegration; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Pronamic\WordPress\Pay\Util as Pay_Util; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * Integration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @author  Remco Tolsma | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @version 1.1.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @since   1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | class Integration extends AbstractGatewayIntegration { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 * REST route namespace. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	const REST_ROUTE_NAMESPACE = 'pronamic-pay/adyen/v1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 * Construct Adyen integration. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 * @param array<string, array<string>> $args Arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 5 |  | 	public function __construct( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 5 |  | 		$args = wp_parse_args( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 5 |  | 			$args, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 5 |  | 				'id'            => 'adyen', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 5 |  | 				'name'          => 'Adyen', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 5 |  | 				'provider'      => 'adyen', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 5 |  | 				'url'           => \__( 'https://www.adyen.com/', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 5 |  | 				'product_url'   => \__( 'https://www.adyen.com/pricing', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 				'dashboard_url' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 5 |  | 					\__( 'test', 'pronamic_ideal' ) => 'https://ca-test.adyen.com/ca/ca/login.shtml', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 5 |  | 					\__( 'live', 'pronamic_ideal' ) => 'https://ca-live.adyen.com/ca/ca/login.shtml', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 5 |  | 				'manual_url'    => \__( 'https://www.pronamic.eu/manuals/using-adyen-pronamic-pay/', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 				'supports'      => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 					'webhook', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 					'webhook_log', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 5 |  | 		parent::__construct( $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		// Dependencies. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 5 |  | 		$dependencies = $this->get_dependencies(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 5 |  | 		$dependencies->add( new PhpExtensionDependency( 'intl' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 5 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	 * Setup gateway integration. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 1 |  | 	public function setup() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		// Check if dependencies are met and integration is active. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  | 		if ( ! $this->is_active() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		// Notifications controller. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  | 		$notifications_controller = new NotificationsController(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  | 		$notifications_controller->setup(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		// Payments controller. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 1 |  | 		$payments_controller = new PaymentsController(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 1 |  | 		$payments_controller->setup(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		// Payments result controller. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  | 		$payments_result_controller = new PaymentsResultController(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 1 |  | 		$payments_result_controller->setup(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		// Site Health controller. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 1 |  | 		$site_healht_controller = new SiteHealthController(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 1 |  | 		$site_healht_controller->setup(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		// Settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  | 		add_action( 'init', array( $this, 'init' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 1 |  | 		add_action( 'admin_init', array( $this, 'admin_init' ), 15 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		// Actions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 1 |  | 		add_action( 'current_screen', array( $this, 'maybe_download_certificate_or_key' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	 * Initialize. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 1 |  | 	public function init() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		 * Authentication - User Name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 1 |  | 		register_setting( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 1 |  | 			'pronamic_pay', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 1 |  | 			'pronamic_pay_adyen_notification_authentication_username', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 1 |  | 				'type'              => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 				'sanitize_callback' => 'sanitize_text_field', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		/* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		 * Authentication - Password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 1 |  | 		register_setting( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 1 |  | 			'pronamic_pay', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 1 |  | 			'pronamic_pay_adyen_notification_authentication_password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 1 |  | 				'type'              => 'string', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 				'sanitize_callback' => 'sanitize_text_field', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 1 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	 * Admin initialize. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 1 |  | 	public function admin_init() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 1 |  | 		add_settings_section( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 1 |  | 			'pronamic_pay_adyen_notification_authentication', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 			/* translators: Translate 'notification' the same as in the Adyen dashboard. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 1 |  | 			_x( 'Adyen Notification Authentication', 'Adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 1 |  | 			array( $this, 'settings_section_notification_authentication' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 1 |  | 			'pronamic_pay' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 1 |  | 		add_settings_field( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 | 1 |  | 			'pronamic_pay_adyen_notification_authentication_username', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 1 |  | 			__( 'User Name', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 1 |  | 			array( __CLASS__, 'input_element' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 | 1 |  | 			'pronamic_pay', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 1 |  | 			'pronamic_pay_adyen_notification_authentication', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 1 |  | 				'label_for' => 'pronamic_pay_adyen_notification_authentication_username', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 | 1 |  | 		add_settings_field( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 1 |  | 			'pronamic_pay_adyen_notification_authentication_password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 | 1 |  | 			__( 'Password', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 1 |  | 			array( __CLASS__, 'input_element' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 | 1 |  | 			'pronamic_pay', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 1 |  | 			'pronamic_pay_adyen_notification_authentication', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 			array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 | 1 |  | 				'label_for' => 'pronamic_pay_adyen_notification_authentication_password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 1 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	 * Settings section notification authentication. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 1 |  | 	public function settings_section_notification_authentication() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 1 |  | 		printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 | 1 |  | 			'<p>%s</p>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 | 1 |  | 			esc_html__( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 1 |  | 				'Set the user name and password below and in the webhook authentication settings in the Adyen dashboard for increased security (recommended).', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 | 1 |  | 				'pronamic_ideal' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 1 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 	 * Input text. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	 * @param array<string,string> $args Arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 1 |  | 	public static function input_element( $args ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 | 1 |  | 		$name = $args['label_for']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 1 |  | 		$value = get_option( $name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 1 |  | 		$value = strval( $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 | 1 |  | 		printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 1 |  | 			'<input name="%s" id="%s" value="%s" type="text" class="regular-text" />', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 1 |  | 			esc_attr( $name ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 1 |  | 			esc_attr( $name ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 1 |  | 			esc_attr( $value ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 1 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	 * Get settings fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 	 * @return array<int, array<string, callable|int|string|bool|array<int|string,int|string>>> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 | 1 |  | 	public function get_settings_fields() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 | 1 |  | 		$fields = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 		// Merchant Account. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 | 1 |  | 			'section'  => 'general', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 | 1 |  | 			'filter'   => FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 | 1 |  | 			'meta_key' => '_pronamic_gateway_adyen_merchant_account', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 | 1 |  | 			'title'    => _x( 'Merchant Account', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 | 1 |  | 			'type'     => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 			'classes'  => array( 'regular-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 | 1 |  | 			'tooltip'  => __( 'The merchant account identifier, with which you want to process the transaction.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 		// API Key. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 | 1 |  | 			'section'     => 'general', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 | 1 |  | 			'filter'      => FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_api_key', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 | 1 |  | 			'title'       => _x( 'API Key', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 | 1 |  | 			'type'        => 'textarea', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 			'classes'     => array( 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 | 1 |  | 			'tooltip'     => __( 'API key as mentioned in the payment provider dashboard.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 | 1 |  | 			'description' => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 | 1 |  | 				'<a href="%s" target="_blank">%s</a>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 | 1 |  | 				esc_url( 'https://docs.adyen.com/developers/user-management/how-to-get-the-api-key' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 | 1 |  | 				esc_html__( 'Adyen documentation: "How to get the API key".', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 		// Live API URL prefix. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 | 1 |  | 			'section'     => 'general', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 | 1 |  | 			'filter'      => FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_api_live_url_prefix', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 | 1 |  | 			'title'       => _x( 'API Live URL Prefix', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 | 1 |  | 			'type'        => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 			'classes'     => array( 'regular-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 | 1 |  | 			'tooltip'     => __( 'The unique prefix for the live API URL, as mentioned at <strong>Account » API URLs</strong> in the Adyen dashboard.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 | 1 |  | 			'description' => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 | 1 |  | 				'<a href="%s" target="_blank">%s</a>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 | 1 |  | 				esc_url( 'https://docs.adyen.com/developers/development-resources/live-endpoints#liveurlprefix' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 | 1 |  | 				esc_html__( 'Adyen documentation: "Live URL prefix".', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 		// Origin Key. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 | 1 |  | 			'section'     => 'general', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 | 1 |  | 			'filter'      => FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_origin_key', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 | 1 |  | 			'title'       => _x( 'Origin Key', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 | 1 |  | 			'type'        => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 			'classes'     => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 				'regular-text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 				'code', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 				'pronamic-pay-form-control-lg', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 | 1 |  | 			'tooltip'     => __( 'An origin key is a client-side key that is used to validate Adyen\'s JavaScript component library. It is required for the Drop-in and Component integrations.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 | 1 |  | 			'description' => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 | 1 |  | 				'<a href="%s" target="_blank">%s</a>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 | 1 |  | 				esc_url( 'https://docs.adyen.com/user-management/how-to-get-an-origin-key' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 | 1 |  | 				esc_html__( 'Adyen documentation: "How to get an origin key".', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 		// Merchant Order Reference. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 | 1 |  | 			'section'     => 'advanced', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 			'filter'      => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 				'filter' => \FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 				'flags'  => \FILTER_FLAG_NO_ENCODE_QUOTES, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_merchant_order_reference', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 | 1 |  | 			'title'       => __( 'Merchant Order Reference', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 | 1 |  | 			'type'        => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 			'classes'     => array( 'regular-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 | 1 |  | 			'tooltip'     => \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 				/* translators: %s: <code>parameterName</code> */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 | 1 |  | 				\__( 'The Adyen %s parameter.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 | 1 |  | 				\sprintf( '<code>%s</code>', 'merchantOrderReference' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 | 1 |  | 			'description' => \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 | 1 |  | 				'%s %s<br />%s', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 | 1 |  | 				\__( 'Available tags:', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 | 1 |  | 				\sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 | 1 |  | 					'<code>%s</code> <code>%s</code>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 | 1 |  | 					'{order_id}', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 | 1 |  | 					'{payment_id}' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 | 1 |  | 				\sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 					/* translators: %s: default code */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 | 1 |  | 					\__( 'Default: <code>%s</code>', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 | 1 |  | 					'{payment_id}' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 		// Apple Pay - Merchant identifier. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 | 1 |  | 			'section'     => 'advanced', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 			'filter'      => \FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_apple_pay_merchant_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 | 1 |  | 			'title'       => _x( 'Apple Pay Merchant ID', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 | 1 |  | 			'type'        => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 			'classes'     => array( 'regular-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 | 1 |  | 			'tooltip'     => __( 'Your Apple Pay Merchant ID. Required for accepting live payments.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 | 1 |  | 			'description' => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 | 1 |  | 				'<a href="%s" target="_blank">%s</a><br /><a href="%s" target="_blank">%s</a>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 | 1 |  | 				esc_url( 'https://docs.adyen.com/payment-methods/apple-pay/web-drop-in#before-you-begin' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 | 1 |  | 				esc_html__( 'Adyen documentation: "Apple Pay Drop-in - Before you begin".', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 | 1 |  | 				esc_url( 'https://developer.apple.com/documentation/apple_pay_on_the_web/configuring_your_environment' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 | 1 |  | 				esc_html__( 'Apple documentation: "Configuring your environment".', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		// Apple Pay - Merchant Identity PKCS#12. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 | 1 |  | 			'section'     => 'advanced', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 			'filter'      => \FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_apple_pay_merchant_id_certificate', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 | 1 |  | 			'title'       => __( 'Apple Pay Merchant Identity Certificate', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 | 1 |  | 			'type'        => 'textarea', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 | 1 |  | 			'callback'    => array( $this, 'field_certificate' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 			'classes'     => array( 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 | 1 |  | 			'tooltip'     => __( 'The Apple Pay Merchant Identity certificate required for secure communication with Apple.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 | 1 |  | 			'description' => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 | 1 |  | 				'<a href="%s" target="_blank">%s</a>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 | 1 |  | 				esc_url( 'https://docs.adyen.com/payment-methods/apple-pay/enable-apple-pay#create-merchant-identity-certificate' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 | 1 |  | 				esc_html__( 'Adyen documentation: "Enable Apple Pay - Create a merchant identity certificate".', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 		// Apple Pay - Merchant Identity private key. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 | 1 |  | 			'section'  => 'advanced', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 			'filter'   => \FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 | 1 |  | 			'meta_key' => '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 | 1 |  | 			'title'    => __( 'Apple Pay Merchant Identity Private Key', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 | 1 |  | 			'type'     => 'textarea', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 | 1 |  | 			'callback' => array( $this, 'field_private_key' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 			'classes'  => array( 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 | 1 |  | 			'tooltip'  => __( 'The private key of the Apple Pay Merchant Identity certificate for secure communication with Apple.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 		// Apple Pay - Merchant Identity certificate private key password. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 | 1 |  | 			'section'  => 'advanced', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 			'filter'   => \FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 | 1 |  | 			'meta_key' => '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key_password', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 | 1 |  | 			'title'    => _x( 'Apple Pay Merchant Identity Private Key Password', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 | 1 |  | 			'type'     => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 			'classes'  => array( 'regular-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 | 1 |  | 			'tooltip'  => __( 'Your Apple Pay Merchant Identity Certificate private key password.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 		// Google Pay - Merchant identifier. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 | 1 |  | 			'section'     => 'advanced', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 			'filter'      => \FILTER_SANITIZE_STRING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 | 1 |  | 			'meta_key'    => '_pronamic_gateway_adyen_google_pay_merchant_identifier', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 | 1 |  | 			'title'       => _x( 'Google Pay Merchant ID', 'adyen', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 | 1 |  | 			'type'        => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 			'classes'     => array( 'regular-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 | 1 |  | 			'tooltip'     => __( 'Your Google Merchant ID. Required for accepting live payments.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 | 1 |  | 			'description' => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 | 1 |  | 				'<a href="%s" target="_blank">%s</a><br /><a href="%s" target="_blank">%s</a>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 | 1 |  | 				esc_url( 'https://docs.adyen.com/payment-methods/google-pay/web-drop-in#test-and-go-live' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 | 1 |  | 				esc_html__( 'Adyen documentation: "Google Pay Drop-in - Test and go live".', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 | 1 |  | 				esc_url( 'https://developers.google.com/pay/api/web/guides/test-and-deploy/deploy-production-environment' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 | 1 |  | 				esc_html__( 'Google documentation: "Deploy production environment".', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 		// Webhook URL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 | 1 |  | 			'section'  => 'feedback', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 | 1 |  | 			'title'    => __( 'Webhook URL', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 | 1 |  | 			'type'     => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 			'classes'  => array( 'large-text', 'code' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 | 1 |  | 			'value'    => rest_url( self::REST_ROUTE_NAMESPACE . '/notifications' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 			'readonly' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 | 1 |  | 			'tooltip'  => sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 				/* translators: %s: payment provider name */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 | 1 |  | 				__( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 | 1 |  | 				__( 'Adyen', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		 * SSL Version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		 * @link https://docs.adyen.com/developers/development-resources/notifications/set-up-notifications#step3configurenotificationsinthecustomerarea | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		 * @link https://www.howsmyssl.com/a/check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 | 1 |  | 			'section' => 'feedback', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 | 1 |  | 			'title'   => __( 'SSL Version', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 | 1 |  | 			'type'    => 'description', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 | 1 |  | 			'html'    => __( 'Choose the SSL Version of your server on the Adyen Customer Area.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		 * Method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 		 * @link https://docs.adyen.com/developers/development-resources/notifications/set-up-notifications#step3configurenotificationsinthecustomerarea | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		 * @link https://www.howsmyssl.com/a/check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 | 1 |  | 			'section' => 'feedback', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 | 1 |  | 			'title'   => _x( 'Method', 'adyen notification', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 | 1 |  | 			'type'    => 'description', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 | 1 |  | 			'html'    => __( 'JSON', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		// Webhook authentication settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 | 1 |  | 		$fields[] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 | 1 |  | 			'section' => 'feedback', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 | 1 |  | 			'title'   => __( 'Authentication', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 | 1 |  | 			'type'    => 'description', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 | 1 |  | 			'html'    => \sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 				/* translators: %s: Pronamic Pay settings page URL. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 | 1 |  | 				__( 'Go to the <a href="%s">Pronamic Pay settings page</a> for webhook authentication settings.', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 | 1 |  | 				\esc_url( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 | 1 |  | 					\add_query_arg( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 						array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 | 1 |  | 							'page' => 'pronamic_pay_settings', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 						), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 | 1 |  | 						\admin_url( 'admin.php' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 					) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		// Return fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 | 1 |  | 		return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 	 * Field certificate. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 	 * @param array<string> $field Field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 	public function field_certificate( $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 		if ( ! \array_key_exists( 'meta_key', $field ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 		$post_id = \get_the_ID(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		if ( false === $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 		$certificate = \get_post_meta( $post_id, $field['meta_key'], true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		if ( ! empty( $certificate ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 			$fingerprint = Security::get_sha_fingerprint( $certificate ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 			echo '<dl>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 			if ( null !== $fingerprint ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 				$fingerprint = \str_split( $fingerprint, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 				$fingerprint = \implode( ':', $fingerprint ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 				echo '<dt>', \esc_html__( 'SHA Fingerprint', 'pronamic_ideal' ), '</dt>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 				echo '<dd>', \esc_html( $fingerprint ), '</dd>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 			$info = \openssl_x509_parse( $certificate ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 			if ( $info ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 				$date_format = __( 'M j, Y @ G:i', 'pronamic_ideal' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 				if ( isset( $info['validFrom_time_t'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 					echo '<dt>', \esc_html__( 'Valid From', 'pronamic_ideal' ), '</dt>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 					echo '<dd>', \esc_html( \date_i18n( $date_format, $info['validFrom_time_t'] ) ), '</dd>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 				if ( isset( $info['validTo_time_t'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 					echo '<dt>', \esc_html__( 'Valid To', 'pronamic_ideal' ), '</dt>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 					echo '<dd>', \esc_html( \date_i18n( $date_format, $info['validTo_time_t'] ) ), '</dd>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 			echo '</dl>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 		} elseif ( false !== \strpos( $field['meta_key'], 'apple_pay' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 			\printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 				'<p class="pronamic-pay-description description">%s</p><p> </p>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 				\esc_html__( 'Upload an Apple Pay Merchant Identity certificate, which can be exported from Keychain Access on Mac as a PKCS#12 (*.p12) file.', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 		<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 			if ( ! empty( $certificate ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 				\submit_button( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 					__( 'Download', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 					'secondary', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 					'download' . $field['meta_key'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 					false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 				echo ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 			\printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 				'<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 				\esc_html__( 'Upload', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 				\esc_attr( $field['meta_key'] . '_file' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 		</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 	 * Field private key. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 	 * @param array<string> $field Field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 	public function field_private_key( $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 		if ( ! \array_key_exists( 'meta_key', $field ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 		$post_id = \get_the_ID(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 		if ( false === $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		$private_key = \get_post_meta( $post_id, $field['meta_key'], true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 		<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 			if ( ! empty( $private_key ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 				\submit_button( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 					__( 'Download', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 					'secondary', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 					'download' . $field['meta_key'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 					false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 				echo ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 			if ( empty( $private_key ) && false !== \strpos( $field['meta_key'], 'apple_pay' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 				\printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 					'<p class="pronamic-pay-description description">%s</p><p> </p>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 					\esc_html__( 'Leave empty to auto fill when uploading an Apple Pay Merchant Identity PKCS#12 certificate file.', 'pronamic_ideal' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			\printf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 				'<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 				\esc_html__( 'Upload', 'pronamic_ideal' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 				\esc_attr( $field['meta_key'] . '_file' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 		</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 	 * Download certificate or key in Privacy Enhanced Mail (PEM) format. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 	public function maybe_download_certificate_or_key() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 		// Certificate fields and download filename. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 		$fields = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			'_pronamic_gateway_adyen_apple_pay_merchant_id_certificate' => 'apple-pay-merchant-identity-certificate-%s.pem', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 			'_pronamic_gateway_adyen_apple_pay_merchant_id_private_key' => 'apple-pay-merchant-identity-private-key-%s.pem', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 		// Check download actions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 		$is_download_action = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 		foreach ( $fields as $meta_key => $filename ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 			if ( \filter_has_var( \INPUT_POST, 'download' . $meta_key ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 				$is_download_action = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 		// No valid download action found. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 		if ( false === $is_download_action ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 		$post_id = filter_input( \INPUT_POST, 'post_ID', \FILTER_SANITIZE_STRING ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 		$filename = sprintf( $filename, $post_id ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 		header( 'Content-Description: File Transfer' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 		header( 'Content-Disposition: attachment; filename=' . $filename ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 		header( 'Content-Type: application/x-pem-file; charset=' . get_option( 'blog_charset' ), true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 		echo get_post_meta( $post_id, $meta_key, true ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 		exit; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 	 * Save post. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 	 * @param int $post_id Post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 	public function save_post( $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 		// Files. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		$files = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 			'_pronamic_gateway_adyen_apple_pay_merchant_id_certificate_file' => '_pronamic_gateway_adyen_apple_pay_merchant_id_certificate', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 			'_pronamic_gateway_adyen_apple_pay_merchant_id_private_key_file' => '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 		foreach ( $files as $name => $meta_key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 			// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 			if ( isset( $_FILES[ $name ] ) && \UPLOAD_ERR_OK === $_FILES[ $name ]['error'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 				$value = file_get_contents( $_FILES[ $name ]['tmp_name'], true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 				update_post_meta( $post_id, $meta_key, $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 		// Update Apple Pay Merchant Identity certificate and private key from uploaded PKCS#12 file. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 		$apple_pay_merchant_id_pkcs12 = get_post_meta( $post_id, '_pronamic_gateway_adyen_apple_pay_merchant_id_certificate', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 		if ( ! empty( $apple_pay_merchant_id_pkcs12 ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 			// Try to read file without using password. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 			$pkcs12_read = \openssl_pkcs12_read( $apple_pay_merchant_id_pkcs12, $certs, '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 			$password = \get_post_meta( $post_id, '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key_password', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 			// Try to read file with private key password. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 			if ( false === $pkcs12_read ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 				$pkcs12_read = \openssl_pkcs12_read( $apple_pay_merchant_id_pkcs12, $certs, $password ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 			if ( true === $pkcs12_read ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 				if ( isset( $certs['cert'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 					\update_post_meta( $post_id, '_pronamic_gateway_adyen_apple_pay_merchant_id_certificate', $certs['cert'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 				if ( isset( $certs['pkey'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 					$private_key = $certs['pkey']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 					$cipher = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 					// Try to export the private key encrypted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 					if ( defined( 'OPENSSL_CIPHER_AES_128_CBC' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 						$cipher = \OPENSSL_CIPHER_AES_128_CBC; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 					} elseif ( defined( 'OPENSSL_CIPHER_3DES' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 						$cipher = \OPENSSL_CIPHER_3DES; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 					if ( null !== $cipher && '' !== $password ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 						$args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 							'digest_alg'             => 'SHA256', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 							'private_key_bits'       => 2048, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 							'private_key_type'       => \OPENSSL_KEYTYPE_RSA, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 							'encrypt_key'            => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 							'encrypt_key_cipher'     => $cipher, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 							'subjectKeyIdentifier'   => 'hash', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  | 							'authorityKeyIdentifier' => 'keyid:always,issuer:always', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 							'basicConstraints'       => 'CA:true', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 						); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 						\openssl_pkey_export( $certs['pkey'], $private_key, $password, $args ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 					\update_post_meta( $post_id, '_pronamic_gateway_adyen_apple_pay_merchant_id_private_key', $private_key ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 	 * Get configuration by post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 	 * @param int $post_id Post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 	 * @return Config | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 707 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 708 | 1 |  | 	public function get_config( $post_id ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 709 | 1 |  | 		$config = new Config(); | 
            
                                                                        
                            
            
                                    
            
            
                | 710 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 711 | 1 |  | 		$config->mode                                       = $this->get_meta( $post_id, 'mode' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 712 | 1 |  | 		$config->api_key                                    = $this->get_meta( $post_id, 'adyen_api_key' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 713 | 1 |  | 		$config->api_live_url_prefix                        = $this->get_meta( $post_id, 'adyen_api_live_url_prefix' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 714 | 1 |  | 		$config->merchant_account                           = $this->get_meta( $post_id, 'adyen_merchant_account' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 715 | 1 |  | 		$config->origin_key                                 = $this->get_meta( $post_id, 'adyen_origin_key' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 716 | 1 |  | 		$config->merchant_order_reference                   = $this->get_meta( $post_id, 'adyen_merchant_order_reference' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 717 | 1 |  | 		$config->apple_pay_merchant_id                      = $this->get_meta( $post_id, 'adyen_apple_pay_merchant_id' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 718 | 1 |  | 		$config->apple_pay_merchant_id_certificate          = $this->get_meta( $post_id, 'adyen_apple_pay_merchant_id_certificate' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 719 | 1 |  | 		$config->apple_pay_merchant_id_private_key          = $this->get_meta( $post_id, 'adyen_apple_pay_merchant_id_private_key' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 720 | 1 |  | 		$config->apple_pay_merchant_id_private_key_password = $this->get_meta( $post_id, 'adyen_apple_pay_merchant_id_private_key_password' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 721 | 1 |  | 		$config->google_pay_merchant_identifier             = $this->get_meta( $post_id, 'adyen_google_pay_merchant_identifier' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 722 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 723 | 1 |  | 		return $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 	 * Get gateway. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 	 * @param int $post_id Post ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 	 * @return AbstractGateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 | 1 |  | 	public function get_gateway( $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 | 1 |  | 		$config = $this->get_config( $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 | 1 |  | 		if ( empty( $config->origin_key ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 | 1 |  | 			return new WebSdkGateway( $config ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 		return new DropInGateway( $config ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 741 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 742 |  |  |  | 
            
                        
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.