Ensuring my webhook captures a customer's name and email address during subscription payments is crucial.
To achieve this, I decided to test the test_clock functionality provided by Stripe for simulation purposes.
While the Advance time feature works flawlessly in deducting payments from the designated card, I'm facing difficulty extracting the customer's email address and name from the event response returned.
Below is the snippet of code that deals with the event type:
// Event handling
switch (event.type) {
case 'customer.subscription.updated':
console.log(`Subscription status updated: ${event.data.object.status}`);
const subscription = event.data.object;
const customerName = subscription.customer.name;
const customerEmail = subscription.customer.email;
console.log('Customer Name: ' + customerName);
console.log('Customer Email: ' + customerEmail);
The output of the code above shows:
Subscription status updated: active
Customer Name: undefined
Customer Email: undefined
I am seeking guidance on how to successfully capture the customer's name and email address.