Vonage / vonage-php-sdk-core

Vonage REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
https://developer.vonage.com/
Apache License 2.0
908 stars 181 forks source link

Remove generic Sender ID from your PHP SDK code #452

Closed simonrjones closed 9 months ago

simonrjones commented 9 months ago

Expected Behavior

Your PHP SDK contains a bug that stops Verify SMS messages being sent. We discovered this while testing our website and since 31 Oct 2023 SMS one time verification codes stopped being sent.

Our code set the brand, but did not set the sender ID. So it used the default sender ID of "VERIFY" which is set in your PHP code.

According to: https://api.support.vonage.com/hc/en-us/articles/10866279173148-United-Kingdom-List-of-Generic-SIDs-Blocked

The sender ID "VERIFY" is blocked in the UK.

Current Behavior

Our code that failed:

    $request = new Request($phoneNumber, self::BRAND_NAME, self::WORKFLOW_ID);       
        try {
            $response = $this->client->verify()->start($request);
        } catch (\Exception $e) {
            Log::error("Error when sending a verification request: " . $e->getMessage());
            throw new \Exception('Something went wrong when sending a verification request. Please try again in a few minutes.');
        }

This used the default SenderID of VERIFY and this failed to send SMSs.

We added this:

$request = new Request($phoneNumber, self::BRAND_NAME, self::WORKFLOW_ID);
$request->setSenderId(self::SENDER_ID);      

with a SENDER_ID = Studio24 and this fixed it and SMS one time codes delivered successfully.

Possible Solution

To fix this in your code:

https://github.com/Vonage/vonage-php-sdk-core/blob/main/src/Verify/Request.php

Change line 41 to:

    protected $senderId = 'VONAGE';

Or change the code to require that a custom Sender ID is set via setSenderId() for all verify requests.

You may also want to update documentation to reflect this.

SecondeJK commented 9 months ago

As has been identified, this has been specifically caused by UK Provider BT from restricting keywords. I'll schedule work in to add a validator class that contains this list.

SecondeJK commented 9 months ago

I'll split this into two. PR coming to fix this, validator will be added later.

SecondeJK commented 9 months ago

Fixed in 4.4.3, thank you for reporting :)