Last active
March 7, 2019 10:46
-
-
Save ger86/92841486f540f3fa63550ebeadd3bfd6 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\Product; | |
final class StripeCreateProduct { | |
/** | |
* @param string $stripeSecretApiKey | |
*/ | |
public function __construct(string $stripeSecretApiKey) { | |
$this->stripeSecretApiKey = $stripeSecretApiKey; | |
} | |
/** | |
* Creates a Stripe Product | |
* | |
* @param string $name | |
* @param array $metadata | |
* @return Product | |
* | |
*/ | |
public function __invoke(string $name, array $metadata = []): Product { | |
Stripe::setApiKey($this->stripeSecretApiKey); | |
$product = Product::create([ | |
'name' => $name, | |
'type' => 'service', | |
'metadata' => $metadata | |
]); | |
return $product; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment