// If you need to look up data when opening the page, list it out
// under "resolve".
resolve:{
processors:function(crmApi4){
returncrmApi4('PaymentProcessor','get',{
select:["id","MIN(name) AS processorName","MIN(payment_processor_type_id:label) AS processorType","MIN(is_test) AS isTest","COUNT(paymentprocessor_webhook.id) AS webhooksCount"],
join:[["PaymentprocessorWebhook AS paymentprocessor_webhook","LEFT",["id","=","paymentprocessor_webhook.payment_processor_id"]]],
if (!confirm(ts("Deleting a received webhook event is not un-do-able, and you may not be able to generate it again. Are you sure?"))){
return;
}
})
);
};
this.changePage=function(dir){
letnewOffset=Math.min(
Math.max(ctrl.offset+dir*ctrl.limit,0),
ctrl.resultsCount-1
);
// console.log({newOffset, o: ctrl.offset, dir});
if (newOffset!=ctrl.offset){
ctrl.offset=newOffset;
ctrl.load();
}
};
this.delete=function(id){
if (!(parseInt(id)>0))return;
if (
!confirm(
ts(
"Deleting a received webhook event is not un-do-able, and you may not be able to generate it again. Are you sure?"
)
)
){
return;
}
returncrmStatus(
{start:ts('Deleting...'),success:ts('Gone')},
crmApi4('PaymentprocessorWebhook','delete',{
where:[['id','=',id]],
limit:1
}))
.then(r=>{
returncrmStatus(
{start:ts("Deleting..."),success:ts("Gone")},
crmApi4("PaymentprocessorWebhook","delete",{
where:[["id","=",id]],
limit:1
})
).then(r=>{
// Reload the page.
returnctrl.load();
});
};
this.retry=function(id){
if (!(parseInt(id)>0))return;
if (!confirm(ts("Retrying an event could cause bad things to happen, depending on the event and the processor, so please be confident in your understanding of both. Schedule retry of this event?"))){
return;
}
};
this.retry=function(id){
if (!(parseInt(id)>0))return;
if (
!confirm(
ts(
"Retrying an event could cause bad things to happen, depending on the event and the processor, so please be confident in your understanding of both. Schedule retry of this event?"
)
)
){
return;
}
returncrmStatus(
// Status messages. For defaults, just use "{}"
{start:ts('Updating...'),success:ts('Updated')},
crmApi4('PaymentprocessorWebhook','update',{
where:[['id','=',id]],
values:{status:'new',processed_date:null,message:ts('Scheduled for retry')},