|
|
@@ -34,6 +34,16 @@
|
|
|
</i18n-t>
|
|
|
</div>
|
|
|
|
|
|
+ <div v-else-if="processing" class="col column items-center justify-center q-px-xl">
|
|
|
+ <q-spinner-oval color="primary" size="72px" class="q-mb-lg" />
|
|
|
+ <div class="processing-title text-primary text-weight-bold text-center q-mb-sm">
|
|
|
+ {{ $t('payment.processing_title') }}
|
|
|
+ </div>
|
|
|
+ <div class="processing-message text-grey-6 text-center">
|
|
|
+ {{ $t('payment.processing_message') }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
<div v-else class="col scroll q-px-lg q-pt-lg q-pb-xl column">
|
|
|
|
|
|
<div class="row items-center justify-between q-mb-sm">
|
|
|
@@ -52,74 +62,20 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="flex flex-center q-mb-md">
|
|
|
- <div class="qrcode-wrapper">
|
|
|
- <svg viewBox="0 0 200 200" width="180" height="180" xmlns="http://www.w3.org/2000/svg">
|
|
|
- <rect x="10" y="10" width="60" height="60" rx="4" fill="none" stroke="#000" stroke-width="6"/>
|
|
|
- <rect x="22" y="22" width="36" height="36" rx="2" fill="#000"/>
|
|
|
- <rect x="130" y="10" width="60" height="60" rx="4" fill="none" stroke="#000" stroke-width="6"/>
|
|
|
- <rect x="142" y="22" width="36" height="36" rx="2" fill="#000"/>
|
|
|
- <rect x="10" y="130" width="60" height="60" rx="4" fill="none" stroke="#000" stroke-width="6"/>
|
|
|
- <rect x="22" y="142" width="36" height="36" rx="2" fill="#000"/>
|
|
|
- <g fill="#000">
|
|
|
- <rect x="85" y="10" width="8" height="8"/>
|
|
|
- <rect x="100" y="10" width="8" height="8"/>
|
|
|
- <rect x="85" y="24" width="8" height="8"/>
|
|
|
- <rect x="108" y="24" width="8" height="8"/>
|
|
|
- <rect x="85" y="38" width="16" height="8"/>
|
|
|
- <rect x="85" y="52" width="8" height="8"/>
|
|
|
- <rect x="100" y="52" width="16" height="8"/>
|
|
|
- <rect x="10" y="85" width="8" height="8"/>
|
|
|
- <rect x="24" y="85" width="16" height="8"/>
|
|
|
- <rect x="48" y="85" width="8" height="8"/>
|
|
|
- <rect x="62" y="85" width="8" height="8"/>
|
|
|
- <rect x="10" y="99" width="16" height="8"/>
|
|
|
- <rect x="34" y="99" width="8" height="8"/>
|
|
|
- <rect x="54" y="99" width="16" height="8"/>
|
|
|
- <rect x="10" y="113" width="8" height="8"/>
|
|
|
- <rect x="26" y="113" width="16" height="8"/>
|
|
|
- <rect x="56" y="113" width="8" height="8"/>
|
|
|
- <rect x="85" y="85" width="8" height="8"/>
|
|
|
- <rect x="100" y="85" width="16" height="8"/>
|
|
|
- <rect x="124" y="85" width="8" height="8"/>
|
|
|
- <rect x="140" y="85" width="16" height="8"/>
|
|
|
- <rect x="166" y="85" width="8" height="8"/>
|
|
|
- <rect x="85" y="100" width="16" height="8"/>
|
|
|
- <rect x="108" y="100" width="8" height="8"/>
|
|
|
- <rect x="130" y="100" width="16" height="8"/>
|
|
|
- <rect x="154" y="100" width="8" height="8"/>
|
|
|
- <rect x="170" y="100" width="8" height="8"/>
|
|
|
- <rect x="85" y="115" width="8" height="8"/>
|
|
|
- <rect x="100" y="115" width="8" height="8"/>
|
|
|
- <rect x="116" y="115" width="16" height="8"/>
|
|
|
- <rect x="140" y="115" width="8" height="8"/>
|
|
|
- <rect x="156" y="115" width="16" height="8"/>
|
|
|
- <rect x="85" y="130" width="16" height="8"/>
|
|
|
- <rect x="108" y="130" width="8" height="8"/>
|
|
|
- <rect x="124" y="130" width="16" height="8"/>
|
|
|
- <rect x="148" y="130" width="8" height="8"/>
|
|
|
- <rect x="164" y="130" width="8" height="8"/>
|
|
|
- <rect x="85" y="144" width="8" height="8"/>
|
|
|
- <rect x="100" y="144" width="16" height="8"/>
|
|
|
- <rect x="124" y="144" width="8" height="8"/>
|
|
|
- <rect x="140" y="144" width="16" height="8"/>
|
|
|
- <rect x="166" y="144" width="8" height="8"/>
|
|
|
- <rect x="85" y="158" width="16" height="8"/>
|
|
|
- <rect x="110" y="158" width="8" height="8"/>
|
|
|
- <rect x="126" y="158" width="8" height="8"/>
|
|
|
- <rect x="144" y="158" width="8" height="8"/>
|
|
|
- <rect x="160" y="158" width="16" height="8"/>
|
|
|
- <rect x="85" y="172" width="8" height="8"/>
|
|
|
- <rect x="100" y="172" width="8" height="8"/>
|
|
|
- <rect x="116" y="172" width="16" height="8"/>
|
|
|
- <rect x="142" y="172" width="8" height="8"/>
|
|
|
- <rect x="158" y="172" width="8" height="8"/>
|
|
|
- <rect x="174" y="172" width="8" height="8"/>
|
|
|
- </g>
|
|
|
- </svg>
|
|
|
+ <q-img
|
|
|
+ v-if="pixQrCodeUrl"
|
|
|
+ :src="pixQrCodeUrl"
|
|
|
+ width="180px"
|
|
|
+ height="180px"
|
|
|
+ fit="contain"
|
|
|
+ class="qrcode-wrapper"
|
|
|
+ />
|
|
|
+ <div v-else class="qrcode-wrapper column items-center justify-center">
|
|
|
+ <q-icon name="mdi-qrcode" size="80px" color="grey-6" />
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="pix-code-text q-mb-md">{{ pixCode }}</div>
|
|
|
+ <div class="pix-code-text q-mb-md">{{ pixCode || 'Código Pix indisponível.' }}</div>
|
|
|
|
|
|
<q-btn
|
|
|
unelevated
|
|
|
@@ -145,10 +101,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted, onUnmounted } from 'vue'
|
|
|
+import { computed, ref, onMounted, onUnmounted } from 'vue'
|
|
|
import { useDialogPluginComponent, useQuasar, copyToClipboard } from 'quasar'
|
|
|
import { formatCurrency } from 'src/helpers/utils'
|
|
|
-import { updateScheduleStatus } from 'src/api/schedule'
|
|
|
+import { paySchedule } from 'src/api/payment'
|
|
|
|
|
|
const props = defineProps({
|
|
|
schedule: { type: Object, required: true },
|
|
|
@@ -160,30 +116,28 @@ defineEmits([...useDialogPluginComponent.emits])
|
|
|
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
|
|
|
const $q = useQuasar()
|
|
|
|
|
|
-const pixCode = `00020126580014br.gov.bcb.pix0136sfp-diaria-${props.schedule.id}-${props.schedule.provider_id}5204000053039865406${(props.total * 100).toFixed(0).padStart(8, '0')}5802BR5913Diaria App6009SAO PAULO62070503***6304ABCD`
|
|
|
-
|
|
|
+const payment = ref(null)
|
|
|
const success = ref(false)
|
|
|
-const processing = ref(false)
|
|
|
+const processing = ref(true)
|
|
|
+
|
|
|
+const pixTransaction = computed(() => payment.value?.gateway_payload?.charges?.[0]?.last_transaction ?? {})
|
|
|
+const pixCode = computed(() => pixTransaction.value?.qr_code ?? pixTransaction.value?.qr_code_text ?? '')
|
|
|
+const pixQrCodeUrl = computed(() => pixTransaction.value?.qr_code_url ?? '')
|
|
|
|
|
|
const copyCode = async () => {
|
|
|
try {
|
|
|
- await copyToClipboard(pixCode)
|
|
|
+ if (!pixCode.value) {
|
|
|
+ $q.notify({ type: 'negative', message: 'Código Pix indisponível.' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ await copyToClipboard(pixCode.value)
|
|
|
$q.notify({ type: 'positive', message: 'Código copiado!' })
|
|
|
} catch {
|
|
|
$q.notify({ type: 'negative', message: 'Erro ao copiar.' })
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- processing.value = true
|
|
|
- try {
|
|
|
- await updateScheduleStatus(props.schedule.id, 'paid')
|
|
|
- } catch (e) {
|
|
|
- console.error('Erro ao atualizar status:', e)
|
|
|
- } finally {
|
|
|
- processing.value = false
|
|
|
- }
|
|
|
- success.value = true
|
|
|
- setTimeout(() => onDialogOK(), 3000)
|
|
|
}
|
|
|
|
|
|
const totalSeconds = ref(20 * 60)
|
|
|
@@ -197,9 +151,19 @@ const updateCountdown = () => {
|
|
|
if (totalSeconds.value > 0) totalSeconds.value--
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
+onMounted(async () => {
|
|
|
updateCountdown()
|
|
|
timer = setInterval(updateCountdown, 1000)
|
|
|
+
|
|
|
+ try {
|
|
|
+ payment.value = await paySchedule(props.schedule.id, { payment_method: 'pix' })
|
|
|
+ } catch (e) {
|
|
|
+ console.error('Erro ao criar pagamento Pix:', e)
|
|
|
+ $q.notify({ type: 'negative', message: e?.response?.data?.message ?? 'Erro ao criar pagamento Pix.' })
|
|
|
+ onDialogCancel()
|
|
|
+ } finally {
|
|
|
+ processing.value = false
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|