Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
12| Name | Data Type | Length | Description |
|---|---|---|---|
| @accion | varchar | 500 | |
| @contraparte | int | 4 | |
| @status | varchar | 100 | |
| @transact_id | int | 4 | |
| @merchant_id | bigint | 8 | |
| @preference_id | varchar | 200 | |
| @payment_id | bigint | 8 | |
| @motivo | varchar | 500 | |
| @vigencia | datetime | 8 | |
| @fecha_transaccion | datetime | 8 | |
| @facturado | bit | 1 | |
| @fecha_facturado | datetime | 8 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Leonel Turchetto>
-- Create date: <24 de Octubre de 2019>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.pagos_productos
--$cliente,$contraparte,$merchant_order_id,$preference_id,$payment_id,$payment_status
@accion varchar(500),
@contraparte int,
@status varchar(100) = null,
@transact_id int = null,
@merchant_id bigint = null,
@preference_id varchar(200) = null,
@payment_id bigint = null,
@motivo varchar(500) = null,
@vigencia datetime=null,
@fecha_transaccion datetime=null,
@facturado bit=0,
@fecha_facturado datetime=null
AS
BEGIN
SET NOCOUNT ON;
if(@accion = 'obtener_productos_activos')
begin
if(@transact_id is not null)
begin
select cpp.descripcion,cpp.nombre,plataforma_pago,producto,pagos_transacciones.valor,pagos_transacciones.moneda,transact_id
from pagos_transacciones
inner join clientes_productos_pagos cpp
on cpp.id_pago =pagos_transacciones.id_pago
where pagos_transacciones.contraparte = @contraparte and pagos_transacciones.vigencia > getdate() and pagos_transacciones.status != 'approved'
and transact_id = @transact_id
end
else
begin
select cpp.descripcion,cpp.nombre,plataforma_pago,producto,pagos_transacciones.valor,pagos_transacciones.moneda,transact_id
from pagos_transacciones
inner join clientes_productos_pagos cpp
on cpp.id_pago =pagos_transacciones.id_pago
where pagos_transacciones.contraparte = @contraparte and pagos_transacciones.vigencia > getdate() and pagos_transacciones.status != 'approved'
end
end
if(@accion = 'agregar_pago_transaccion_contraparte')
begin
if((select count(*) from pagos_transacciones where merchant_id = @merchant_id ) = 0)
update pagos_transacciones
set
status=@status,
fecha_transaccion=getdate(),
fecha_confirmacion=getdate(),
motivo=@motivo,
preference_id=@preference_id,
payment_id=@payment_id
where
transact_id = @transact_id
end
if (@accion = 'actualizar_datos_pago') begin
if (@transact_id > 0 AND @contraparte > 0) begin
DECLARE @status_ant varchar(100)
DECLARE @cliente int
select @status_ant = status from pagos_transacciones where transact_id = @transact_id
select @cliente = cliente from LN_contrapartes where contraparte = @contraparte
update pagos_transacciones set
status = @status,
preference_id = @preference_id,
motivo = @motivo,
vigencia = @vigencia,
fecha_transaccion = @fecha_transaccion,
fecha_confirmacion = @fecha_transaccion,
facturado = @facturado,
fecha_facturado = @fecha_facturado
where transact_id = @transact_id
if (@status = 'approved' AND @status_ant <> @status) begin
exec insertar_trazabilidad 'Ingreso de pago de contraparte',@cliente,'PAGO_CONTRAPARTE','LEGAJOS',@contraparte
end
end
end
END
GO
GO
-- =============================================
-- Author: <Leonel Turchetto>
-- Create date: <24 de Octubre de 2019>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.pagos_productos
--$cliente,$contraparte,$merchant_order_id,$preference_id,$payment_id,$payment_status
@accion varchar(500),
@contraparte int,
@status varchar(100) = null,
@transact_id int = null,
@merchant_id bigint = null,
@preference_id varchar(200) = null,
@payment_id bigint = null,
@motivo varchar(500) = null,
@vigencia datetime=null,
@fecha_transaccion datetime=null,
@facturado bit=0,
@fecha_facturado datetime=null
AS
BEGIN
SET NOCOUNT ON;
if(@accion = 'obtener_productos_activos')
begin
if(@transact_id is not null)
begin
select cpp.descripcion,cpp.nombre,plataforma_pago,producto,pagos_transacciones.valor,pagos_transacciones.moneda,transact_id
from pagos_transacciones
inner join clientes_productos_pagos cpp
on cpp.id_pago =pagos_transacciones.id_pago
where pagos_transacciones.contraparte = @contraparte and pagos_transacciones.vigencia > getdate() and pagos_transacciones.status != 'approved'
and transact_id = @transact_id
end
else
begin
select cpp.descripcion,cpp.nombre,plataforma_pago,producto,pagos_transacciones.valor,pagos_transacciones.moneda,transact_id
from pagos_transacciones
inner join clientes_productos_pagos cpp
on cpp.id_pago =pagos_transacciones.id_pago
where pagos_transacciones.contraparte = @contraparte and pagos_transacciones.vigencia > getdate() and pagos_transacciones.status != 'approved'
end
end
if(@accion = 'agregar_pago_transaccion_contraparte')
begin
if((select count(*) from pagos_transacciones where merchant_id = @merchant_id ) = 0)
update pagos_transacciones
set
status=@status,
fecha_transaccion=getdate(),
fecha_confirmacion=getdate(),
motivo=@motivo,
preference_id=@preference_id,
payment_id=@payment_id
where
transact_id = @transact_id
end
if (@accion = 'actualizar_datos_pago') begin
if (@transact_id > 0 AND @contraparte > 0) begin
DECLARE @status_ant varchar(100)
DECLARE @cliente int
select @status_ant = status from pagos_transacciones where transact_id = @transact_id
select @cliente = cliente from LN_contrapartes where contraparte = @contraparte
update pagos_transacciones set
status = @status,
preference_id = @preference_id,
motivo = @motivo,
vigencia = @vigencia,
fecha_transaccion = @fecha_transaccion,
fecha_confirmacion = @fecha_transaccion,
facturado = @facturado,
fecha_facturado = @fecha_facturado
where transact_id = @transact_id
if (@status = 'approved' AND @status_ant <> @status) begin
exec insertar_trazabilidad 'Ingreso de pago de contraparte',@cliente,'PAGO_CONTRAPARTE','LEGAJOS',@contraparte
end
end
end
END
GO
Depends On
4Used By
No items found