Last active
March 7, 2019 10:41
-
-
Save ger86/28ea45556174bc77e4d74da279c8b3d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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