diff --git a/src/stores/tpv.js b/src/stores/tpv.js index 4bf2e252..e9312a52 100644 --- a/src/stores/tpv.js +++ b/src/stores/tpv.js @@ -4,19 +4,19 @@ import { api } from 'boot/axios'; export const tpvStore = defineStore('tpv', { actions: { async check(route) { - const order = route.query.tpvOrder; + const orderId = route.query.tpvOrder; const status = route.query.tpvStatus; - if (!(order && status)) return null; + if (!(orderId && status)) return null; await api.post('tpvTransactions/end', { - orderId: order, - status: status + orderId, + status }); if (status === 'ko') { const retry = confirm('retryPayQuestion'); if (retry) { - this.retryPay(order); + this.retryPay(orderId); } } @@ -27,17 +27,17 @@ export const tpvStore = defineStore('tpv', { await this.realPay(amount * 100, company); }, - async retryPay(order) { + async retryPay(orderId) { const { data: transactions } = await api.get( 'clients/transactions', { params: { - orderFk: order + orderFk: orderId } } ); if (transactions && transactions.length > 0) { - const transaction = transactions[0]; + const [transaction] = transactions; await this.realPay( transaction.amount * 100, transaction.merchantFk @@ -45,15 +45,15 @@ export const tpvStore = defineStore('tpv', { } }, - async realPay(amount, company) { + async realPay(amount, companyId) { if (!isNumeric(amount) || amount <= 0) { throw new Error('payAmountError'); } const { data: json } = await api.post('tpvTransactions/start', { - amount: amount, + amount, + companyId, urlOk: this.makeUrl('ok'), - urlKo: this.makeUrl('ko'), - companyId: company + urlKo: this.makeUrl('ko') }); const postValues = json.postValues;