Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adnan.shabbir's avatar

How to create a product using Laravel Cashier

Hey,

I want to create a Stripe product using Laravel cashier. It seems to me after some search on google, that I have to first create Products and Pricings manually on Stripe then I would sync it and create a user subscription.

I want to create products from my code, instead of doing it manually. I can do it from Stripe REST API but I want to use Laravel Cashier to create products too and unfortunately, I'm not seeing any option on docs.

Please help

Thanks

0 likes
4 replies
adnan.shabbir's avatar

Yes but it does not create products and pricing from Cashier

Fors32's avatar

@adnan.shabbir if U are using Cashier v8 or lower you can use CURL for that. I don't see the Price class for that in vendor. Code below for curl

private function curlCreatePrice($productId, $productPrice) {

		$post = [
			'unit_amount' => $productPrice,
			'currency' => 'usd',
			'product'   => $productId,
		];

		$url = "https://api.stripe.com/v1/prices";

		//cURL Request
		$ch = curl_init();
		//set the url, number of POST vars, POST data
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_USERPWD, env('STRIPE_SECRET'));
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		curl_setopt($ch, CURLOPT_POST, 1);
		$params = http_build_query($post);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

		$result = curl_exec($ch);
		curl_close($ch);

		return json_decode($result);
	}
martinbean's avatar

@adnan.shabbir Cashier is not a complete wrapper around Stripe’s API.

Use the Stripe SDK directly to programmatically create products and prices.

Please or to participate in this conversation.