PHP code example of emmanuelsaleem / laravel-stripe-manager
1. Go to this page and download the library: Download emmanuelsaleem/laravel-stripe-manager library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emmanuelsaleem / laravel-stripe-manager example snippets
'api_routes' => [
'prefix' => 'api/stripe-manager',
'middleware' => ['api'], // e.g. ['api','auth:sanctum']
],
use EmmanuelSaleem\LaravelStripeManager\Services\CustomerService;
$customerService = app(CustomerService::class);
// Create a customer
$user = User::find(1);
$customer = $customerService->createCustomer($user, [
'name' => 'John Doe',
'email' => '[email protected] '
]);
// Store a payment method
$card = $customerService->storePaymentMethod($user, $paymentMethodId, $setAsDefault = true);
// Create setup intent for card collection
$setupIntent = $customerService->createSetupIntent($user);
use EmmanuelSaleem\LaravelStripeManager\Services\ProductService;
$productService = app(ProductService::class);
// Create a product
$product = $productService->createProduct([
'name' => 'Premium Subscription',
'description' => 'Access to premium features',
'active' => true
]);
// Create pricing for the product
$pricing = $productService->createProductPrice($product, [
'unit_amount' => 1999, // $19.99 in cents
'currency' => 'usd',
'recurring' => [
'interval' => 'month',
'interval_count' => 1
],
'nickname' => 'Monthly Premium'
]);
use EmmanuelSaleem\LaravelStripeManager\Services\SubscriptionService;
$subscriptionService = app(SubscriptionService::class);
// Create a subscription
$subscription = $subscriptionService->createSubscription($user, $pricing, [
'trial_days' => 14,
'payment_method' => $paymentMethodId
]);
// Cancel a subscription
$subscriptionService->cancelSubscription($subscription, $immediately = false);
// Resume a subscription
$subscriptionService->resumeSubscription($subscription);
bash
composer bash
php artisan vendor:publish --provider="EmmanuelSaleem\LaravelStripeManager\StripeManagerServiceProvider" --tag="migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="EmmanuelSaleem\LaravelStripeManager\StripeManagerServiceProvider" --tag="views"
bash
php artisan vendor:publish --provider="EmmanuelSaleem\LaravelStripeManager\StripeManagerServiceProvider" --tag="config"
bash
php artisan migrate