/**
  * When the post is saved, saves our custom data.
  *
  * @param int $post_id The ID of the post being saved.
  */
 public function save_post($post_id)
 {
     // Check if our nonce is set.
     if (!filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
         return $post_id;
     }
     $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, 'pronamic_pay_save_gateway')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* OK, its safe for us to save the data now. */
     $fields = $this->admin->gateway_settings->get_fields();
     $definition = array('_pronamic_gateway_id' => FILTER_SANITIZE_STRING);
     foreach ($fields as $field) {
         if (isset($field['meta_key'], $field['filter'])) {
             $name = $field['meta_key'];
             $filter = $field['filter'];
             $definition[$name] = $filter;
         }
     }
     $data = filter_input_array(INPUT_POST, $definition);
     // Files
     $files = array('_pronamic_gateway_ideal_private_key_file' => '_pronamic_gateway_ideal_private_key', '_pronamic_gateway_ideal_private_certificate_file' => '_pronamic_gateway_ideal_private_certificate');
     foreach ($files as $name => $meta_key) {
         if (isset($_FILES[$name]) && UPLOAD_ERR_OK === $_FILES[$name]['error']) {
             $value = file_get_contents($_FILES[$name]['tmp_name']);
             $data[$meta_key] = $value;
         }
     }
     // Update post meta data
     pronamic_pay_update_post_meta_data($post_id, $data);
     // Transient
     delete_transient('pronamic_pay_issuers_' . $post_id);
 }
Esempio n. 2
0
 /**
  * When the post is saved, saves our custom data.
  *
  * @param int $post_id The ID of the post being saved.
  */
 public function save_post($post_id)
 {
     // Check if our nonce is set.
     if (!filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
         return $post_id;
     }
     $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, 'pronamic_pay_save_gateway')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* OK, its safe for us to save the data now. */
     $definition = array('_pronamic_gateway_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_mode' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_merchant_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_sub_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_purchase_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_hash_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_paydutch_username' => FILTER_SANITIZE_STRING, '_pronamic_gateway_paydutch_password' => FILTER_SANITIZE_STRING, '_pronamic_gateway_mollie_api_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_mollie_partner_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_mollie_profile_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_multisafepay_account_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_multisafepay_site_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_multisafepay_site_code' => FILTER_SANITIZE_STRING, '_pronamic_gateway_omnikassa_merchant_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_omnikassa_secret_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_omnikassa_key_version' => FILTER_SANITIZE_STRING, '_pronamic_gateway_buckaroo_website_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_buckaroo_secret_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_icepay_merchant_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_icepay_secret_code' => FILTER_SANITIZE_STRING, '_pronamic_gateway_pay_nl_token' => FILTER_SANITIZE_STRING, '_pronamic_gateway_pay_nl_service_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_sisow_merchant_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_sisow_merchant_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_sisow_shop_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_targetpay_layoutcode' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_psp_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_hash_algorithm' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_sha_in_pass_phrase' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_sha_out_pass_phrase' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_user_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_password' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_order_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_param_var' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_template_page' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_directlink_sha_in_pass_phrase' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ogone_3d_secure_enabled' => FILTER_VALIDATE_BOOLEAN, '_pronamic_gateway_qantani_merchant_id' => FILTER_SANITIZE_STRING, '_pronamic_gateway_qantani_merchant_secret' => FILTER_SANITIZE_STRING, '_pronamic_gateway_qantani_merchant_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_private_key_password' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_private_key' => FILTER_SANITIZE_STRING, '_pronamic_gateway_ideal_private_certificate' => FILTER_SANITIZE_STRING, '_pronamic_gateway_number_days_valid' => FILTER_SANITIZE_STRING, '_pronamic_gateway_country' => FILTER_SANITIZE_STRING, '_pronamic_gateway_state_or_province' => FILTER_SANITIZE_STRING, '_pronamic_gateway_locality' => FILTER_SANITIZE_STRING, '_pronamic_gateway_organization' => FILTER_SANITIZE_STRING, '_pronamic_gateway_organization_unit' => FILTER_SANITIZE_STRING, '_pronamic_gateway_common_name' => FILTER_SANITIZE_STRING, '_pronamic_gateway_email' => FILTER_SANITIZE_STRING);
     $data = filter_input_array(INPUT_POST, $definition);
     // Files
     $files = array('_pronamic_gateway_ideal_private_key_file' => '_pronamic_gateway_ideal_private_key', '_pronamic_gateway_ideal_private_certificate_file' => '_pronamic_gateway_ideal_private_certificate');
     foreach ($files as $name => $meta_key) {
         if (isset($_FILES[$name]) && UPLOAD_ERR_OK === $_FILES[$name]['error']) {
             $value = file_get_contents($_FILES[$name]['tmp_name']);
             $data[$meta_key] = $value;
         }
     }
     // Update post meta data
     pronamic_pay_update_post_meta_data($post_id, $data);
     // Transient
     delete_transient('pronamic_pay_issuers_' . $post_id);
 }
 /**
  * When the post is saved, saves our custom data.
  *
  * @param int $post_id The ID of the post being saved.
  */
 public function save_post($post_id)
 {
     // Check if our nonce is set.
     if (!filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
         return $post_id;
     }
     $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, 'pronamic_pay_save_form_options')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* OK, its safe for us to save the data now. */
     $definition = array('_pronamic_payment_form_config_id' => FILTER_SANITIZE_NUMBER_INT, '_pronamic_payment_form_button_text' => FILTER_SANITIZE_STRING, '_pronamic_payment_form_amount_method' => FILTER_SANITIZE_STRING, '_pronamic_payment_form_amount_choices' => array('flags' => FILTER_REQUIRE_ARRAY));
     $data = filter_input_array(INPUT_POST, $definition);
     // Convert amount choices to cents
     if (isset($data['_pronamic_payment_form_amount_choices'])) {
         foreach ($data['_pronamic_payment_form_amount_choices'] as $i => $amount) {
             $amount = Pronamic_WP_Pay_Util::string_to_amount($amount);
             $data['_pronamic_payment_form_amount_choices'][$i] = Pronamic_WP_Pay_Util::amount_to_cents($amount);
         }
         // Remove empty choices
         $data['_pronamic_payment_form_amount_choices'] = array_filter($data['_pronamic_payment_form_amount_choices']);
     }
     // Update post meta data
     pronamic_pay_update_post_meta_data($post_id, $data);
 }
Esempio n. 4
0
 /**
  * When the post is saved, saves our custom data.
  *
  * @param int $post_id The ID of the post being saved.
  */
 public function save_post($post_id)
 {
     // Check if our nonce is set.
     if (!filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) {
         return $post_id;
     }
     $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING);
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, 'pronamic_pay_save_form_options')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted, so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     /* OK, its safe for us to save the data now. */
     $definition = array('_pronamic_payment_form_config_id' => FILTER_SANITIZE_STRING, '_pronamic_payment_form_button_text' => FILTER_SANITIZE_STRING);
     $data = filter_input_array(INPUT_POST, $definition);
     // Update post meta data
     pronamic_pay_update_post_meta_data($post_id, $data);
 }