Xendit InvoiceCallback Type not match with request body
From the documentation, all properties of Invoice Callback Object are in camelCase.
However, when I checked the request body in invoice webhook, all properties are in snake_case
So, the request body in invoice webhook not match with Invoice Callback Object
Is there a way to make it work?
Hi Mike,
To make it work, you can just create an extended interface. For instance, we can add "external_id" like this:
interface ExtendedInvoiceCallback extends InvoiceCallback { external_id: string; }
Now we can get "external_id" from Invoice Callback Object.
Best Regards, Muhamad Danang Priambodo
On Tue, Aug 20, 2024 at 2:21 AM Mike John Eviota @.***> wrote:
Is there a way to make it work?
— Reply to this email directly, view it on GitHub https://github.com/xendit/xendit-node/issues/223#issuecomment-2297276079, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQM65W6EUQOUGGPZV6Y45ODZSJASRAVCNFSM6AAAAABMXM2TD2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJXGI3TMMBXHE . You are receiving this because you authored the thread.Message ID: @.***>
Hi Mike, To make it work, you can just create an extended interface. For instance, we can add "external_id" like this: interface ExtendedInvoiceCallback extends InvoiceCallback { external_id: string; } Now we can get "external_id" from Invoice Callback Object. Best Regards, Muhamad Danang Priambodo … On Tue, Aug 20, 2024 at 2:21 AM Mike John Eviota @.> wrote: Is there a way to make it work? — Reply to this email directly, view it on GitHub <#223 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQM65W6EUQOUGGPZV6Y45ODZSJASRAVCNFSM6AAAAABMXM2TD2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJXGI3TMMBXHE . You are receiving this because you authored the thread.Message ID: @.>
Will this work with this issue sir mcdanag https://github.com/xendit/xendit-node/issues/222
Hi Mike, To make it work, you can just create an extended interface. For instance, we can add "external_id" like this: interface ExtendedInvoiceCallback extends InvoiceCallback { external_id: string; } Now we can get "external_id" from Invoice Callback Object. Best Regards, Muhamad Danang Priambodo … On Tue, Aug 20, 2024 at 2:21 AM Mike John Eviota @.> wrote: Is there a way to make it work? — Reply to this email directly, view it on GitHub <#223 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQM65W6EUQOUGGPZV6Y45ODZSJASRAVCNFSM6AAAAABMXM2TD2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJXGI3TMMBXHE . You are receiving this because you authored the thread.Message ID: _@**.**_>
Will this work with this issue sir mcdanag #222
I don't think so.
In this thread, the callback return the data (e.g. external_id) but the properties name not match with the Invoice Callback Object (externalId).
On the other hand, issue #222 doesn't return the url properties. I think you can just save the url in your own database.
Hi Mike,
To make it work, you can just create an extended interface. For instance, we can add "external_id" like this:
interface ExtendedInvoiceCallback extends InvoiceCallback { external_id: string; }
Now we can get "external_id" from Invoice Callback Object.
Best Regards, Muhamad Danang Priambodo …
this is absurd, inconsistent, and unnecessary. why isn’t it typed 1:1 with the response body style (snake_case)? I really wonder who approved this and why
i had to add a type utility just to make it 1:1 (and to cover missing fields)
type SnakeCase<S extends string> = S extends `${infer T}${infer U}`
? U extends Uncapitalize<U>
? `${Lowercase<T>}${SnakeCase<U>}`
: `${Lowercase<T>}_${SnakeCase<Uncapitalize<U>>}`
: S
type SnakeCasedKeys<T> = {
[K in keyof T as K extends string ? SnakeCase<K> : K]: T[K] extends object
? SnakeCasedKeys<T[K]>
: T[K]
}
interface CompleteInvoiceCallback extends SnakeCasedKeys<InvoiceCallback> {
is_high?: boolean
adjusted_received_amount?: number
fees_paid?: number
}