diff --git a/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html b/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html index b4e4c7c..d7d1c3e 100644 --- a/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html +++ b/src/app/components/confirmacion-carrito/confirmacion-carrito.component.html @@ -156,7 +156,7 @@
+ (click)="pagar(1)">
Efectivo
@@ -182,7 +182,7 @@
+ (click)="pagar(9)">
Pago Electrónico
diff --git a/src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts b/src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts index d323526..1ced8fa 100644 --- a/src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts +++ b/src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts @@ -75,34 +75,37 @@ export class ConfirmacionCarritoComponent implements OnInit, OnDestroy { } //#region METODOS PARA LA FORMA DE PAGO - pagar(medioPago: string) { + pagar(medioPago: number) { - if (medioPago == 'electronico') { + if (medioPago === 9) { this.verQR = true; } - this.subscribePago = this.productoService.pagar(medioPago) - .subscribe(() => { + this.productoService.getClienteById(-1) + .subscribe(cliente => { + this.subscribePago = this.productoService.pagar(medioPago, cliente) + .subscribe(() => { - clearTimeout(this.timerReposo); + clearTimeout(this.timerReposo); - if (medioPago == 'efectivo') { + if (medioPago === 1) { - this.compraConEfectivofinalizada = true; - } else if (medioPago == 'electronico') { + this.compraConEfectivofinalizada = true; + } else if (medioPago === 9) { - this.compraConQRfinalizada = true; - } + this.compraConQRfinalizada = true; + } - setTimeout(() => { + setTimeout(() => { - this.router.navigate(['mensaje-final']); - }, 10000); - }, err => { - console.log(err); - alert('algo salió mal'); - }) + this.router.navigate(['mensaje-final']); + }, 10000); + }, err => { + console.log(err); + alert('algo salió mal'); + }) + }, console.error) } //#endregion diff --git a/src/app/services/producto.service.ts b/src/app/services/producto.service.ts index c825683..3702c2f 100644 --- a/src/app/services/producto.service.ts +++ b/src/app/services/producto.service.ts @@ -79,9 +79,18 @@ export class ProductoService { return this.http.get(`${appSettings.apiUrl}/categorias`); } - pagar(medioPago: string) { + getClienteById(id: number = -1): Observable { + + let apiClientes = 'http://10.231.45.220:1515/clientes'; + return this.http.get(`${apiClientes}/get/${id}`); + } + + pagar(medioPago: number, cliente: any) { + return this.http.post(`${appSettings.apiUrl}/comprobante/guardar/${medioPago}`, { - productos: this.productos + productos: this.productos, + cliente: cliente, + origen: 'autoservicio', }); }