fix(helcim): read dateBilling on subscription CREATE to populate next-billing cache
Helcim returns next-charge as `dateBilling` on POST /subscriptions, but the two CREATE sites were reading `subscription.nextBillingDate`, leaving `member.nextBillingDate` empty after every signup and free→paid upgrade. The lazy refresh in subscription.get.js (which already accepts both shapes) masked it on next account-page load, so renders eventually populated — but the success response we returned to the client also had `nextBillingDate: undefined`. Mirror the GET-side resolution at both CREATE sites: prefer `dateBilling`, fall back to `nextBillingDate`. Existing Number.isNaN guard unchanged; defensively rejects malformed strings from either field.
This commit is contained in:
parent
3c38333dd1
commit
cf59931814
5 changed files with 65 additions and 9 deletions
|
|
@ -100,9 +100,8 @@ export default defineEventHandler(async (event) => {
|
|||
throw new Error("No subscription returned in response");
|
||||
}
|
||||
|
||||
const nextBillingDate = subscription.nextBillingDate
|
||||
? new Date(subscription.nextBillingDate)
|
||||
: null;
|
||||
const rawNextBilling = subscription.dateBilling || subscription.nextBillingDate || null;
|
||||
const nextBillingDate = rawNextBilling ? new Date(rawNextBilling) : null;
|
||||
|
||||
// Update member record
|
||||
await Member.findByIdAndUpdate(
|
||||
|
|
@ -149,7 +148,7 @@ export default defineEventHandler(async (event) => {
|
|||
subscription: {
|
||||
subscriptionId: subscription.id,
|
||||
status: subscription.status,
|
||||
nextBillingDate: subscription.nextBillingDate,
|
||||
nextBillingDate: rawNextBilling,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue