Installation and Usage
AUTHORIZATION NEEDED
Remember that In order to instance this widget, you will need a widgetToken obtained from this endpoint. and a publicKey provided by us.
Library Integration​
Simply download the library hosted on npm using the command:
$ npm i @bancame/widget-js
- TypeScript
./your-typescript-component.ts
import { getBancameWidget } from '@bancame/widget-js'
const BancameWidget = await getBancameWidget();
const otherParams = { ... };
const params = { widgetToken, publicKey ...otherParams };
const widget = BancameWidget.create(params);
Where widgetToken is obtained from this endpoint.
Simple HTML Integration​
HTML
<script type="module">
import "https://js.banca.me/";
const authWidget = window.BancameWidget;
const onSuccess = (event) => {
console.log("SUCCESS: ", event);
};
const onError = (event) => {
console.log("ERROR: ", event);
};
const onEvent = (event) => {
console.log("EVENT: ", event);
};
const onReject = (event) => {
console.log("REJECT: ", event);
};
const widgetToken = "obtain-widgetToken-from-endpoints";
const publicKey = "obtain-publicKey-from-us";
const widget = authWidget.create({
widgetToken,
onSuccess,
onError,
onEvent,
onReject,
buttonMode: "hidden", // "light" | "dark" | "hidden" , required
publicKey,
widgetProps: {
hideCloseButton: false,
autoCloseOnSuccess: false,
autoCloseOnRejection: false,
}
});
widget.open(); // In order to open the widget programatically
</script>
window.onload
Remember that when importing a JavaScript script, if you try to use functions before the browser loads the script, an error will be generated.
You can solve this by using the browser's native window.onload event