This one for completed initial subscription payments and subscription renewals.
function payment_made($subscription){
// How do I get the order details?
}
add
To get the Order details from the WC_Subscription Object, you will need first to get the parent ID (which is the order ID) using get_parent_id() method:
$order_id = $subscription->get_parent_id();
Then you will get the WC_Order Object from the order Id using:
$order = wc_get_order( $order_id );
Then to get order details: How to get WooCommerce order details
Related: