)
}
const FeeInfoElement = () => {
let info: string
if (LKN_SLIP_FEE === '1') {
info = LKN_SLIP_INFO
} else {
info = ''
}
return (
{info}
)
}
const LknBolGateway = {
id: 'lkn-pgpf-give-paghiper-slip',
// The function that runs when form is opened.
async initialize() {
// Function to remove event bubling on value buttons.
document.addEventListener('DOMContentLoaded', () => {
const inputCustomAmount = document.querySelectorAll('.givewp-fields-amount__level')
const emptyEvent = (event) => {
}
for (let i = 0; i < inputCustomAmount.length; i++) {
inputCustomAmount[i].removeEventListener('click', emptyEvent, false)
inputCustomAmount[i].addEventListener('click', emptyEvent, false)
}
})
},
// The function that runs when form is submited but not completed.
async beforeCreatePayment(values) {
const cpfCnpjField = document.querySelectorAll('#lkn_pgpf_give_paghiper_primary_document')[0]
const cpfCnpj = cpfCnpjField.value
values.cpfCnpj = cpfCnpj
// Example of validation.
if (values.firstName === 'error') {
throw new Error('Gateway failed')
}
return {
'lkn_give_primary_document': cpfCnpj
}
},
// The function that runs when form is submited, completed, but before show the payment proof.
async afterCreatePayment(response) {
},
// Function that handle the HTML form elements.
Fields() {
const BolFeeInfo = React.createElement(FeeInfoElement)
const PrimaryDocumentInput = React.createElement(lknSlipElementWithTooltip, {
title: LKN_SLIP_CPF_CNPJ_TOOLTIP,
tooltipClass: 'lkn_cpf_cnpj_tooltip',
margin: '-45px',
})
return (
)
}
}
window.givewp.gateways.register(LknBolGateway)
})()