Código: Selecionar todos
************************************************************************************************************************************************************************************************************************
METHOD Pix_String( ) CLASS PIXClass
************************************************************************************************************************************************************************************************************************
LOCAL cString
cString := ""
cString += get_p_value('00', '01')
// cString += get_p_value('01', '11')
cString += get_p_account_information(::cPIX_KEY, ::cPIX_RECEIVER, ::pix_url)
cString += get_p_value('52', '0000')
cString += get_p_value('53', '986')
cString += get_p_value('54', ::nPIX_AMOUNT)
cString += get_p_value('58', 'BR')
cString += get_p_value('59', SUBSTR(::cPIX_DESCRIPTION,1,25))
cString += get_p_value('60', ::cPIX_CITY)
** cString += get_p_value('61', '')
cString += get_p_additional_data_field(::cPIX_IDENTIFICATION)
cString += "6304"
cString += hb_numtohex(hb_crcct(cString, 0xFFFF, 0x11021))
::qrcode := cString
return Nil
************************************************************************************************************************************************************************************************************************
STATIC function get_p_value(identify, value)
************************************************************************************************************************************************************************************************************************
Value := AllTrim( Value )
return identify + StrZero( Len( value ), 2 ) + value
//return trim(identify + strzero(len(alltrim(value)), 2) + value)
************************************************************************************************************************************************************************************************************************
STATIC function get_p_account_information(key, description, url)
************************************************************************************************************************************************************************************************************************
Local base_pix := get_p_value('00', 'br.gov.bcb.pix')
Local info_string := ''
if key != Nil
info_string += get_p_value('01', key)
elseif url != Nil
info_string += get_p_value('25', url)
endif
info_string += get_p_value('02', description)
return get_p_value('26', base_pix + info_string)
************************************************************************************************************************************************************************************************************************
STATIC function get_p_additional_data_field(identification)
************************************************************************************************************************************************************************************************************************
if identification != Nil
return get_p_value('62', get_p_value('05', identification))
endif
return get_p_value('62', get_p_value('05', '***'))
************************************************************************************************************************************************************************************************************************
FUNCTION create_Txid( )
************************************************************************************************************************************************************************************************************************
Local cRetorno:="";
, nCont;
, equivalente:= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',;
'0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',;
'Z','0','1','2','3','4','5','6','7','8','9'}
For nCont:=1 to 32
cRetorno += equivalente[HB_RandomInt(1, 62)]
next
return cRetorno
******************************************************************************************************************************
METHOD PDF_QRCode( ) CLASS PIXClass
******************************************************************************************************************************
LOCAL h1, iPDF, sPDF, hPDF, cFileName;
h1:=::qrcodeImage
iPDF:= Array( 1, 1 )
iPDF[1, 1] := h1
sPDF:= hb_base64Decode( iPDF[1, 1] )
cFileName:="C:\filesold\report\PIX_" + strzero(HB_RandomInt(1, 99999999),8,0) +'.PDF'
hPDF := FCreate(cFileName, 0)
FWrite(hPDF, sPDF)
FClose(hPDF)
WAPI_ShellExecute( NIL, "OPEN", cFileName ,"",NIL,5 )
RETURN Nil
************************************************************************************************************************************************************************************************************************
METHOD PrintQRCode( ) CLASS PIXClass
************************************************************************************************************************************************************************************************************************
LOCAL oPDF;
// , nTamValor;
if ::erro_status = WS_OK
oPDF := PDFClass()
IF oPDF == NIL
hwg_msginfo("Falha da criação do objeto PDF","ATENÇÃO!!!")
RETURN .F.
ENDIF
oPDF:cFileName := ::cFileName
oPDF:SetType( PDFCLASS_ROLLS )
oPDF:nPageHeight := 150
oPDF:Begin()
oPDF:AddPage()
// nTamValor := (38 - (len("Valor do PIX: " + LTRIM(TRANSFORM(::nPIX_AMOUNT,"@E 999,999,999.99" ))))) /2
oPDF:DrawText( 0 , 8, "Leia o QR Code Pix e pague" , Nil, 8, "Helvetica-Bold", Nil, Nil )
oPDF:DrawText( 0.7, 5, "utilizando o aplicativo do seu banco." , Nil, 8, "Helvetica-Bold", Nil, Nil )
oPDF:DrawBarcodeQRCode( 1, 4.5, 0.22, ::qrcode )
oPDF:DrawText( 11.3 , 30, ::cPDF_Linha1, Nil, 6, "Helvetica-Bold", 90, Nil )
oPDF:DrawText( 11.3 , 31 , ::cPDF_Linha2, Nil, 6, "Helvetica-Bold", 90, Nil )
oPDF:DrawText( 11.3 , 32 , "PIX: R$ " + LTRIM(TRANSFORM(VAL(::nPIX_AMOUNT),"@E 999,999,999.99" )), Nil, 6, "Helvetica-Bold", 90, Nil )
// oPDF:DrawLine( 10, 0, 10, 38, 3 )
oPDF:End( )
oPDF:PrintPreview( )
ENDIF
RETURN NIL