laravel / cashier-mollie

MIT License
375 stars 63 forks source link

user id rounded up #332

Closed gotexx1 closed 3 years ago

gotexx1 commented 3 years ago

When Mollie retrieves the user's data, it rounds up the id.

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Cache;
use Overtrue\LaravelFollow\Followable;
use Overtrue\LaravelLike\Traits\Liker;
use Laravel\Cashier\Billable;
use Laravel\Cashier\Order\Contracts\ProvidesInvoiceInformation;

class User extends Authenticatable
{
    use Notifiable, Followable, Liker, Billable;

    protected $primaryKey = 'steam_id';
    protected $dates = ['community_banned_until'];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'avatar', 'steam_url', 'steam_id',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function getInvoiceInformation()
    {
        return [$this->name, $this->email];
    }

    public function getIdAttribute()
    {
        return $this->steam_id;
    }
}
    /**
     * @param string $plan
     * @return \Illuminate\Http\RedirectResponse
     */
    public function __invoke(string $plan)
    {

        $name = 'premium';

        if(!Auth::user()->subscribed($name, $plan)) {

            $result = Auth::user()->newSubscription($name, $plan)->create();

            if(is_a($result, RedirectToCheckoutResponse::class)) {
                return $result; // Redirect to Mollie checkout
            }
            //create subscription
            return back()->with('status', 'Welcome to the ' . $plan . ' plan');
        }

        return back()->with('status', 'You are already on the ' . $plan . ' plan');
    }

When i do a dd(Auth::user()->getIdAttribute()); i got 76561198024018092 but in mollie dashboard i got

  "owner": {
    "type": "App\\User",
    "id": 76561198024018100
  },

Mollie round up 092 to 100 in three last digit id

sandervanhooft commented 3 years ago

Mollie isn't manipulating the data.

I suspect it's caused because the steam id isn't cast to a string but sent to Mollie as an integer.