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çãoEste 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
ProblemDetailsdo ASP.NET Core, com um objetoerrorscujas chaves são os nomes dos campos que falharam.
Recomendação de integraçãoNã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 chaveerrors(Formato C).
2. Retorno HTTP de cada aplicação
| Aplicação | Como o resultado é sinalizado |
|---|---|
| SOAP | O 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. |
| REST | Erros 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 deErrorReportCollection; se três campos estiverem errados, os três elementosErrorReportaparecem 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.
ImportanteNo 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) |
|---|---|---|---|
| 111 | Internal error. | N/A | Value does not fall within the expected range. |
FraudAnalysisRequestError | The MerchantOrderId is mandatory | ||
| 0 | MerchantReferenceCode: The size of MerchantReferenceCode must be between 1 and 50 characters. | FraudAnalysisRequestError | The MerchantOrderId length is greater than 100. |
errors.Currency | The Currency field is required. | ||
| 902 | Currency: Invalid parameter length. Valid length: 3 [PurchaseTotalsData] | FraudAnalysisRequestError | The Currency length is greater than 3. |
errors.TransactionAmount | The TransactionAmount field is required. | ||
| 903 | GrandTotalAmount: Invalid parameter value. Valid value: greater than 0 [PurchaseTotalsData] | ||
errors.TotalOrderAmount | The TotalOrderAmount field is required. | ||
FraudAnalysisRequestError | The Partner length is greater than 3. | ||
| 902 | Comments: 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) |
|---|---|---|---|
| 901 | Street1: Parameter cannot be null or empty [BillToData] | ||
| 902 | Street1: Invalid parameter length. Valid length: 1 to 60 [BillToData] | FraudAnalysisRequestError | The Billing.Street length is greater than 54. |
| SOAP não separa número do logradouro. | FraudAnalysisRequestError | The Billing.Number length is greater than 5. | |
| 902 | Street2: Invalid parameter length. Valid length: 0 to 60 [BillToData] | FraudAnalysisRequestError | The Billing.Complement length is greater than 14. |
Street2 (SOAP) corresponde a Neighborhood + Complement (REST) concatenados. | FraudAnalysisRequestError | The Billing.Neighborhood length is greater than 45. | |
| 901 | City: Parameter cannot be null or empty [BillToData] | ||
| 902 | City: Invalid parameter length. Valid length: 1 to 50 [BillToData] | FraudAnalysisRequestError | The Billing.City length is greater than 50. |
| 901 | State: Parameter cannot be null or empty [BillToData] | ||
| 902 | State: Invalid parameter length. Valid length: 2 [BillToData] | FraudAnalysisRequestError | The Billing.State length is greater than 2. |
| 901 | Country: Parameter cannot be null or empty [BillToData] | ||
| 902 | Country: Invalid parameter length. Valid length: 2 [BillToData] | FraudAnalysisRequestError | The Billing.Country length is greater than 3. |
| 902 | PostalCode: Invalid parameter length. Valid length: 0 to 10 [BillToData] | FraudAnalysisRequestError | The Billing.ZipCode length is greater than 9. |
| 901 | Email: Parameter cannot be null or empty [BillToData] | ||
| 902 | Email: Invalid parameter length. Valid length: 1 to 100 [BillToData] | FraudAnalysisRequestError | The Customer.Email length is greater than 100. |
| 901 | FirstName: Parameter cannot be null or empty [BillToData] | ||
| 902 | FirstName: Invalid parameter length. Valid length: 1 to 60 [BillToData] | FraudAnalysisRequestError | The Customer.FirstName length is greater than 60. |
| 901 | LastName: Parameter cannot be null or empty [BillToData] | ||
| 902 | LastName: Invalid parameter length. Valid length: 1 to 60 [BillToData] | FraudAnalysisRequestError | The Customer.LastName length is greater than 60. |
SOAP não exige CustomerId. | FraudAnalysisRequestError | The Customer.MerchantCustomerId is mandatory | |
| Obrigatório em REST/Cybersource; SOAP não exige. | |||
| 902 | CustomerId: Invalid parameter length. Valid length: 0 to 50 [BillToData] | FraudAnalysisRequestError | The Customer.MerchantCustomerId length is greater than 16. |
| 902 | HostName: Invalid parameter length. Valid length: 0 to 60 [BillToData] | ||
| 902 | HttpBrowserEmail: Invalid parameter length. Valid length: 0 to 100 [BillToData] | ||
| 902 | HttpBrowserType: Invalid parameter length. Valid length: 0 to 40 [BillToData] | ||
| 902 | IpAddress: Invalid parameter length. Valid length: 0 to 45 [BillToData] | FraudAnalysisRequestError | The Customer.Ip length is greater than 45. |
| 902 | PhoneNumber: Invalid parameter length. Valid length: 0 to 15 [BillToData] | FraudAnalysisRequestError | The Customer.Phone length is greater than 15. |
| SOAP só tem um telefone. | FraudAnalysisRequestError | The Customer.Mobile length is greater than 20. | |
FraudAnalysisRequestError | The Customer.WorkPhone length is greater than 100. | ||
| 902 | DateOfBirth: Invalid parameter length. Valid length: {data} to {data} [BillToData] | errors.Customer.BirthDate | Could 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) |
|---|---|---|---|
| 902 | AccountNumber: Invalid parameter length. Valid length: 0 to 20 [CardData] | FraudAnalysisRequestError | The Card.Number length is greater than 20. |
| 904 | AccountNumber: Only numeric values are permitted [CardData] | REST não valida se é numérico. | |
| 902 | ExpirationMonth: Invalid parameter length. Valid length: 2 [CardData] | REST usa um único campo mm/yyyy (ver Card.ExpirationDate na linha a seguir). | |
| 904 | ExpirationMonth: Only numeric values are permitted [CardData] | ||
| 902 | ExpirationYear: Invalid parameter length. Valid length: 4 [CardData] | ||
| 904 | ExpirationYear: Only numeric values are permitted [CardData] | ||
| SOAP valida mês e ano em campos separados, sem checar o formato. | errors.Card.ExpirationDate | Error: Card.ExpirationDate must match the format 'mm/yyyy'. | |
| SOAP não valida CVV. | FraudAnalysisRequestError | The Card.Cvv length is greater than 4. | |
SOAP não valida Holder. | FraudAnalysisRequestError | The Card.Holder length is greater than 50. | |
SOAP não valida Brand. | FraudAnalysisRequestError | The Card.Brand length is greater than 10. | |
SOAP não tem campo Bin validado. | FraudAnalysisRequestError | The Card.Bin length is greater than 6. | |
SOAP não valida o tamanho do Alias. | FraudAnalysisRequestError | The Card.Alias length is greater than 64. | |
| Campo sem equivalente no SOAP. | FraudAnalysisRequestError | The Card.EciThreeDSecure length is greater than 32. |
4.4 Endereço de entrega (ShipToData ↔ Shipping)
| Código (SOAP) | Mensagem (SOAP) | Campo (REST) | Mensagem (REST) |
|---|---|---|---|
| 902 | Street1: Invalid parameter length. Valid length: 0 to 60 [ShipToData] | FraudAnalysisRequestError | The Shipping.Street length is greater than 54. |
| SOAP não separa número do logradouro. | FraudAnalysisRequestError | The Shipping.Number length is greater than 5. | |
| 902 | City: Invalid parameter length. Valid length: 0 to 50 [ShipToData] | FraudAnalysisRequestError | The Shipping.City length is greater than 50. |
| 902 | State: Invalid parameter length. Valid length: 2 [ShipToData] | FraudAnalysisRequestError | The Shipping.State length is greater than 2. |
| 902 | Country: Invalid parameter length. Valid length: 2 [ShipToData] | FraudAnalysisRequestError | The Shipping.Country length is greater than 3. |
| 902 | PostalCode: Invalid parameter length. Valid length: 0 to 9 [ShipToData] | FraudAnalysisRequestError | The Shipping.ZipCode length is greater than 9. |
| 902 | PhoneNumber: Invalid parameter length. Valid length: 0 to 15 [ShipToData] | FraudAnalysisRequestError | The Shipping.Phone length is greater than 15. |
SOAP ShipToData não tem campo de e-mail. | FraudAnalysisRequestError | The Shipping.Email length is greater than 100. | |
| 902 | FirstName: Invalid parameter length. Valid length: 0 to 60 [ShipToData] | FraudAnalysisRequestError | The Shipping.FirstName length is greater than 60. |
| 902 | LastName: Invalid parameter length. Valid length: 0 to 60 [ShipToData] | FraudAnalysisRequestError | The Shipping.LastName length is greater than 60. |
| 902 | Street2: Invalid parameter length. Valid length: 0 to 60 [ShipToData] | FraudAnalysisRequestError | The Shipping.Complement length is greater than 14. |
Street2 (SOAP) corresponde a Neighborhood + Complement (REST). | FraudAnalysisRequestError | The Shipping.Neighborhood length is greater than 45. |
4.5 Item / produto (ItemData.ProductData ↔ CartItem)
| Código (SOAP) | Mensagem (SOAP) | Campo (REST) | Mensagem (REST) |
|---|---|---|---|
| 901 | ItemDataCollection: Parameter cannot be null or empty | FraudAnalysisRequestError | The CartItems is mandatory |
| 902 | Name: Invalid parameter length. Valid length: 0 to 255 [ProductData] | FraudAnalysisRequestError | The CartItems[0].ProductName length is greater than 255. |
| 902 | Sku: Invalid parameter length. Valid length: 0 to 255 [ProductData] | FraudAnalysisRequestError | The CartItems[0].Sku length is greater than 255. |
| Campo sem equivalente no SOAP. | FraudAnalysisRequestError | The CartItems[0].MerchantItemId length is greater than 36. | |
FraudAnalysisRequestError | The CartItems[0].Description length is greater than 255. | ||
FraudAnalysisRequestError | The CartItems[0].GiftMessage length is greater than 255. | ||
FraudAnalysisRequestError | The CartItems[0].ShippingInstructions length is greater than 2048. | ||
FraudAnalysisRequestError | The 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.
Updated 4 days ago