{"info":{"_postman_id":"53e72655-c0e6-426d-9a60-e6ca06fb70d2","name":"laravel stripe manager","description":"<html><head></head><body><p><strong>Base URL:</strong> <code>{APP_URL}/api/stripe-manager</code><br><strong>Default Middleware:</strong> <code>['api']</code><br><strong>Authentication:</strong> Configure middleware in <code>config/stripe-manager.php</code> under <code>api_routes.middleware   </code></p>\n<h3 id=\"error-response\">Error Response</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"error\": \"Error message\",\n  \"message\": \"Detailed error description\"\n}\n\n</code></pre>\n<h3 id=\"validation-error-response\">Validation Error Response</h3>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"message\": \"The given data was invalid.\",\n  \"errors\": {\n    \"field_name\": [\n      \"The field name field is required.\"\n    ]\n  }\n}\n\n</code></pre>\n<hr>\n<h2 id=\"configuration-notes\">Configuration Notes</h2>\n<h3 id=\"authentication-setup\">Authentication Setup</h3>\n<p>To secure these endpoints, update&nbsp;<code>config/stripe-manager.php</code>:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-php\">'api_routes' =&gt; [\n    'prefix' =&gt; 'api/stripe-manager',\n    'middleware' =&gt; ['api', 'auth:sanctum'], // Add your preferred auth middleware\n],\n\n</code></pre>\n<h3 id=\"amount-format\">Amount Format</h3>\n<ul>\n<li><p>All amounts are in the smallest currency unit (e.g., cents for USD)</p>\n</li>\n<li><p><code>unit_amount: 1999</code>&nbsp;= $19.99</p>\n</li>\n</ul>\n<h3 id=\"trial-behavior\">Trial Behavior</h3>\n<ul>\n<li><p>Trials are enforced locally and verified with Stripe when possible</p>\n</li>\n<li><p>Prevents re-trial abuse by checking previous subscriptions</p>\n</li>\n</ul>\n<h3 id=\"database-tables\">Database Tables</h3>\n<p>The API interacts with these local database tables:</p>\n<ul>\n<li><p><code>em_stripe_products</code>&nbsp;- Product information</p>\n</li>\n<li><p><code>em_stripe_product_pricing</code>&nbsp;- Pricing tiers</p>\n</li>\n<li><p><code>em_stripe_subscriptions</code>&nbsp;- Subscription data</p>\n</li>\n<li><p><code>em_subscription_payments</code>&nbsp;- Payment history</p>\n</li>\n<li><p><code>em_stripe_cards</code>&nbsp;- Customer payment methods</p>\n</li>\n</ul>\n<hr>\n<h2 id=\"postman-collection-setup\">Postman Collection Setup</h2>\n<ol>\n<li><p><strong>Base URL Variable:</strong>&nbsp;Set&nbsp;<code>{{base_url}}</code>&nbsp;to your application URL</p>\n</li>\n<li><p><strong>Authentication:</strong>&nbsp;Configure your preferred auth method (Bearer token, API key, etc.)</p>\n</li>\n<li><p><strong>Headers:</strong>&nbsp;Set&nbsp;<code>Content-Type: application/json</code>&nbsp;for POST/DELETE requests</p>\n</li>\n<li><p><strong>Environment Variables:</strong></p>\n<ul>\n<li><p><code>base_url</code>:&nbsp;<code>http://yourdomain.com</code>&nbsp;(or&nbsp;<code>https://yourdomain.com</code>)</p>\n</li>\n<li><p><code>api_prefix</code>:&nbsp;<code>api/stripe-manager</code></p>\n</li>\n</ul>\n</li>\n</ol>\n<p><strong>Example Request URLs:</strong></p>\n<ul>\n<li><p><code>{{base_url}}/{{api_prefix}}/plans</code></p>\n</li>\n<li><p><code>{{base_url}}/{{api_prefix}}/subscription</code></p>\n</li>\n<li><p><code>{{base_url}}/{{api_prefix}}/select-subscription-plan</code></p>\n</li>\n</ul>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"21481838","collectionId":"53e72655-c0e6-426d-9a60-e6ca06fb70d2","publishedId":"2sB3QJNAb4","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2025-10-06T20:03:54.000Z"},"item":[{"name":"Get Plans","id":"0aee0bf2-9ee5-4a46-9b17-a7b9880c861f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"{{base-url}}/{{perfix}}/plans","description":"<p><strong>Endpoint:</strong> <code>GET /api/stripe-manager/plans</code></p>\n<p><strong>Description:</strong> Returns all active products with their active pricing from local database (not Stripe).</p>\n<p><strong>Authentication:</strong> Depends on middleware configuration</p>\n<p><strong>Request Parameters:</strong> None</p>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": [\n    {\n      \"id\": 1,\n      \"name\": \"Pro Plan\",\n      \"description\": \"Professional features for advanced users\",\n      \"stripe_product_id\": \"prod_1234567890\",\n      \"pricing\": [\n        {\n          \"id\": 10,\n          \"stripe_price_id\": \"price_1234567890\",\n          \"nickname\": \"Monthly\",\n          \"unit_amount\": 1999,\n          \"currency\": \"usd\",\n          \"type\": \"recurring\",\n          \"billing_period\": \"month\",\n          \"billing_period_count\": 1,\n          \"trial_period_days\": 14\n        },\n        {\n          \"id\": 11,\n          \"stripe_price_id\": \"price_0987654321\",\n          \"nickname\": \"Yearly\",\n          \"unit_amount\": 19999,\n          \"currency\": \"usd\",\n          \"type\": \"recurring\",\n          \"billing_period\": \"year\",\n          \"billing_period_count\": 1,\n          \"trial_period_days\": 14\n        }\n      ]\n    }\n  ]\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>401</code> - Unauthorized (if auth middleware is configured)</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","plans"],"host":["{{base-url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"0aee0bf2-9ee5-4a46-9b17-a7b9880c861f"},{"name":"Get User subscription","id":"cb1f1f5f-1468-4172-a37b-e9e6c0b6f174","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"{{base-url}}/{{perfix}}/subscription?stripe_id","description":"<p><strong>Endpoint:</strong> <code>GET /api/stripe-manager/subscription</code></p>\n<p><strong>Description:</strong> Returns the latest subscription summary for the authenticated user from local database.</p>\n<p><strong>Authentication:</strong> Required (uses <code>$request-&gt;user()</code>)</p>\n<p><strong>Request Parameters:</strong> None</p>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": {\n    \"subscription_id\": 5,\n    \"stripe_subscription_id\": \"sub_1234567890\",\n    \"status\": \"active\",\n    \"product\": \"Pro Plan\",\n    \"price\": {\n      \"nickname\": \"Monthly\",\n      \"unit_amount\": 1999,\n      \"currency\": \"usd\",\n      \"billing_period\": \"month\",\n      \"billing_period_count\": 1\n    },\n    \"current_period_start\": \"2025-01-01 12:00:00\",\n    \"current_period_end\": \"2025-02-01 12:00:00\",\n    \"next_billing_at\": \"2025-02-01 12:00:00\",\n    \"next_billing_amount\": 1999\n  }\n}\n\n</code></pre>\n<p><strong>Response (No Subscription):</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": null\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>401</code> - Unauthorized</p>\n</li>\n</ul>\n<p>EndFragment</p>\n","urlObject":{"path":["{{perfix}}","subscription"],"host":["{{base-url}}"],"query":[{"key":"stripe_id","value":null}],"variable":[]}},"response":[],"_postman_id":"cb1f1f5f-1468-4172-a37b-e9e6c0b6f174"},{"name":"Get User subscription trial Info","id":"a5508f5f-97c6-4c07-a061-dab891cdd5f2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"{{base-url}}/{{perfix}}/trial-info","description":"<p><strong>Endpoint:</strong> <code>GET /api/stripe-manager/trial-info</code></p>\n<p><strong>Description:</strong> Returns the latest trial information for a specific user.</p>\n<p><strong>Authentication:</strong> Depends on middleware configuration</p>\n<p><strong>Query Parameters:</strong></p>\n<ul>\n<li><code>user_id</code> (required): Integer - User ID to get trial info for</li>\n</ul>\n<p><strong>Request Example:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>GET /api/stripe-manager/trial-info?user_id=123\n\n</code></pre><p><strong>Response (Has Trial):</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": {\n    \"has_trial\": true,\n    \"trial_start\": \"2025-01-01 12:00:00\",\n    \"trial_end\": \"2025-01-15 12:00:00\",\n    \"active\": true\n  }\n}\n\n</code></pre>\n<p><strong>Response (No Trial):</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": {\n    \"has_trial\": false\n  }\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>400</code> - Validation error (missing user_id)</p>\n</li>\n<li><p><code>401</code> - Unauthorized (if auth middleware is configured)</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","trial-info"],"host":["{{base-url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"a5508f5f-97c6-4c07-a061-dab891cdd5f2"},{"name":"Get User payment methods","id":"7ee8420b-fb87-4af3-858c-f61f3b74532d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"{{base-url}}/{{perfix}}/user-payment-methods","description":"<p><strong>Endpoint:</strong> <code>GET /api/stripe-manager/user-payment-methods</code></p>\n<p><strong>Description:</strong> Lists all card payment methods from Stripe for the authenticated user.</p>\n<p><strong>Authentication:</strong> Required (uses <code>$request-&gt;user()</code>)</p>\n<p><strong>Request Parameters:</strong> None</p>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": [\n    {\n      \"id\": \"pm_1234567890\",\n      \"brand\": \"visa\",\n      \"last4\": \"4242\",\n      \"exp_month\": 12,\n      \"exp_year\": 2025\n    },\n    {\n      \"id\": \"pm_0987654321\",\n      \"brand\": \"mastercard\",\n      \"last4\": \"5555\",\n      \"exp_month\": 6,\n      \"exp_year\": 2026\n    }\n  ]\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>401</code> - Unauthorized</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","user-payment-methods"],"host":["{{base-url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"7ee8420b-fb87-4af3-858c-f61f3b74532d"},{"name":"select subscription plan","id":"578702f2-cddd-4ce3-b327-6eddbc3697bf","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"plan_id","value":"","type":"text"},{"key":"payment_method_id","value":"","type":"text"}]},"url":"{{base-url}}/{{perfix}}/select-subscription-plan","description":"<p><strong>Endpoint:</strong> <code>POST /api/stripe-manager/select-subscription-plan</code></p>\n<p><strong>Description:</strong> Creates a subscription for the authenticated user with the specified payment method.</p>\n<p><strong>Authentication:</strong> Required (uses <code>$request-&gt;user()</code>)</p>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"plan_id\": 10,\n  \"payment_method_id\": \"pm_1234567890\"\n}\n\n</code></pre>\n<p><strong>Validation Rules:</strong></p>\n<ul>\n<li><p><code>plan_id</code>: Required, integer, must exist in <code>em_stripe_product_pricing</code> table</p>\n</li>\n<li><p><code>payment_method_id</code>: Required, string</p>\n</li>\n</ul>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"data\": {\n    \"id\": 5\n  }\n}\n\n</code></pre>\n<p><strong>Behavior Notes:</strong></p>\n<ul>\n<li><p>No repeat trial: If the user previously subscribed to the same pricing, the trial is skipped and the user is charged immediately</p>\n</li>\n<li><p>Creates subscription both on Stripe and in local database</p>\n</li>\n</ul>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>201</code> - Subscription created successfully</p>\n</li>\n<li><p><code>400</code> - Validation error</p>\n</li>\n<li><p><code>401</code> - Unauthorized</p>\n</li>\n<li><p><code>404</code> - Pricing plan not found</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","select-subscription-plan"],"host":["{{base-url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"578702f2-cddd-4ce3-b327-6eddbc3697bf"},{"name":"cancel subscription plan","id":"8409f80e-2079-4594-bb37-c6ec67ebb17f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"DELETE","header":[],"url":"{{base-url}}/{{perfix}}/cancel-subscription-plan","description":"<p><strong>Endpoint:</strong> <code>DELETE /api/stripe-manager/cancel-subscription-plan</code></p>\n<p><strong>Description:</strong> Cancels the current subscription for the authenticated user.</p>\n<p><strong>Authentication:</strong> Required (uses <code>$request-&gt;user()</code>)</p>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"immediately\": false\n}\n\n</code></pre>\n<p><strong>Validation Rules:</strong></p>\n<ul>\n<li><code>immediately</code>: Optional, boolean (default: false)</li>\n</ul>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"ok\": true\n}\n\n</code></pre>\n<p><strong>Behavior Notes:</strong></p>\n<ul>\n<li><p><code>immediately: true</code> - Cancels immediately and charges for unused time</p>\n</li>\n<li><p><code>immediately: false</code> - Cancels at the end of the current billing period</p>\n</li>\n<li><p>Cancels subscription both on Stripe and updates local database</p>\n</li>\n</ul>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>400</code> - Validation error</p>\n</li>\n<li><p><code>401</code> - Unauthorized</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","cancel-subscription-plan"],"host":["{{base-url}}"],"query":[{"disabled":true,"key":"immediately","value":null}],"variable":[]}},"response":[],"_postman_id":"8409f80e-2079-4594-bb37-c6ec67ebb17f"},{"name":"save stripe id","id":"a051cdaf-598b-4dca-b730-173c9d5beee7","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"stripe_id","value":"","type":"text"}]},"url":"{{base-url}}/{{perfix}}/save-stripe-id","description":"<p><strong>Endpoint:</strong> <code>POST /api/stripe-manager/save-stripe-id</code></p>\n<p><strong>Description:</strong> Saves a known Stripe customer ID to the authenticated user's record.</p>\n<p><strong>Authentication:</strong> Required (uses <code>$request-&gt;user()</code>)</p>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"stripe_id\": \"cus_1234567890\"\n}\n\n</code></pre>\n<p><strong>Validation Rules:</strong></p>\n<ul>\n<li><code>stripe_id</code>: Required, string</li>\n</ul>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"ok\": true\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>400</code> - Validation error</p>\n</li>\n<li><p><code>401</code> - Unauthorized</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","save-stripe-id"],"host":["{{base-url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"a051cdaf-598b-4dca-b730-173c9d5beee7"},{"name":"set default payment method","id":"8eb886d6-4e88-48db-8f61-c0a4d4097aa3","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"payment_method_id","value":"","type":"text"}]},"url":"{{base-url}}/{{perfix}}/set-default-payment-method","description":"<p><strong>Endpoint:</strong> <code>POST /api/stripe-manager/set-default-payment-method</code></p>\n<p><strong>Description:</strong> Sets the user's default payment method on Stripe.</p>\n<p><strong>Authentication:</strong> Required (uses <code>$request-&gt;user()</code>)</p>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"payment_method_id\": \"pm_1234567890\"\n}\n\n</code></pre>\n<p><strong>Validation Rules:</strong></p>\n<ul>\n<li><code>payment_method_id</code>: Required, string</li>\n</ul>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"ok\": true\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p><code>200</code> - Success</p>\n</li>\n<li><p><code>400</code> - Validation error</p>\n</li>\n<li><p><code>401</code> - Unauthorized</p>\n</li>\n</ul>\n","urlObject":{"path":["{{perfix}}","set-default-payment-method"],"host":["{{base-url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"8eb886d6-4e88-48db-8f61-c0a4d4097aa3"}]}