Norris1z / hubtel-laravel-sms-channel

A package that makes it easy to send SMS using Hubtel in a Laravel 5.3+ application
MIT License
10 stars 6 forks source link

I'm trying to use your plugin on laravel 5.8 and it's not working. #6

Closed dela-dels closed 5 years ago

dela-dels commented 5 years ago
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use Illuminate\Notifications\Notifiable;

class Attendee extends Model
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected  $fillable = [
        'lastname', 'firstname', 'phone', 'alt_phone', 'email', 'dob', 'location', 'school', 'gender'
    ];

    public function routeNotificationForSMS()
    {
        return $this->phone; // where phone is a cloumn in your users table;
    }
}

This is my Model for attendees of a program.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Notifications\Notification;

use NotificationChannels\Hubtel\HubtelChannel;

use NotificationChannels\Hubtel\HubtelMessage;

class SendConfirmationSMSController extends Notification
{
    public function via($notifiable)
    {
        return [HubtelChannel::class];
    }

    public function toSMS($notifiable)
    {
        return ( new HubtelMessage )
                            ->from("The Program Hubb")
                            ->content('Just Testing it out');
    }
}

This is my controller that sends the SMS.

what I have realized is that the message is not being sent to the recipient.

Norris1z commented 5 years ago

Does it throw an exception?

Norris1z commented 5 years ago

I think you should also read the latest notice in the changelog section of the readme.md which talks about IP whitelisting.

dela-dels commented 5 years ago

Does it throw an exception?

Nah. it doesnt throw any exception. Surprisingly.

dela-dels commented 5 years ago

I'm developing and testing on my local machine at the moment. I haven't hosted it.

Norris1z commented 5 years ago

Have you published the config files? As in added the credentials to your .env?

dela-dels commented 5 years ago

Have you published the config files? As in added the credentials to your .env?

Yes. I added the credentials to the.env files didn't use the config file

Norris1z commented 5 years ago

Do you have enough sms balance in your hubtel account?

dela-dels commented 5 years ago

Lol Yes. GHS 10.00

Do you have enough sms balance in your hubtel account?

LoL. Yes, I do. GHS 10.00 I think.

Norris1z commented 5 years ago

lol

dela-dels commented 5 years ago

so what's the way forward? does everything look good in my controller and model? I tried sending the number ass both +233 and normal 020 both didn't work.

Norris1z commented 5 years ago

Everything looks good to me. Check your sms reports on hubtel if the messages were sent actually or try using your credentials with postman just to confirm everything works fine.

dela-dels commented 5 years ago

Okay Sure. Will do that and give you feedback.

-----Original Message----- From: "Norris Oduro" notifications@github.com Sent: ‎14/‎04/‎2019 06:46 PM To: "Norris1z/hubtel-laravel-sms-channel" hubtel-laravel-sms-channel@noreply.github.com Cc: "dela-dels" delprane14@gmail.com; "Author" author@noreply.github.com Subject: Re: [Norris1z/hubtel-laravel-sms-channel] I'm trying to use yourplugin on laravel 5.8 and it's not working. (#6)

Everything looks good to me. Check your sms reports on hubtel if the messages were sent actually or try using your credentials with postman just to confirm everything works fine. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dela-dels commented 5 years ago

@Norris1z Is is possible that me not saving the phone numbers as "+233......" be the issue? Because numbers in my database are saved as 020, 024, etc.

Norris1z commented 5 years ago

Okay Sure. Will do that and give you feedback.

Did you try this?

Norris1z commented 5 years ago

@dela-dels I created a new project to replicate the issue and it is true that the messages are not sent. In my case it was a 400 Bad Request error. The problem is that the sender name must have no spaces and must be 11 characters or less

From
string
REQUIRED
The sender address.Sender IDs must be 11 characters or less without spaces or 16 numbers.
Norris1z commented 5 years ago

Here's a link to Hubtel's SMS documentation

https://developers.hubtel.com/reference#send-message

Feel free to submit a PR to update the README with the necessary information.

Oh and don't forget to update the link in the Available Message methods section in the README as it is a dead link now.

dela-dels commented 5 years ago

@dela-dels I created a new project to replicate the issue and it is true that the messages are not sent. In my case, it was a 400 Bad Request error. The problem is that the sender name must have no spaces and must be 11 characters or less

From
string
REQUIRED
The sender address.Sender IDs must be 11 characters or less without spaces or 16 numbers.

So what did you do to resolve this? because changing my sender id to less than 11 characters still doesn't get the message sent

Norris1z commented 5 years ago

WhatsApp Image 2019-04-15 at 1 00 19 PM (1) WhatsApp Image 2019-04-15 at 1 00 19 PM

Norris1z commented 5 years ago

Reducing the characters worked for me

dela-dels commented 5 years ago

Doesn't work for me.

can I get a snippet of your implementation, please?

Norris1z commented 5 years ago

https://github.com/Norris1z/Hubtel-SMS-Test

dela-dels commented 5 years ago

After digging deep into the Laravel documentation as wells as the sample implementation you posted, I have been able to figure it out and it's working fine now.

All I needed to do was to tweak my implementation a bit to suit my requirements.

Thanks, @Norris1z for this package.