Paddle.Update({
    eventCallback: function(data){
        if (data.name == "checkout.completed") {
            console.log(data);
            const customerId = data.data.customer.id;
            const income = data.data.recurring_totals.total ?? 0;

            fetch("/wp-json/digtective/v1/form-submission/paddle",
                {
                    method: "POST", headers: {"Content-Type": "application/json"},
                    body: JSON.stringify({paddleCustomerId: customerId, income: income})
                })
        }
    }
})