Skip to content

Instantly share code, notes, and snippets.

class PaymentService
{
public function charge(User $user, int $amount, string $token): Payment
{
$result = $this->stripe->charge($amount, $token);
$payment = new Payment($user->id, $amount, 'USD');
$payment->status = $result->status === 'succeeded'
? 'paid'
: 'failed';