Payment before publishing post

Use below code

add_action('transition_post_status', 'send_new_post', 10, 3);

// Listen for publishing of a new post
function send_new_post($new_status, $old_status, $post) {

  if('publish' === $new_status && 'publish' !== $old_status && $post->post_type === 'post') {
    // Do something!
  }

}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)