| Linux hosting5.siteguarding.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64 Path : /home/devsafetybis/verd.dev.safetybis.com/js/brippopayments/ |
| Current File : /home/devsafetybis/verd.dev.safetybis.com/js/brippopayments/stripe-connect-admin.js |
var BrippoStripeConnect = Class.create();
BrippoStripeConnect.prototype = {
initialize: function () {
if ($('brippoBtnOpenPreonboarding')) {
Event.observe($("brippoBtnOpenPreonboarding"), 'click', this.openPreOnboarding.bind(this));
Event.observe($("brippoBtnOpenPreonboarding"), 'initializeOauth', this.initializeOauth.bind(this));
} else if ($('brippoBtnStripeOnboarding')) {
Event.observe($("brippoBtnStripeOnboarding"), 'click', this.initializeStripeConnectOnboarding.bind(this));
}
if ($('brippoBtnReset')) {
Event.observe($("brippoBtnReset"), 'click', this.reset.bind(this));
}
},
isLiveMode: function () {
return (document.getElementById("brippoAccountMode").value === "live");
},
openPreOnboarding: function () {
const self = this;
let livemode = this.isLiveMode();
let content = document.getElementById("brippoOnboardingModal").innerHTML;
if ($('preonboarding_browser_window') && typeof(Windows) != 'undefined') {
Windows.focus('preonboarding_browser_window');
return;
}
var dialogWindow = Dialog.info(content, {
closable:true,
resizable:false,
draggable:false,
className:'magento',
windowClassName:'popup-window',
title: Translator.translate('Create account'),
top:50,
width:450,
// height:auto,
zIndex:1000,
recenterAuto:true,
hideEffect:Element.hide,
showEffect:Element.show,
id:'preonboarding_browser_window',
// url:url,
onClose:function (param, el) {
// alert('onClose');
},
onBeforeShow: function (win) {
},
onShow:function () {
document.getElementById('brippoOnboardingInputEmail').value = BRIPPO_PREFILLED_EMAIL;
document.getElementById('brippoOnboardingInputUrl').value = BRIPPO_PREFILLED_URL;
Event.observe(
document.getElementById("btnInitializeOauth"),
'click',
function () {
document.getElementById("brippoBtnOpenPreonboarding").dispatchEvent(new Event('initializeOauth',{'bubbles': true}));
}
);
}
});
},
initializeOauth: function () {
let livemode = this.isLiveMode();
let self = this;
var btnOauth = $('btnInitializeOauth');
btnOauth.disabled = true;
let url = BRIPPO_OAUTH_URL;
new Ajax.Request(
url,
{
method: 'get',
parameters: {
mode: document.getElementById("brippoAccountMode").value,
scope: BRIPPO_SCOPE,
scopeId: BRIPPO_SCOPE_ID,
email: document.getElementById('brippoOnboardingInputEmail').value,
url: document.getElementById('brippoOnboardingInputUrl').value
},
onComplete: function (transport) {
try {
let json = transport.responseText.evalJSON();
btnOauth.disabled = false;
if (!json.error && json.valid === 1) {
location.href = json.url;
} else {
self.showCommonErrorMessage();
}
} catch (e) {
console.log(e)
self.showCommonErrorMessage();
}
}
}
);
},
initializeStripeConnectOnboarding: function () {
var brippoBtnStripeOnboarding = $('brippoBtnStripeOnboarding');
brippoBtnStripeOnboarding.disabled = true;
let self = this;
let url = BRIPPO_ACCOUNT_LINK_URL;
new Ajax.Request(
url,
{
method: 'get',
parameters: {
mode: document.getElementById("brippoAccountMode").value,
scope: BRIPPO_SCOPE,
scopeId: BRIPPO_SCOPE_ID,
},
onComplete: function (transport) {
try {
let json = transport.responseText.evalJSON();
brippoBtnStripeOnboarding.disabled = false;
if (!json.error && json.valid === 1) {
location.href = json.url;
} else {
self.showCommonErrorMessage();
}
} catch (e) {
console.log(e);
self.showCommonErrorMessage();
}
}
}
);
},
reset: function () {
let livemode = this.isLiveMode();
let self = this;
if (confirm(Translator.translate('Are you sure you want to reset this connected account?'))) {
let url = BRIPPO_RESET_ACCOUNT_URL;
new Ajax.Request(
url,
{
method: 'get',
parameters: { mode: document.getElementById("brippoAccountMode").value, scope: BRIPPO_SCOPE, scopeId: BRIPPO_SCOPE_ID},
onComplete: function (transport) {
try {
let json = transport.responseText.evalJSON();
if (!json.error && json.valid === 1) {
location.reload();
} else {
self.showCommonErrorMessage();
}
} catch (e) {
console.log(e);
self.showCommonErrorMessage();
}
},
}
);
} else {
}
},
showError: function (message) {
alert("Error: "+ message);
},
showCommonErrorMessage: function () {
this.showError("Invalid response from server");
}
};
Event.observe(
window,
'load',
function () {
new BrippoStripeConnect();
}
);