Skip to content

Commit

Permalink
refactor: Change gateway var name to prevent collision
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuellopess committed May 7, 2024
1 parent 303fbe9 commit 372ca10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions includes/js/lkn-pix.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {
__
} = wp.i18n
function lknPaymentGatewayPixGiveWPCrcChecksum (string) {
function lknPaymentGatewayPixGiveWPCrcChecksum(string) {
let crc = 0xFFFF
const strlen = string.length
for (let c = 0; c < strlen; c++) {
Expand All @@ -21,7 +21,7 @@ function lknPaymentGatewayPixGiveWPCrcChecksum (string) {
hex = parseInt(hex, 10).toString(16).toUpperCase().padStart(4, '0')
return hex
}
function lknPaymentGatewayPixGiveWPPixBuilder (amount = '') {
function lknPaymentGatewayPixGiveWPPixBuilder(amount = '') {
const pixType = lknAttr.pixType
const pixKey = lknAttr.pixKey
const pixName = lknAttr.pixName
Expand Down Expand Up @@ -94,12 +94,12 @@ function lknPaymentGatewayPixGiveWPPixBuilder (amount = '') {
qr += lknPaymentGatewayPixGiveWPCrcChecksum(qr)
return qr
}
const gateway = {
const lknGatewayPix = {
id: 'pix-payment-gateway',
async initialize () {
async initialize() {
// Aqui vai todas as funções necessárias ao carregar a página de pagamento
},
async beforeCreatePayment (values) {
async beforeCreatePayment(values) {
// Aqui vai tudo que precisa rodar depois de submeter o formulário e antes do pagamento ser completado
// Ponha validações e adicione atributos que você vai precisar no back-end aqui

Expand All @@ -116,12 +116,12 @@ const gateway = {
pluginIntent: 'lkn-plugin-intent'
}
},
async afterCreatePayment (response) {
async afterCreatePayment(response) {
// Aqui roda tudo que você precisa após o formulário ser submetido
// Antes de ir para a tela do comprovante de pagamento
},
// Função onde os campos HTML são criados
Fields () {
Fields() {
const {
useWatch
} = window.givewp.form.hooks
Expand Down Expand Up @@ -207,4 +207,5 @@ const gateway = {
}, 'content_copy'))))))
}
}
window.givewp.gateways.register(gateway)
window.givewp.gateways.register(lknGatewayPix)
export { }
4 changes: 2 additions & 2 deletions includes/js/lkn-pix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function lknPaymentGatewayPixGiveWPPixBuilder(amount = '') {
return qr
}

const gateway = {
const lknGatewayPix = {
id: 'pix-payment-gateway',
async initialize() {
// Aqui vai todas as funções necessárias ao carregar a página de pagamento
Expand Down Expand Up @@ -168,4 +168,4 @@ const gateway = {
}
};

window.givewp.gateways.register(gateway);
window.givewp.gateways.register(lknGatewayPix);

0 comments on commit 372ca10

Please sign in to comment.