Skip to content

Exception Handling Issue during International Address Verification #172

@mrnevisane

Description

@mrnevisane

Summary

We encountered an InvalidArgumentException while utilizing your SDK to verify an international address:

Failed to send a postcard using Lob: “Invalid value 'Housenumber/Building' for 'coverage', must be one of 'SUBBUILDING', 'HOUSENUMBER/BUILDING', 'STREET', 'LOCALITY', 'SPARSE'”.

Expected Behavior

In this case, the exception should not be thrown since the response from the Lob service is Housenumber/Building, whereas the SDK expects it to be in uppercase as HOUSENUMBER/BUILDING. It's worth noting that PHP's in_array method is case-sensitive.

image

Current Behavior

The SDK is throwing an exception, as mentioned before, when attempting to verify an international address.

Possible Solution

To address the issue, there are two potential solutions:

  1. Modify the response from the Lob service to send the coverage in uppercase to match the SDK's expectations.
  2. Alternatively, you can modify the SDK code by adding strtoupper($coverage) as the first parameter of the in_array method.

Steps to Reproduce

Using a simple code like this, leads to same error:

$verificationApi = new IntlVerificationsApi($this->config);
$verificationWritable = new IntlVerificationWritable([
    'recipient' => $recipientFullname,
    'primary_line' => $address->addressLine1,
    'secondary_line' => $address->addressLine2,
    'city' => $address->city,
    'state' => $address->state,
    'postal_code' => $address->postalCode,
    'country' => $address->country->code,
]);

$verification = $verificationApi->verifySingle($verificationWritable);

Context (Environment)

Version: 4.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions