How to programmatically create a node when a payment is successful I have a content type, and  with the help of the UC node checkout module, I am able to successfully add the content to cart once it is created by the user. When the user checked out and had made a successful payment, I want to create another node of another content type. 

function gy_mod_uc_checkout_complete($order, $account) { 
  if ($order-&gt;order_status == 'payment_received') { 
    exit(); 
  } 
} 


The above is not getting fired; I always get it as "in_checkout." I tried doing it using the Paypal sandbox. 

Does anyone have a suggestion on how I should write the code I need?
Looks like hook_uc_checkout_complete() is called while the order is still in "in_checkout."

You might want to consider using Ubercart's Conditional actions module and add an action for "Trigger: Customer completes checkout"; it allows you to execute actions based on a range of conditions. You can then either execute custom PHP code to create the node, or implement the hook_ca_action() (see "ubercart/ca/ca.ca.inc" for reference).

As to how to programmatically create a node, you can either use node_save() or drupal_execute(). There's quite a few tutorials around that you can use as guidance.