Manual de Migração SOAP → REST

Guia de integração: diferenças de contrato, formatos de erro e mapeamento de campos entre as duas integrações.

⚠️

Atenção

Este documento apoia a migração de clientes. Valide o comportamento atual antes de codificar regras rígidas em produção.

1. Visão geral: a diferença fundamental

A API SOAP (Antifraude WebService) retorna cada erro como um elemento estruturado dentro de ErrorReportCollection, com um código numérico (<ErrorCode>) e uma descrição (<ErrorMessage>) em campos XML separados. Já a API antifraude REST não tem nenhum campo numérico de código de erro no corpo da resposta; a informação equivalente aparece sempre como texto livre, dentro de um de três formatos de corpo JSON diferentes, dependendo de qual camada de validação rejeitou a requisição:

  • Formato A: corpo é uma string JSON solta (sem nenhuma chave ou envelope);
  • Formato B: corpo é um objeto com a chave fixa FraudAnalysisRequestError, contendo um array de mensagens;
  • Formato C: corpo é o padrão ProblemDetails do ASP.NET Core, com um objeto errors cujas chaves são os nomes dos campos que falharam.
ℹ️

Recomendação de integração

Não tente adivinhar o formato pelo texto da mensagem. Verifique primeiro o HTTP status; para 400, verifique se o corpo é uma string (Formato A), tem a chave FraudAnalysisRequestError (Formato B) ou tem a chave errors (Formato C).

2. Retorno HTTP de cada aplicação

AplicaçãoComo o resultado é sinalizado
SOAPO envelope SOAP sempre retorna 200 OK; o resultado real vem em TransactionStatusCode/TransactionStatusDescription (500 a 506) e em Success/ErrorReportCollection. Não existe erro HTTP: é sempre uma resposta SOAP válida, mesmo quando a requisição é rejeitada por validação.
RESTErros de validação de dados de entrada (Formatos A/B/C deste manual) retornam 400 Bad Request. Outros HTTP status existem para outras situações (404 recurso não encontrado, 501 operação não implementada, 500 erro interno inesperado), mas não fazem parte da validação de payload.

3. Pode haver mais de uma validação na mesma requisição?

Sim, nas duas aplicações, mas cada uma acumula de um jeito diferente:

  • SOAP: cada campo inválido gera um <ErrorReport> próprio dentro de ErrorReportCollection; se três campos estiverem errados, os três elementos ErrorReport aparecem juntos na mesma resposta;
  • REST, Formato B: a API valida todos os campos numa só passada; cada violação é adicionada ao array FraudAnalysisRequestError;
  • REST, Formato C: essa lógica também vale para o objeto errors; cada campo com problema aparece como uma chave própria;
  • REST, Formato A: é sempre uma única mensagem; não acumula.
ℹ️

Importante

No REST, os três formatos nunca aparecem juntos na mesma resposta. O ASP.NET Core executa a validação automática (Formato C) antes da validação personalizada da API (Formato B); se qualquer campo cair no Formato C, o Formato B nunca é avaliado.

4. Mapeamento de campos entre as duas aplicações

A tabela a seguir apresenta o mapeamento entre os campos do Antifraude Legado (SOAP) e da API antifraude REST. Uma célula em branco indica que a validação existe somente na outra aplicação.

4.1 Dados gerais da transação

Código (SOAP)Mensagem (SOAP)Campo (REST)Mensagem (REST)
111Internal error.N/AValue does not fall within the expected range.
FraudAnalysisRequestErrorThe MerchantOrderId is mandatory
0MerchantReferenceCode: The size of MerchantReferenceCode must be between 1 and 50 characters.FraudAnalysisRequestErrorThe MerchantOrderId length is greater than 100.
errors.CurrencyThe Currency field is required.
902Currency: Invalid parameter length. Valid length: 3 [PurchaseTotalsData]FraudAnalysisRequestErrorThe Currency length is greater than 3.
errors.TransactionAmountThe TransactionAmount field is required.
903GrandTotalAmount: Invalid parameter value. Valid value: greater than 0 [PurchaseTotalsData]
errors.TotalOrderAmountThe TotalOrderAmount field is required.
FraudAnalysisRequestErrorThe Partner length is greater than 3.
902Comments: Invalid parameter length. Valid length: 0 to 255

4.2 Comprador e endereço de cobrança (BillToData ↔ Billing / Customer)

Código (SOAP)Mensagem (SOAP)Campo (REST)Mensagem (REST)
901Street1: Parameter cannot be null or empty [BillToData]
902Street1: Invalid parameter length. Valid length: 1 to 60 [BillToData]FraudAnalysisRequestErrorThe Billing.Street length is greater than 54.
SOAP não separa número do logradouro.FraudAnalysisRequestErrorThe Billing.Number length is greater than 5.
902Street2: Invalid parameter length. Valid length: 0 to 60 [BillToData]FraudAnalysisRequestErrorThe Billing.Complement length is greater than 14.
Street2 (SOAP) corresponde a Neighborhood + Complement (REST) concatenados.FraudAnalysisRequestErrorThe Billing.Neighborhood length is greater than 45.
901City: Parameter cannot be null or empty [BillToData]
902City: Invalid parameter length. Valid length: 1 to 50 [BillToData]FraudAnalysisRequestErrorThe Billing.City length is greater than 50.
901State: Parameter cannot be null or empty [BillToData]
902State: Invalid parameter length. Valid length: 2 [BillToData]FraudAnalysisRequestErrorThe Billing.State length is greater than 2.
901Country: Parameter cannot be null or empty [BillToData]
902Country: Invalid parameter length. Valid length: 2 [BillToData]FraudAnalysisRequestErrorThe Billing.Country length is greater than 3.
902PostalCode: Invalid parameter length. Valid length: 0 to 10 [BillToData]FraudAnalysisRequestErrorThe Billing.ZipCode length is greater than 9.
901Email: Parameter cannot be null or empty [BillToData]
902Email: Invalid parameter length. Valid length: 1 to 100 [BillToData]FraudAnalysisRequestErrorThe Customer.Email length is greater than 100.
901FirstName: Parameter cannot be null or empty [BillToData]
902FirstName: Invalid parameter length. Valid length: 1 to 60 [BillToData]FraudAnalysisRequestErrorThe Customer.FirstName length is greater than 60.
901LastName: Parameter cannot be null or empty [BillToData]
902LastName: Invalid parameter length. Valid length: 1 to 60 [BillToData]FraudAnalysisRequestErrorThe Customer.LastName length is greater than 60.
SOAP não exige CustomerId.FraudAnalysisRequestErrorThe Customer.MerchantCustomerId is mandatory
Obrigatório em REST/Cybersource; SOAP não exige.
902CustomerId: Invalid parameter length. Valid length: 0 to 50 [BillToData]FraudAnalysisRequestErrorThe Customer.MerchantCustomerId length is greater than 16.
902HostName: Invalid parameter length. Valid length: 0 to 60 [BillToData]
902HttpBrowserEmail: Invalid parameter length. Valid length: 0 to 100 [BillToData]
902HttpBrowserType: Invalid parameter length. Valid length: 0 to 40 [BillToData]
902IpAddress: Invalid parameter length. Valid length: 0 to 45 [BillToData]FraudAnalysisRequestErrorThe Customer.Ip length is greater than 45.
902PhoneNumber: Invalid parameter length. Valid length: 0 to 15 [BillToData]FraudAnalysisRequestErrorThe Customer.Phone length is greater than 15.
SOAP só tem um telefone.FraudAnalysisRequestErrorThe Customer.Mobile length is greater than 20.
FraudAnalysisRequestErrorThe Customer.WorkPhone length is greater than 100.
902DateOfBirth: Invalid parameter length. Valid length: {data} to {data} [BillToData]errors.Customer.BirthDateCould not convert string to DateTime: {valor}. Path 'Customer.BirthDate', line {L}, position {P}. Ocorre quando o formato da data enviada é inválido.

4.3 Cartão (CardData ↔ Card)

Código (SOAP)Mensagem (SOAP)Campo (REST)Mensagem (REST)
902AccountNumber: Invalid parameter length. Valid length: 0 to 20 [CardData]FraudAnalysisRequestErrorThe Card.Number length is greater than 20.
904AccountNumber: Only numeric values are permitted [CardData]REST não valida se é numérico.
902ExpirationMonth: Invalid parameter length. Valid length: 2 [CardData]REST usa um único campo mm/yyyy (ver Card.ExpirationDate na linha a seguir).
904ExpirationMonth: Only numeric values are permitted [CardData]
902ExpirationYear: Invalid parameter length. Valid length: 4 [CardData]
904ExpirationYear: Only numeric values are permitted [CardData]
SOAP valida mês e ano em campos separados, sem checar o formato.errors.Card.ExpirationDateError: Card.ExpirationDate must match the format 'mm/yyyy'.
SOAP não valida CVV.FraudAnalysisRequestErrorThe Card.Cvv length is greater than 4.
SOAP não valida Holder.FraudAnalysisRequestErrorThe Card.Holder length is greater than 50.
SOAP não valida Brand.FraudAnalysisRequestErrorThe Card.Brand length is greater than 10.
SOAP não tem campo Bin validado.FraudAnalysisRequestErrorThe Card.Bin length is greater than 6.
SOAP não valida o tamanho do Alias.FraudAnalysisRequestErrorThe Card.Alias length is greater than 64.
Campo sem equivalente no SOAP.FraudAnalysisRequestErrorThe Card.EciThreeDSecure length is greater than 32.

4.4 Endereço de entrega (ShipToData ↔ Shipping)

Código (SOAP)Mensagem (SOAP)Campo (REST)Mensagem (REST)
902Street1: Invalid parameter length. Valid length: 0 to 60 [ShipToData]FraudAnalysisRequestErrorThe Shipping.Street length is greater than 54.
SOAP não separa número do logradouro.FraudAnalysisRequestErrorThe Shipping.Number length is greater than 5.
902City: Invalid parameter length. Valid length: 0 to 50 [ShipToData]FraudAnalysisRequestErrorThe Shipping.City length is greater than 50.
902State: Invalid parameter length. Valid length: 2 [ShipToData]FraudAnalysisRequestErrorThe Shipping.State length is greater than 2.
902Country: Invalid parameter length. Valid length: 2 [ShipToData]FraudAnalysisRequestErrorThe Shipping.Country length is greater than 3.
902PostalCode: Invalid parameter length. Valid length: 0 to 9 [ShipToData]FraudAnalysisRequestErrorThe Shipping.ZipCode length is greater than 9.
902PhoneNumber: Invalid parameter length. Valid length: 0 to 15 [ShipToData]FraudAnalysisRequestErrorThe Shipping.Phone length is greater than 15.
SOAP ShipToData não tem campo de e-mail.FraudAnalysisRequestErrorThe Shipping.Email length is greater than 100.
902FirstName: Invalid parameter length. Valid length: 0 to 60 [ShipToData]FraudAnalysisRequestErrorThe Shipping.FirstName length is greater than 60.
902LastName: Invalid parameter length. Valid length: 0 to 60 [ShipToData]FraudAnalysisRequestErrorThe Shipping.LastName length is greater than 60.
902Street2: Invalid parameter length. Valid length: 0 to 60 [ShipToData]FraudAnalysisRequestErrorThe Shipping.Complement length is greater than 14.
Street2 (SOAP) corresponde a Neighborhood + Complement (REST).FraudAnalysisRequestErrorThe Shipping.Neighborhood length is greater than 45.

4.5 Item / produto (ItemData.ProductData ↔ CartItem)

Código (SOAP)Mensagem (SOAP)Campo (REST)Mensagem (REST)
901ItemDataCollection: Parameter cannot be null or emptyFraudAnalysisRequestErrorThe CartItems is mandatory
902Name: Invalid parameter length. Valid length: 0 to 255 [ProductData]FraudAnalysisRequestErrorThe CartItems[0].ProductName length is greater than 255.
902Sku: Invalid parameter length. Valid length: 0 to 255 [ProductData]FraudAnalysisRequestErrorThe CartItems[0].Sku length is greater than 255.
Campo sem equivalente no SOAP.FraudAnalysisRequestErrorThe CartItems[0].MerchantItemId length is greater than 36.
FraudAnalysisRequestErrorThe CartItems[0].Description length is greater than 255.
FraudAnalysisRequestErrorThe CartItems[0].GiftMessage length is greater than 255.
FraudAnalysisRequestErrorThe CartItems[0].ShippingInstructions length is greater than 2048.
FraudAnalysisRequestErrorThe CartItems[0].ShippingTrackingNumber length is greater than 50.

5. Exemplos: a mesma falha de negócio, nas duas aplicações

5.1 Múltiplos campos obrigatórios ou inválidos na mesma requisição

SOAP

HTTP/1.1 200 OK
<FraudAnalysisResponse>
  <Success>false</Success>
  <ErrorReportCollection>
    <ErrorReport>
      <ErrorCode>901</ErrorCode>
      <ErrorMessage>Street1: Parameter cannot
      be null or empty [BillToData]</ErrorMessage>
    </ErrorReport>
    <ErrorReport>
      <ErrorCode>902</ErrorCode>
      <ErrorMessage>Country: Invalid parameter
      length. Valid length: 2 [BillToData]</ErrorMessage>
    </ErrorReport>
  </ErrorReportCollection>
  <TransactionStatusCode>505</TransactionStatusCode>
</FraudAnalysisResponse>

REST

HTTP/1.1 400 Bad Request
Content-Type: application/json
{
  "FraudAnalysisRequestError": [
    "The Customer.MerchantCustomerId is mandatory",
    "The Billing.Country length is greater than 3."
  ]
}

Este exemplo evidencia a estrutura que o cliente recebe quando mais de um campo falha na validação na mesma requisição: no SOAP, cada campo inválido aparece como um <ErrorReport> próprio dentro de ErrorReportCollection; no REST, cada campo inválido aparece como um item do array FraudAnalysisRequestError.

5.2 Campo de tipo ou formato inválido no cartão

SOAP

HTTP/1.1 200 OK
<FraudAnalysisResponse>
  <Success>false</Success>
  <ErrorReportCollection>
    <ErrorReport>
      <ErrorCode>904</ErrorCode>
      <ErrorMessage>ExpirationMonth: Only numeric values are permitted [CardData]</ErrorMessage>
    </ErrorReport>
  </ErrorReportCollection>
  <TransactionStatusCode>505</TransactionStatusCode>
</FraudAnalysisResponse>

REST

HTTP/1.1 400 Bad Request
Content-Type: application/problem+json

{
  "errors": {
    "Card.ExpirationDate": [
      "Error: Card.ExpirationDate must match the format 'mm/yyyy'."
    ]
  },
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-9c9289ecce24a77c5636de3ee60a43a2-5abcf1a7535aab99-01"
}

O SOAP não valida o formato da data de validade; ele valida mês (ExpirationMonth) e ano (ExpirationYear) em campos separados, aceitando qualquer valor numérico dentro do tamanho esperado. O exemplo desta seção mostra o cenário mais próximo disso no SOAP: enviar um valor não numérico nesses campos. Já o REST usa um único campo (Card.ExpirationDate, formato mm/yyyy) e rejeita qualquer valor que não corresponda a essa máscara.


Did this page help you?