github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/citibank/request.go (about)

     1  package citibank
     2  
     3  const responseCiti = `
     4  <?xml version="1.0" encoding="UTF-8"?>
     5  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s1="http://www.citibank.com.br/comercioeletronico/registerboleto">
     6      <soap:Body>
     7          <s1:RegisterBoletoResponse>
     8              <actionCode>{{returnCode}}</actionCode>
     9              <reasonMessage>{{returnMessage}}</reasonMessage>
    10              <TitlBarCd>{{barcodeNumber}}</TitlBarCd>
    11              <TitlDgtLine>{{digitableLine}}</TitlDgtLine>
    12          </s1:RegisterBoletoResponse>
    13      </soap:Body>
    14  </soap:Envelope>
    15  `
    16  
    17  const registerBoletoCiti = `
    18  
    19  ## SOAPAction:RegisterBoleto
    20  ## Content-Type:text/xml
    21  
    22  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    23     <soapenv:Header/>
    24     <soapenv:Body>
    25        <GrpREMColTit>
    26           <GrpBenf>
    27              <CdClrSys>745</CdClrSys>
    28              <CdIspb>33479023</CdIspb>
    29              <CdtrId>{{.Authentication.Username}}</CdtrId>
    30              <CdtrNm>{{truncateOnly (sanitizeCitibankSpecialCharacteres .Recipient.Name) 40}}</CdtrNm>
    31              <CdtrTaxId>{{truncate .Recipient.Document.Number 14}}</CdtrTaxId>
    32              <CdtrTaxTp>J</CdtrTaxTp>
    33           </GrpBenf>
    34           <GrpClPgd>
    35              <DbtrNm>{{truncateOnly (sanitizeCitibankSpecialCharacteres .Buyer.Name) 50}}</DbtrNm>
    36              <DbtrTaxId>{{clearString (truncate .Buyer.Document.Number 14)}}</DbtrTaxId>
    37  			{{if (eq .Buyer.Document.Type "CPF")}}
    38              	<DbtrTaxTp>F</DbtrTaxTp>
    39  			{{else}}
    40              	<DbtrTaxTp>J</DbtrTaxTp>
    41  			{{end}}
    42              <GrpClPgdAdr>
    43                 <DbtrAdrTp>{{truncateOnly (sanitizeCitibankSpecialCharacteres (joinSpace .Buyer.Address.Street .Buyer.Address.Number .Buyer.Address.Complement)) 40}}</DbtrAdrTp>
    44                 <DbtrCtrySubDvsn>{{clearString (truncate .Buyer.Address.StateCode 2)}}</DbtrCtrySubDvsn>
    45                 <DbtrPstCd>{{truncate (extractNumbers .Buyer.Address.ZipCode) 8}}</DbtrPstCd>
    46                 <DbtrTwnNm>{{clearString (truncate .Buyer.Address.City 15)}}</DbtrTwnNm>
    47              </GrpClPgdAdr>
    48           </GrpClPgd>
    49           <CdOccTp>01</CdOccTp>
    50           {{if .HasPayeeGuarantor}}
    51              <DbtrGrntNm>{{truncateOnly (onlyOneSpace (onlyAlphanumerics (sanitizeCitibankSpecialCharacteres .PayeeGuarantor.Name))) 23}}</DbtrGrntNm>
    52           {{else}}
    53              <DbtrGrntNm> </DbtrGrntNm>
    54           {{end}}
    55           <DbtrMsg>{{truncateOnly (sanitizeCitibankSpecialCharacteres .Title.Instructions) 40}}</DbtrMsg>
    56           <TitlAmt>{{.Title.AmountInCents}}</TitlAmt>
    57           <TitlBarCdInd>0</TitlBarCdInd>
    58           <TitlCcyCd>09</TitlCcyCd>
    59           <TitlCiaCdId>{{trimLeft .Title.DocumentNumber "0"}}</TitlCiaCdId>
    60           <TitlDueDt>{{enDate .Title.ExpireDateTime "-"}}</TitlDueDt>
    61           <TitlInstrNmDtExec>0</TitlInstrNmDtExec>
    62           <TitlInstrProtInd> </TitlInstrProtInd>
    63           <TitlInstrWrtOffInd> </TitlInstrWrtOffInd>
    64           <TitlIOFAmt>0</TitlIOFAmt>
    65           <TitlIssDt>{{enDate todayCiti "-"}}</TitlIssDt>
    66           <TitlOurNb>{{padLeft (toString .Title.OurNumber) "0" 12}}</TitlOurNb>
    67           <TitlPortCd>1</TitlPortCd>
    68           <TitlRbtAmt>0</TitlRbtAmt>
    69           <TitlTpCd>{{.Title.BoletoTypeCode}}</TitlTpCd>
    70           <TitlYourNb>{{trimLeft .Title.DocumentNumber "0"}}</TitlYourNb>
    71           <GrpDscnt>
    72              <TitlDscntAmtOrPrct>0</TitlDscntAmtOrPrct>
    73              <TitlDscntEndDt> </TitlDscntEndDt>
    74              <TitlDscntTp> </TitlDscntTp>
    75           </GrpDscnt>
    76           <GrpItrs>
    77              <TitlItrsAmtOrPrct>0</TitlItrsAmtOrPrct>
    78              <TitlItrsStrDt> </TitlItrsStrDt>
    79              <TitlItrsTp> </TitlItrsTp>
    80           </GrpItrs>
    81           <GrpFn>
    82              <TitlFnAmtOrPrct>0</TitlFnAmtOrPrct>
    83              <TitlFnStrDt> </TitlFnStrDt>
    84              <TitlFnTp> </TitlFnTp>
    85           </GrpFn>
    86           {{if .HasPayeeGuarantor}}
    87              <DbtrGrntDocum>{{.PayeeGuarantor.Document.Number}}</DbtrGrntDocum>
    88              {{if eq .PayeeGuarantor.Document.Type "CPF"}}        
    89                 <DbtrGrntTpPess>F</DbtrGrntTpPess>
    90              {{else}}
    91                 <DbtrGrntTpPess>J</DbtrGrntTpPess>
    92              {{end}}
    93           {{end}}
    94        </GrpREMColTit>
    95     </soapenv:Body>
    96  </soapenv:Envelope>
    97  `
    98  
    99  func getRequestCiti() string {
   100  	return registerBoletoCiti
   101  }
   102  
   103  func getResponseCiti() string {
   104  	return responseCiti
   105  }