adyen-web icon indicating copy to clipboard operation
adyen-web copied to clipboard

[FEAT] Add callback types to CoreOptions

Open nklaasse opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. Currently none of the callbacks are typed in CoreOptions.

Describe the solution you'd like

src/core/types.ts

    ...

    /**
     * OnLoad callback
     */
    onLoad?: (callbackObj: CbObjOnLoad) => void;

    /**
     * OnConfigSuccess callback
     */
    onConfigSuccess?: (callbackObj: CbObjOnConfigSuccess) => void;

    /**
     * OnFieldValid callback
     */
    onFieldValid?: (callbackObj: CbObjOnFieldValid) => void;

    /**
     * OnAllValid callback
     */
    onAllValid?: (callbackObj: CbObjOnAllValid) => void;

    /**
     * OnBrand callback
     */
    onBrand?: (callbackObj: CbObjOnBrand) => void;

    /**
     * OnError callback
     */
    onError?: (callbackObj: CbObjOnError) => void;

    /**
     * OnFocus callback
     */
    onFocus?: (callbackObj: CbObjOnFocus) => void;

    /**
     * OnBinValue callback
     */
    onBinValue?: (callbackObj: CbObjOnBinValue) => void;

    /**
     * OnAutoComplete callback
     */
    onAutoComplete?: (callbackObj: CbObjOnAutoComplete) => void;

    ...

To start off with a little more strict typing, I have updated the type field in CbObjOnConfigSuccess with keyof PaymentMethods.

src/components/internal/SecuredFields/lib/types.ts

import { PaymentMethods } from '../../../../types';

...
export interface CbObjOnConfigSuccess {
    iframesConfigured: boolean;
    type: keyof PaymentMethods;
}
...

Additional context Tested changed above successfully locally.

nklaasse avatar Oct 13 '20 09:10 nklaasse

Hi @nklaasse,

Thanks for the pointing this out. Indeed we are missing the types for those events. We'll make a note to implement those in a future release.

marcperez avatar Oct 13 '20 11:10 marcperez

These types were all added as part of the Card component (packages/lib/src/components/Card/types.ts) in November 2020

sponglord avatar Jan 24 '23 14:01 sponglord