Skip to content

Instantly share code, notes, and snippets.

@ger86
Last active March 7, 2019 10:41
Show Gist options
  • Save ger86/28ea45556174bc77e4d74da279c8b3d8 to your computer and use it in GitHub Desktop.
Save ger86/28ea45556174bc77e4d74da279c8b3d8 to your computer and use it in GitHub Desktop.
<?php
namespace App\Service;
use Stripe\Stripe;
use Stripe\Customer;
final class StripeCreateCustomer {
/**
* @param string $stripeSecretApiKey
*/
public function __construct(string $stripeSecretApiKey) {
$this->stripeSecretApiKey = $stripeSecretApiKey;
}
/**
* Creates a Customer
*
* @param string $email
* @param string $token
* @return Customer
*/
public function __invoke(string $email, string $token): Customer {
Stripe::setApiKey($this->stripeSecretApiKey);
$customer = Customer::create([
'email' => $email,
'source' => $token
]);
return $customer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment