y( 'a' => array( 'href' => true, ), 'code' => array(), 'strong' => array(), ) ) ); } /** * Get settings fields. * * @return array>> */ public function get_settings_fields() { $fields = array(); // Refresh Token. $fields[] = array( 'section' => 'general', 'filter' => \FILTER_SANITIZE_STRING, 'meta_key' => '_pronamic_gateway_omnikassa_2_refresh_token', 'title' => \_x( 'Refresh Token', 'omnikassa', 'pronamic_ideal' ), 'type' => 'textarea', 'classes' => array( 'code' ), ); // Signing Key. $fields[] = array( 'section' => 'general', 'filter' => \FILTER_SANITIZE_STRING, 'meta_key' => '_pronamic_gateway_omnikassa_2_signing_key', 'title' => \_x( 'Signing Key', 'omnikassa', 'pronamic_ideal' ), 'type' => 'text', 'classes' => array( 'large-text', 'code' ), ); // Purchase ID. $code_field = \sprintf( '%s', 'merchantOrderId' ); $fields[] = array( 'section' => 'advanced', 'filter' => \FILTER_SANITIZE_STRING, 'meta_key' => '_pronamic_gateway_omnikassa_2_order_id', 'title' => \__( 'Order ID', 'pronamic_ideal' ), 'type' => 'text', 'classes' => array( 'regular-text', 'code' ), 'tooltip' => \sprintf( /* translators: %s: merchantOrderId */ \__( 'This setting defines the OmniKassa 2.0 %s field.', 'pronamic_ideal' ), $code_field ), 'description' => \sprintf( '%s
%s %s
%s', \sprintf( /* translators: %s: merchantOrderId */ \__( 'The OmniKassa 2.0 %s field must consist strictly of 24 alphanumeric characters, other characters, such as ".", "@", " " (space), etc. are not allowed.', 'pronamic_ideal' ), $code_field ), \__( 'Available tags:', 'pronamic_ideal' ), \sprintf( '%s %s', '{order_id}', '{payment_id}' ), \sprintf( /* translators: %s: default code */ \__( 'Default: %s', 'pronamic_ideal' ), '{payment_id}' ) ), ); // Webhook. $fields[] = array( 'section' => 'feedback', 'title' => \__( 'Webhook URL', 'pronamic_ideal' ), 'type' => 'text', 'classes' => array( 'large-text', 'code' ), 'value' => \rest_url( self::REST_ROUTE_NAMESPACE . '/webhook' ), 'readonly' => true, 'tooltip' => \__( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), ); return $fields; } /** * Get configuration by post ID. * * @param int $post_id Post ID. * @return Config */ public function get_config( $post_id ) { $config = new Config(); $config->post_id = \intval( $post_id ); $config->mode = $this->get_meta( $post_id, 'mode' ); $config->refresh_token = $this->get_meta( $post_id, 'omnikassa_2_refresh_token' ); $config->signing_key = $this->get_meta( $post_id, 'omnikassa_2_signing_key' ); $config->access_token = $this->get_meta( $post_id, 'omnikassa_2_access_token' ); $config->access_token_valid_until = $this->get_meta( $post_id, 'omnikassa_2_access_token_valid_until' ); $config->order_id = $this->get_meta( $post_id, 'omnikassa_2_order_id' ); return $config; } /** * Delete access token meta for the specified post ID. * * @link https://github.com/WordPress/WordPress/blob/5.0/wp-includes/post.php#L3724-L3736 * @link https://codex.wordpress.org/Function_Reference/delete_post_meta * @param int $post_id Post ID. * @return void */ public static function delete_access_token_meta( $post_id ) { \delete_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_access_token' ); \delete_post_meta( $post_id, '_pronamic_gateway_omnikassa_2_access_token_valid_until' ); } /** * Get gateway. * * @param int $post_id Post ID. * @return Gateway */ public function get_gateway( $post_id ) { return new Gateway( $this->get_config( $post_id ) ); } }