diff --git a/src/CheckoutAPI.ts b/src/CheckoutAPI.ts index 9984fb4..a362c8e 100644 --- a/src/CheckoutAPI.ts +++ b/src/CheckoutAPI.ts @@ -77,12 +77,21 @@ export default function CheckoutAPI(options?: CheckoutConfiguration) { }, destroy() { // Unmount all registered drop-in-components - Object.keys(elements).forEach((sere) => { - elements[sere].unmount(); + Object.keys(elements).forEach((el) => { + elements[el].unmount(); }); // Clear store data store.options = {} as CheckoutConfiguration; }, + reload() { + if (store.options) { + Object.keys(elements).forEach((el) => { + elements[el].update(store.options); + }); + } else { + throw new Error("Invalid configurations!"); + } + }, }; } diff --git a/src/DropInComponent.ts b/src/DropInComponent.ts index d5f7920..e58f2ea 100644 --- a/src/DropInComponent.ts +++ b/src/DropInComponent.ts @@ -43,5 +43,8 @@ export default function DropInComponent(name: string, options: CheckoutConfigura update(opt: CheckoutConfiguration | undefined): void { if (opt) updateOptions(opt); }, + reload() { + initialise(); + }, }; }