File size: 921 Bytes
5f32fbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ProcessStripeCustomerJob implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
protected $stripe;
protected $user;
protected $userData;
/**
* Create a new job instance.
*/
public function __construct($stripe, $user, $userData)
{
$this->stripe = $stripe;
$this->user = $user;
$this->userData = $userData;
}
/**
* Execute the job.
*/
public function handle(): void
{
$stripeCustomer = $this->stripe->customers->create($this->userData);
$this->user->stripe_id = $stripeCustomer->id;
$this->user->save();
}
}
|