#nerder-customerdelete-event
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
Hmm have you tested it already? My understanding is that this event is only generated in case the request to detach/delete PaymentMethod is triggered.
I've tested it but I expected it to be fired
since the customer is not there anymore, the payment method is not attached to anyone so it should be detached no?
You wouldn't be able to use the PaymentMethod if the customer gets deleted afaik. and there are webhook events for customer deletion I believe.
Taking a step back, what's the usecase here? Trying to understand why you'd rely on payment_method.detached events in such cases versus customer object related webhook events?
it's just to not duplicate the logic
for now my use case is quite simple, in customer.deleted I only want to remove the payment_methods attached to it
but might make sense for me to handle customer.deleted and recursively remove all the payment_methods of that customer (in my DB)
it was strange to not see this firing
Yeah that's the path I'd go, as payment_method.detached won't have a reason listed as to why this payment method was detached
i expected it to behave as customer.subscription.deleted in a sense
it will be called as a consequence of customer.deleted
but it was the wrong assumption ๐
Hey sorry
just testing your proposal
there is a small issue
since the customer is deleted i could not retreive the payment methods attached to ti
imagine i'm doing something like this:
const paymentMethods = await this.customerRepository.retrievePaymentMethods(stripeAccount, customer);
await Promise.all([
...paymentMethods.map(paymentMethod =>
this.customerPaymentMethodRepository.remove(stripeAccount, gymId, paymentMethod, customer),
),
]);
where retrievePaymentMethod is this:
async retrievePaymentMethods(
stripeAccount: StripeAccountId,
customer: Stripe.Customer,
): Promise<Stripe.PaymentMethod[]> {
this.logger.log(`Retrieve all payment methods for customer [${customer.id}]`);
const allPaymentMethods = await this.stripe.customers.listPaymentMethods(customer.id, {
stripeAccount,
});
if (!allPaymentMethods.data.length) {
return null;
}
return allPaymentMethods.data;
}
}
this will fail, because that customer is deleted now
but might make sense for me to handle customer.deleted and recursively remove all the payment_methods of that customer (in my DB)
I am assuming you have some sort of mapping betweenpm_xxxandcus_xxxobjects in your DB?
๐ ๐
sorry to bother ๐
NP! ๐ Happy to help
nerder-customerdelete-event