{"info":{"_postman_id":"ecb64938-862b-42ff-9d04-b51c7a97d6c5","name":"CommerceCore Payment Microservice","description":"<html><head></head><body><h2 id=\"overview\">Overview</h2>\n<p>The CommerceCore Payment Microservice provides a robust and flexible API for managing various aspects of payment processing for the CommerceCore API. This API is designed to seamlessly integrate with Stripe's payment infrastructure while offering additional features and abstractions tailored for CommerceCore's ecosystem. The API is structured around three main components: Connected Accounts, Transactions, and Refunds.</p>\n<h2 id=\"connected-accounts\">Connected Accounts</h2>\n<p>The Connected Accounts feature allows businesses to create and manage their own payment processing accounts within the CommerceCore ecosystem. This is particularly useful for marketplaces or platforms that need to handle payments on behalf of multiple sellers or service providers.</p>\n<p>Key functionalities include:</p>\n<ol>\n<li><p><strong>Creating Connected Accounts</strong>: Businesses can easily set up new accounts by providing an email address. This process generates a Stripe Connected Account, providing a unique account ID and public key for future transactions.</p>\n</li>\n<li><p><strong>Account Onboarding</strong>: The API facilitates the onboarding process for new accounts, ensuring that all necessary information is collected to comply with financial regulations and Stripe's requirements.</p>\n</li>\n<li><p><strong>Dashboard Access</strong>: Account holders can securely access their Stripe dashboard through a generated login link, allowing them to manage their account settings, view transaction history, and access financial reports.</p>\n</li>\n</ol>\n<p>These features enable platforms to quickly set up and manage multiple seller accounts, streamlining the process of integrating diverse businesses into a single payment ecosystem.</p>\n<h2 id=\"transactions\">Transactions</h2>\n<p>The Transactions component forms the core of the payment processing functionality, handling the creation and confirmation of payment intents.</p>\n<p>Key features include:</p>\n<ol>\n<li><p><strong>Initiating Transactions</strong>: The API allows for the creation of new transactions by specifying details such as the order ID, connected account ID, and transaction amount. This process generates a client secret and transaction ID, which are crucial for completing the payment on the client side.</p>\n</li>\n<li><p><strong>Confirming Transactions</strong>: Once a payment method is selected by the customer, the transaction can be confirmed using the API. This step finalizes the payment, moving it from an initiated state to a completed state.</p>\n</li>\n</ol>\n<p>The transaction process is designed to be flexible and secure, allowing for various payment flows including delayed capture for pre-authorization scenarios.</p>\n<h2 id=\"refunds\">Refunds</h2>\n<p>The Refunds component handles the process of returning funds to customers, which is a critical part of any e-commerce platform.</p>\n<p>Key functionality:</p>\n<ol>\n<li><strong>Requesting Refunds</strong>: The API provides an endpoint to initiate refunds for completed transactions. This process is tied to specific orders and connected accounts, ensuring that refunds are properly tracked and allocated.</li>\n</ol>\n<p>The refund system is designed to be straightforward yet flexible, accommodating various refund scenarios that may arise in complex e-commerce operations.</p>\n<h3 id=\"cross-cutting-concerns\">Cross-Cutting Concerns</h3>\n<p>Across all these components, the API implements several important features:</p>\n<ol>\n<li><p><strong>Authentication and Authorization</strong>: The API uses a multi-layered authentication system, including bearer tokens for overall API access, developer tokens for identifying the integrating application, and user IDs for attributing actions to specific users within the system.</p>\n</li>\n<li><p><strong>Error Handling</strong>: Comprehensive error reporting is implemented across all endpoints, providing clear and actionable information when issues arise.</p>\n</li>\n<li><p><strong>Stripe Integration</strong>: While abstracting many of the complexities, the API closely integrates with Stripe's services, leveraging its robust payment processing capabilities and security features.</p>\n</li>\n<li><p><strong>Extensibility</strong>: The API is designed with future growth in mind, allowing for easy addition of new features and endpoints as the needs of the platform evolve.</p>\n</li>\n</ol>\n<p>This API provides a comprehensive solution for platforms and marketplaces looking to implement complex payment flows. By abstracting much of the complexity involved in multi-party payments, refunds, and account management, it allows businesses to focus on their core operations while still maintaining flexibility and control over their payment processes.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"36378381","collectionId":"ecb64938-862b-42ff-9d04-b51c7a97d6c5","publishedId":"2sAXqtb23V","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2024-09-26T09:16:12.000Z"},"item":[{"name":"Version 1","item":[{"name":"Connected Accounts","item":[{"name":"Create Connected Account","id":"4e8ab493-b138-4ab0-ae49-23e1df36958e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"X-Developer-Token","value":"214c0063-6017-46be-a9a7-a633ac55e65d","description":"<p>Token of authorized developer</p>\n","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"ezewisdomjohn@gmail.com\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts","description":"<h2 id=\"endpoint-overview\">Endpoint Overview</h2>\n<p>This endpoint allows you to create a new connected Stripe account within the CommerceCore Payment Microservice ecosystem.</p>\n<h2 id=\"request-details\">Request Details</h2>\n<h3 id=\"headers\">Headers</h3>\n<ol>\n<li><p><strong>X-Developer-Token</strong> (required)</p>\n<ul>\n<li><p>Type: String</p>\n</li>\n<li><p>Description: A used for authentication and authorization.</p>\n</li>\n<li><p>Format: <code>Bearer</code></p>\n</li>\n<li><p>X-Developer-Token:</p>\n</li>\n</ul>\n</li>\n</ol>\n<h3 id=\"body\">Body</h3>\n<p>The request body should be in JSON format and contain the following field:</p>\n<ol>\n<li><p><strong>email</strong> (required)</p>\n<ul>\n<li><p>Type: String</p>\n</li>\n<li><p>Description: The email address associated with the connected account to be created.</p>\n</li>\n<li><p>Format: A valid email address</p>\n</li>\n<li><p>{ \"email\": \"ezeisraeljohn<a href=\"https://mailto:ezewisdomjohn@gmail.com\">@example.com</a>\"}</p>\n</li>\n</ul>\n</li>\n</ol>\n<h2 id=\"response-details\">Response Details</h2>\n<h3 id=\"success-response\">Success Response</h3>\n<p><strong>Status Code:</strong> 201 Created</p>\n<p>The response body will be a JSON object with the following structure:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\": {\n        \"account_id\": \"acct_1Q05C3FNeyusjZzz\",\n        \"public_key\": \"pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n        \"message\": \"Connected account created successfully onboarding link expires in 18 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts,\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_1xxxxxxxxxxxxxxx\"\n    }\n}\n\n</code></pre>\n<h4 id=\"response-fields-explained\">Response Fields Explained</h4>\n<ol>\n<li><p><strong>data</strong></p>\n<ul>\n<li><p><strong>account_id</strong>: A unique identifier for the created Stripe connected account. This ID should be stored securely as it will be used for future operations related to this account.</p>\n</li>\n<li><p><strong>public_key</strong>: The Stripe public key associated with this connected account. This key can be used for client-side operations specific to this account.</p>\n</li>\n<li><p><strong>message</strong>: A human-readable message indicating the successful creation of the account and providing instructions for the next steps.</p>\n</li>\n</ul>\n</li>\n<li><p><strong>meta</strong></p>\n<ul>\n<li><strong>status_code</strong>: The HTTP status code of the response, in this case, 201 indicating successful creation.</li>\n</ul>\n</li>\n<li><p><strong>links</strong></p>\n<ul>\n<li><p><strong>self</strong>: The URL of the endpoint that was called to create this account.</p>\n</li>\n<li><p><strong>onboarding_url</strong>: A Stripe-hosted URL where the account holder can complete the onboarding process. This URL is time-sensitive and typically expires after 18 hours.</p>\n</li>\n</ul>\n</li>\n</ol>\n<h3 id=\"error-responses\">Error Responses</h3>\n<ol>\n<li><p><strong>Unauthorized (401)</strong></p>\n<ul>\n<li><p>Occurs when the X-Developer-Token is missing, invalid, or expired.</p>\n</li>\n<li><p>{ \"detail\": \"Invalid or expired token\"}</p>\n</li>\n</ul>\n</li>\n<li><p><strong>Bad Request (400)</strong></p>\n<ul>\n<li><p>Occurs when the request body is malformed or missing required fields.</p>\n</li>\n<li><p>{ \"detail\": \"Invalid request body. 'email' field is required.\"}</p>\n</li>\n</ul>\n</li>\n<li><p><strong>Conflict (409)</strong></p>\n<ul>\n<li><p>Might occur if an account with the provided email already exists.</p>\n</li>\n<li><p>{ \"detail\": \"An account with this email already exists.\"}</p>\n</li>\n</ul>\n</li>\n<li><p><strong>Internal Server Error (500)</strong></p>\n<ul>\n<li><p>Occurs when there's an unexpected error on the server side.</p>\n</li>\n<li><p>{ \"detail\": \"An unexpected error occurred while processing your request.\"}</p>\n</li>\n</ul>\n</li>\n</ol>\n<h2 id=\"implementation-details\">Implementation Details</h2>\n<ol>\n<li><p><strong>Email Validation</strong>: The service performs basic validation on the provided email address to ensure it's in a valid format</p>\n</li>\n<li><p><strong>Public Key Generation</strong>: The public key returned in the response is generated by Stripe and associated with the newly created account.</p>\n</li>\n<li><p><strong>Onboarding URL Generation</strong>: The service requests a time-limited onboarding URL from Stripe, which is then returned in the response.</p>\n</li>\n<li><p><strong>Error Handling</strong>: The implementation lincludes comprehensive error handling to catch and appropriately respond to various error scenarios, both from internal processing and from the Stripe API.</p>\n</li>\n</ol>\n","urlObject":{"path":["api","v1","connected-accounts"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"572186a4-8985-4f53-b741-ca94301762bd","name":"Unauthorized To Create Account","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"johndoe@example.com\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/connected-accounts"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Tue, 17 Sep 2024 13:24:44 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"25"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"detail\": \"Unauthorized\"\n}"},{"id":"c151dd37-2468-4d50-88b0-ea2bb29575ae","name":"Create Connected Account","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"johndoe@example.com.com\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/connected-accounts"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Tue, 17 Sep 2024 17:27:57 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"492"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"data\": {\n        \"account_id\": \"acct_1Q05C3FNeyusjZzz\",\n        \"public_key\": \"pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n        \"message\": \"Connected account created successfully onboarding link expires in 18 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": \"http://127.0.0.1:8000/api/v1/connected-accounts\",\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_xxxxxxxxxxxxxxxxxxxxxxx\"\n    }\n}"}],"_postman_id":"4e8ab493-b138-4ab0-ae49-23e1df36958e"},{"name":"Onboarding","id":"de4baffa-a2d7-47cd-8a64-d4b2f0a8763f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"X-Developer-Token","value":"b9f10f7c-4743-4423-a2c0-888168864f5d","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"account_id\":\"acct_1Q4p9Q2X3OIeSA1E\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts/onboarding","description":"<h3 id=\"connected-accounts-onboarding\">Connected Accounts Onboarding</h3>\n<p>This endpoint is used to onboard connected accounts.</p>\n<h4 id=\"request-body\">Request Body</h4>\n<ul>\n<li><code>account_id</code> (string, required): The ID of the account to be onboarded.</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>The response will contain the result of the onboarding process.</p>\n","urlObject":{"path":["api","v1","connected-accounts","onboarding"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"38cf856f-bdc2-4c4c-b8a7-ceb909696191","name":"Created Onboarding","originalRequest":{"method":"POST","header":[{"key":"X-Developer-Token","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzI2OTM1NTA5LCJpYXQiOjE3MjY4NDkxMDksImp0aSI6IjQ3MmNkZjEzOTkzMjQ3ODdhYzE4MGExN2E0NWEzNmM5IiwidXNlcl9pZCI6InVzcl90M2hiWWlEbHh3RjBXUjZ6NDlGeW1WZ18yIiwiZGV2ZWxvcGVyX2lkIjoiZGVfOHZETC1MLWdBZjI0UnJBek1PZmdMQldoQSIsImFwcF9pZHMiOlsiYXBfM1BUTThMRlVjZmRsV19uakxwZmNTbUFKNiJdfQ.TUPaMsu2_296IheypiMiymoEkkDD4UCQ6um0JGqF3Us","type":"text","disabled":true},{"key":"X-Developer-Token","value":"<Developer-Token>","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"account_id\":\"acc_xxxxxxxxxxxxxxxxxx\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/connected-accounts/onboarding"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Sat, 21 Sep 2024 12:22:09 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"304"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"data\": {\n        \"message\": \"Onboarding link expires in 13 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": \"http://127.0.0.1:8000/api/v1/connected-accounts/onboarding\",\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_xxxxxxxxxxxxxxxxxxxxxxxxx\"\n    }\n}"}],"_postman_id":"de4baffa-a2d7-47cd-8a64-d4b2f0a8763f"},{"name":"Login Dashboard","id":"ff769ff8-1d4d-4208-84de-6f95888e85b7","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"X-Developer-Token","value":"9080d9ea-a700-4eeb-9374-4034901e351e","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"account_id\": \"acct_1Q2aJc2azLnUiqXE\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts/login","description":"<p>The <code>POST /api/v1/connected-accounts/login</code> endpoint is used to log in to a connected account in the commercecore-payment-service. The request should include a JSON payload with the <code>account_id</code> field.</p>\n<h3 id=\"response\">Response</h3>\n<p>The response of this request follows the JSON schema below:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n  \"type\": \"object\",\n  \"properties\": {\n    \"token\": {\n      \"type\": \"string\"\n    },\n    \"expires_in\": {\n      \"type\": \"integer\"\n    }\n  }\n}\n\n</code></pre>\n<p>The response object includes the <code>token</code> (a string) and <code>expires_in</code> (an integer) properties.</p>\n","urlObject":{"path":["api","v1","connected-accounts","login"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"65955f2b-b444-4084-a855-ea3c70d94c24","name":"Error Complete Unboarding","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"account_id\": \"acct_1Q05C3FNeyusjZzz\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/connected-accounts/login"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Tue, 17 Sep 2024 17:52:40 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"165"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"detail\": \"An error occurred while creating the login link.Request req_SnAXAgrgUIRQPm: Cannot create a login link for an account that has not completed onboarding.\"\n}"}],"_postman_id":"ff769ff8-1d4d-4208-84de-6f95888e85b7"},{"name":"Delete Account","id":"8ae4447b-e8cb-458f-aa8f-8ae12983a582","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"DELETE","header":[{"key":"X-Developer-Token","value":"b9f10f7c-4743-4423-a2c0-888168864f5d","type":"text"}],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts/acct_1Q2aJc2azLnUiqXE","urlObject":{"path":["api","v1","connected-accounts","acct_1Q2aJc2azLnUiqXE"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[],"_postman_id":"8ae4447b-e8cb-458f-aa8f-8ae12983a582"},{"name":"Retrieve Connected Accounts","id":"7c3ab9c2-0300-4b20-be59-5899a004cb36","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"X-Developer-Token","value":"","type":"text"}],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts/acct_1Q1uwPFKeQfUzMzl","urlObject":{"path":["api","v1","connected-accounts","acct_1Q1uwPFKeQfUzMzl"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"6a293f0d-a567-44f5-8f10-2e98fcf04cc9","name":"Retrieve Connected Accounts","originalRequest":{"method":"GET","header":[{"key":"X-Developer-Token","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzI3MDUzNjY2LCJpYXQiOjE3MjY5NjcyNjYsImp0aSI6ImNkZDlmMmYzZGJmZTQzMzQ4ZDBmOWQ4YzFkYWRhMjdjIiwidXNlcl9pZCI6InVzcl8xbzVWZzlaN1VXNThlN1FNQ2wwUnp4XzcwIiwiZGV2ZWxvcGVyX2lkIjoiZGVfZ3NyczR0Zk55TjlaVi1VSjVMNmNlYWNzbSIsImFwcF9pZHMiOlsiYXBfTFdPQzhDTHM1dTEyZ2RkSzBKWkpkcnV2QyJdfQ.hono9VpXsUsvfb3dq-IElm9Rg-0FiI_qvEvYERWHvwY","type":"text","disabled":true},{"key":"X-Developer-Token","value":"<Token>","type":"text"}],"url":"http://127.0.0.1:8000/api/v1/connected-accounts/acct_1Q1uwPFKeQfUzMzl"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Sun, 22 Sep 2024 18:58:10 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"446"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"data\": {\n        \"account_id\": \"acct_1Q1uwPFKeQfUzMzl\",\n        \"metadata\": {\n            \"developer_id\": \"de_gsrs4tfNyN9ZV-UJ5L6ceacsm\"\n        },\n        \"email\": \"johndoe@example.com\",\n        \"capabilities\": {\n            \"bank_transfer_payments\": \"inactive\",\n            \"card_payments\": \"inactive\",\n            \"link_payments\": \"inactive\",\n            \"transfers\": \"inactive\",\n            \"us_bank_transfer_payments\": \"inactive\"\n        },\n        \"created\": 1727031330\n    },\n    \"meta\": {\n        \"status_code\": 200\n    },\n    \"links\": {\n        \"self\": \"http://127.0.0.1:8000/api/v1/connected-accounts/acct_1Q1uwPFKeQfUzMzl\"\n    }\n}"},{"id":"14c567a1-3999-4f0d-a04b-abca9b4b72cb","name":"404 Unauthorized","originalRequest":{"method":"GET","header":[{"key":"X-Developer-Token","value":"<Token>","description":"Token of the developer","type":"text"},{"key":"X-User-ID","value":"<ID>","description":"User ID of the user initiating the transaction","type":"text"},{"key":"X-APP-ID","value":"<ID>","description":"The app ID of the app been used","type":"text"}],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts/acct_1Q1uwPFKeQfUzMzl"},"status":"Unauthorized","code":401,"_postman_previewlanguage":"json","header":[{"key":"Report-To","value":"{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"https://nel.heroku.com/reports?ts=1727256545&sid=c46efe9b-d3d2-4a0c-8c76-bfafa16c5add&s=XcX7KvB%2ByG0MPaS5trWr42BI5n4bW%2BRpKjOGIvfiYMc%3D\"}]}"},{"key":"Reporting-Endpoints","value":"heroku-nel=https://nel.heroku.com/reports?ts=1727256545&sid=c46efe9b-d3d2-4a0c-8c76-bfafa16c5add&s=XcX7KvB%2ByG0MPaS5trWr42BI5n4bW%2BRpKjOGIvfiYMc%3D"},{"key":"Nel","value":"{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}"},{"key":"Connection","value":"keep-alive"},{"key":"Date","value":"Wed, 25 Sep 2024 09:29:05 GMT"},{"key":"Server","value":"uvicorn"},{"key":"Content-Length","value":"25"},{"key":"Content-Type","value":"application/json"},{"key":"Via","value":"1.1 vegur"}],"cookie":[],"responseTime":null,"body":"{\n    \"detail\": \"Unauthorized\"\n}"}],"_postman_id":"7c3ab9c2-0300-4b20-be59-5899a004cb36"}],"id":"d12a8f3a-e727-44e1-92ab-5ea8da429f94","description":"<h2 id=\"overview\">Overview</h2>\n<p>The Connected Accounts functionality in the CommerceCore Payment Microservice provides endpoints for managing and interacting with connected Stripe accounts. This feature is crucial for platforms that need to onboard sellers, service providers, or other entities that will receive payments through the platform.</p>\n<h2 id=\"endpoints\">Endpoints</h2>\n<h3 id=\"1-create-connected-account\">1. Create Connected Account</h3>\n<p><strong>Endpoint:</strong> <code>POST /connected-accounts</code></p>\n<p>This endpoint allows you to create a new connected account in Stripe.</p>\n<h4 id=\"request-headers\">Request Headers:</h4>\n<ul>\n<li><code>X-Developer-Token</code>: A developer token for authentication</li>\n</ul>\n<h4 id=\"request-body\">Request Body:</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"email\": \"example@example.com\"\n}\n\n</code></pre>\n<h4 id=\"response\">Response:</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\": {\n        \"account_id\": \"acct_xxxxxxxxxxxxxxxx\",\n        \"public_key\": \"pk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n        \"message\": \"Connected account created successfully onboarding link expires in 18 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts,\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx\"\n    }\n}\n\n</code></pre>\n<h3 id=\"2-onboarding\">2. Onboarding</h3>\n<p><strong>Endpoint:</strong> <code>POST /api/v1/connected-accounts/onboarding</code></p>\n<p>This endpoint is used to initiate or continue the onboarding process for a connected account.</p>\n<h4 id=\"request-headers-1\">Request Headers:</h4>\n<ul>\n<li><code>X-Developer-Token</code>: A developer token for authentication</li>\n</ul>\n<h4 id=\"request-body-1\">Request Body:</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"account_id\": \"acct_xxxxxxxxxxxxxxxx\"\n}\n\n</code></pre>\n<h4 id=\"response-1\">Response:</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\": {\n        \"message\": \"Onboarding link expires in 13 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/connected-accounts/onboarding,\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_1Q05C3FNeyusjZzz/j4wOPU7xxxxxxxxm4WzN\"\n    }\n}\n\n</code></pre>\n<h3 id=\"3-login-dashboard\">3. Login Dashboard</h3>\n<p><strong>Endpoint:</strong> <code>POST /api/v1/connected-accounts/login</code></p>\n<p>This endpoint generates a login link for the connected account's Stripe dashboard.</p>\n<h4 id=\"request-headers-2\">Request Headers:</h4>\n<ul>\n<li>Authorization: Bearer token</li>\n</ul>\n<h4 id=\"request-body-2\">Request Body:</h4>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"account_id\": \"acct_xxxxxxxxxxxxxxxx\"\n}\n\n</code></pre>\n<h4 id=\"response-2\">Response:</h4>\n<p>The response will contain a login link for the Stripe dashboard. If the account has not completed onboarding, an error will be returned:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"detail\": \"An error occurred while creating the login link. Request req_xxxxxxxxxxxxxxxx: Cannot create a login link for an account that has not completed onboarding.\"\n}\n\n</code></pre>\n<h2 id=\"important-notes\">Important Notes</h2>\n<ol>\n<li><p><strong>Authentication</strong>: All endpoints require authentication, typically using a developer token provided in the <code>X-Developer-Token</code> header.</p>\n</li>\n<li><p><strong>Onboarding Process</strong>: After creating a connected account, the account must complete the onboarding process before it can be fully utilized. The onboarding URL is provided in the response when creating a connected account.</p>\n</li>\n<li><p><strong>Login Link Expiration</strong>: The login link for the Stripe dashboard is temporary and will expire after a certain period.</p>\n</li>\n<li><p><strong>Error Handling</strong>: The API provides detailed error messages, which should be handled appropriately in your application.</p>\n</li>\n<li><p><strong>Account ID</strong>: The <code>account_id</code> is a crucial identifier for most operations related to connected accounts. It's provided when creating an account and should be stored for future use.</p>\n</li>\n<li><p><strong>Public Key</strong>: Each connected account gets its own public key, which can be used for client-side operations specific to that account.</p>\n</li>\n<li><p><strong>Stripe Integration</strong>: This API appears to be a wrapper around Stripe's Connect API, simplifying the process of managing connected accounts within your platform.</p>\n</li>\n</ol>\n","_postman_id":"d12a8f3a-e727-44e1-92ab-5ea8da429f94"},{"name":"API Health and Status","item":[{"name":"API Root","id":"c9ddbefa-672a-450b-86d0-d96d9693663c","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1","urlObject":{"path":["api","v1"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"3df9e8c6-21df-4cb5-a8a2-8db6ce2d46dc","name":"Root Response","originalRequest":{"method":"GET","header":[],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Sat, 21 Sep 2024 23:42:22 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"522"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"message\": \"Welcome to CommerceCore Payment Service API\",\n    \"version\": \"v1\",\n    \"timpstamp\": \"2024-09-22 00:42:22.137597\",\n    \"starter_endpoints\": {\n        \"create_connected_account\": \"/api/v1/connected-accounts\",\n        \"continue_onboarding\": \"/api/v1/connected-accounts/onboarding\",\n        \"login_account_dashboard\": \"/api/v1/connected-accounts/login\",\n        \"create_transaction\": \"/api/v1/transactions\",\n        \"confirm_transaction\": \"/api/v1/transactions/confirm\",\n        \"request_refund\": \"/api/v1/refunds\"\n    },\n    \"documentation\": \"https://documenter.getpostman.com/view/36378381/2sAXqtb23\"\n}"}],"_postman_id":"c9ddbefa-672a-450b-86d0-d96d9693663c"},{"name":"API Status","id":"a97f2690-d55d-4d56-b932-b0b542994b1f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/status","urlObject":{"path":["api","v1","status"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"5403c912-1a0b-4648-9e8b-cf69998f9e00","name":"API Status","originalRequest":{"method":"GET","header":[],"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/status"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Sat, 21 Sep 2024 23:44:55 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"188"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"status\": \"ok\",\n    \"service\": \"The Payment Service\",\n    \"timestamp\": \"2024-09-22 00:44:56.093179\",\n    \"base_url\": \"https://commercecore-payment-service.onrender.com/api/v1\",\n    \"database_status\": \"connected\"\n}"}],"_postman_id":"a97f2690-d55d-4d56-b932-b0b542994b1f"}],"id":"98abed4a-fe6c-465a-82e0-753db607dce9","description":"<p>This contains the status and health of the api</p>\n","_postman_id":"98abed4a-fe6c-465a-82e0-753db607dce9"},{"name":"Transactions","item":[{"name":"Create Transaction","id":"a86a38b4-c638-468a-a8e1-ba498247d107","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"X-Developer-Token","value":"9080d9ea-a700-4eeb-9374-4034901e351e","type":"text"},{"key":"X-User-ID","value":"32e5a206-8aa5-49ab-b074-9d6a529cc42f","type":"text"},{"key":"X-App-ID","value":"6c9f4861-7e4e-4825-b636-c26430bb9220","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"order_id\":\"01922494-61b1-74e6-9d0c-0a04717d13e4\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/transactions","urlObject":{"path":["api","v1","transactions"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"597886cd-13b0-40d0-a21a-e7f6f44598d2","name":"Initiated Transaction","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"order_id\": \"01922494-61b1-74e6-9d0c-0a04717d13e4\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/transactions"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Tue, 17 Sep 2024 23:28:17 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"302"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"data\": {\n        \"client_secret\": \"pi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDESwtWsq\",\n        \"status\": \"requires_payment_method\",\n        \"transaction_id\": \"pi_3Q0AohFNeyusjZzz0MFRwI7M\"\n    },\n    \"meta\": {\n        \"message\": \"Payment initiated successfully\",\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": \"http://127.0.0.1:8000/api/v1/transactions\"\n    }\n}"},{"id":"f166f2ee-0059-49a5-8567-46f49537bba9","name":"Failure to Connect to Third Service","originalRequest":{"method":"POST","header":[{"key":"X-Developer-Token","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzI2OTM1NTA5LCJpYXQiOjE3MjY4NDkxMDksImp0aSI6IjQ3MmNkZjEzOTkzMjQ3ODdhYzE4MGExN2E0NWEzNmM5IiwidXNlcl9pZCI6InVzcl90M2hiWWlEbHh3RjBXUjZ6NDlGeW1WZ18yIiwiZGV2ZWxvcGVyX2lkIjoiZGVfOHZETC1MLWdBZjI0UnJBek1PZmdMQldoQSIsImFwcF9pZHMiOlsiYXBfM1BUTThMRlVjZmRsV19uakxwZmNTbUFKNiJdfQ.TUPaMsu2_296IheypiMiymoEkkDD4UCQ6um0JGqF3Us","type":"text"},{"key":"X-User-ID","value":"usr_t3hbYiDlxwF0WR6z49FymVg_2","type":"text"},{"key":"X-App-ID","value":"ap_3PTM8LFUcfdlW_njLpfcSmAJ6","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"order_id\": \"2227222\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-service.onrender.com/api/v1/transactions"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"json","header":[{"key":"Date","value":"Sat, 21 Sep 2024 14:13:15 GMT"},{"key":"Content-Type","value":"application/json"},{"key":"Content-Length","value":"180"},{"key":"Connection","value":"keep-alive"},{"key":"CF-Ray","value":"8c6aa79fbd6f0bc5-AMS"},{"key":"CF-Cache-Status","value":"DYNAMIC"},{"key":"Content-Encoding","value":"br"},{"key":"Vary","value":"Accept-Encoding"},{"key":"rndr-id","value":"8ef2a6b2-cd40-4427"},{"key":"x-render-origin-server","value":"uvicorn"},{"key":"Server","value":"cloudflare"}],"cookie":[],"responseTime":null,"body":"{\n    \"error\": \"Internal Server Error\",\n    \"meta\": {\n        \"success\": false,\n        \"status_code\": 500,\n        \"request_method\": \"POST\",\n        \"request_path\": \"https://commercecore-payment-service.onrender.com/api/v1/transactions\"\n    },\n    \"details\": {\n        \"message\": \"All connection attempts failed\"\n    }\n}"}],"_postman_id":"a86a38b4-c638-468a-a8e1-ba498247d107"},{"name":"Confirm Transaction","id":"ac02217a-803e-42e0-8504-87ec27c7a2bd","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"X-Developer-Token","value":"9080d9ea-a700-4eeb-9374-4034901e351e","type":"text"},{"key":"X-User-ID","value":"32e5a206-8aa5-49ab-b074-9d6a529cc42f","type":"text"},{"key":"X-APP-ID","value":"6c9f4861-7e4e-4825-b636-c26430bb9220","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"payment_method_id\":\"pm_card_visa\",\r\n    \"transaction_id\":\"pi_3QDm1PFWESP12sz21OLo3zE4\",\r\n    \"account_id\": \"acct_1QDlglFLJMa7tjMS\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/transactions/confirm","urlObject":{"path":["api","v1","transactions","confirm"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"3e820ec1-ccb1-48da-9895-8d05eac8067c","name":"Payment Already Confirmed","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"account_id\":\"acct_1Q05C3FNeyusjZzz\",\r\n    \"payment_method_id\":\"pm_card_visa\",\r\n    \"transaction_id\":\"pi_3Q0AohFNeyusjZzz0MFRwI7M\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/transactions/confirm"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Wed, 18 Sep 2024 02:17:27 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"295"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"detail\": \"An error occurred while confirming the payment intentRequest req_g66SutHWZA1AEi: You cannot confirm this PaymentIntent because it has already succeeded after being previously confirmed. Check if the payment method is valid, and also check if you havecompleted the onboarding process\"\n}"},{"id":"2e63f464-77e3-48ff-b785-2b4d4a28fd47","name":"Confirm Transaction","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"account_id\":\"acct_1Q05C3FNeyusjZzz\",\r\n    \"payment_method_id\":\"pm_card_visa\",\r\n    \"transaction_id\":\"pi_3Q1QX8FNeyusjZzz1P1mzgXX\"\r\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/api/v1/transactions/confirm"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Sat, 21 Sep 2024 12:34:18 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"247"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"data\": {\n        \"message\": \"Payment confirmed successfully\",\n        \"status_code\": 200,\n        \"account_id\": \"acct_xxxxxxxxxxxx\"\n    },\n    \"meta\": {\n        \"message\": \"Payment confirmed successfully\",\n        \"status_code\": 200\n    },\n    \"links\": {\n        \"self\": \"http://127.0.0.1:8000/api/v1/transactions/confirm\"\n    }\n}"},{"id":"fa030350-8381-495e-850a-3783a8d3da9b","name":"No account Id passed","originalRequest":{"method":"POST","header":[{"key":"X-Developer-Token","value":"<Developer_Token>","type":"text"},{"key":"X-User-ID","value":"<ID>","type":"text"},{"key":"X-APP-ID","value":"<ID>","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"payment_method_id\":\"pm_card_visa\",\r\n    \"transaction_id\":\"pi_xxxxxxxxxxxxxxxxx\"\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/transactions/confirm"},"status":"Internal Server Error","code":500,"_postman_previewlanguage":"json","header":[{"key":"Report-To","value":"{\"group\":\"heroku-nel\",\"max_age\":3600,\"endpoints\":[{\"url\":\"https://nel.heroku.com/reports?ts=1727341943&sid=c46efe9b-d3d2-4a0c-8c76-bfafa16c5add&s=TvpOqCkR2JitRV15hxPBRHyEzOT%2BjWDFW%2Bv2b4SyaGs%3D\"}]}"},{"key":"Reporting-Endpoints","value":"heroku-nel=https://nel.heroku.com/reports?ts=1727341943&sid=c46efe9b-d3d2-4a0c-8c76-bfafa16c5add&s=TvpOqCkR2JitRV15hxPBRHyEzOT%2BjWDFW%2Bv2b4SyaGs%3D"},{"key":"Nel","value":"{\"report_to\":\"heroku-nel\",\"max_age\":3600,\"success_fraction\":0.005,\"failure_fraction\":0.05,\"response_headers\":[\"Via\"]}"},{"key":"Connection","value":"keep-alive"},{"key":"Date","value":"Thu, 26 Sep 2024 09:12:22 GMT"},{"key":"Server","value":"uvicorn"},{"key":"Content-Length","value":"242"},{"key":"Content-Type","value":"application/json"},{"key":"Via","value":"1.1 vegur"}],"cookie":[],"responseTime":null,"body":"{\n    \"error\": \"Internal Server Error\",\n    \"meta\": {\n        \"success\": false,\n        \"status_code\": 500,\n        \"request_method\": \"POST\",\n        \"request_path\": \"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/transactions/confirm\"\n    },\n    \"details\": {\n        \"message\": \"'account_id'\"\n    }\n}"}],"_postman_id":"ac02217a-803e-42e0-8504-87ec27c7a2bd"}],"id":"947dcbe0-7a80-4c0e-ae00-724b2e08e932","_postman_id":"947dcbe0-7a80-4c0e-ae00-724b2e08e932","description":""},{"name":"Refund","item":[{"name":"Request Refund","id":"bd798a42-dbad-463b-a58a-26e9ae32f6ec","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"noauth","isInherited":false},"method":"POST","header":[{"key":"X-Developer-Token","value":"<Token>","type":"text"},{"key":"X-App-ID","value":"<ID>","type":"text"},{"key":"X-User-ID","value":"<ID>","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"order_id\": \"2227222\",\r\n    \"account_id\": \"acct_xxxxxxxxxxxxxxx\"\r\n\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/refunds","description":"<h3 id=\"create-a-refund\">Create a Refund</h3>\n<p>This endpoint allows you to create a refund for a specific order.</p>\n<h4 id=\"request-body\">Request Body</h4>\n<ul>\n<li><p><code>order_id</code> (string, required): The ID of the order for which the refund is being created.</p>\n</li>\n<li><p><code>account_id</code> (string, required): The ID of the account to which the refund should be credited.</p>\n</li>\n</ul>\n<h4 id=\"response\">Response</h4>\n<p>The response will include the status of the refund creation.</p>\n","urlObject":{"path":["api","v1","refunds"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[{"id":"674dbf1c-f2e4-4ad3-bf1b-45daad1af4ca","name":"Provide App Id","originalRequest":{"method":"POST","header":[],"url":"http://127.0.0.1:8000/api/v1/refunds"},"status":"Bad Request","code":400,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Tue, 17 Sep 2024 18:35:37 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"204"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"error\": \"Bad Request\",\n    \"meta\": {\n        \"success\": false,\n        \"status_code\": 400,\n        \"request_method\": \"POST\",\n        \"request_path\": \"http://127.0.0.1:8000/api/v1/refunds\"\n    },\n    \"details\": {\n        \"message\": \"Provide app_id as a query parameter\"\n    }\n}"},{"id":"43935f92-468a-4538-acf7-63965b486708","name":"Provide User Token","originalRequest":{"method":"POST","header":[],"url":{"raw":"http://127.0.0.1:8000/api/v1/refunds?app_id=ap_3PTM8LFUcfdlW_njLpfcSmAJ6","protocol":"http","host":["127","0","0","1"],"port":"8000","path":["api","v1","refunds"],"query":[{"key":"app_id","value":"ap_3PTM8LFUcfdlW_njLpfcSmAJ6"}]}},"status":"Unauthorized","code":401,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Tue, 17 Sep 2024 18:43:23 GMT"},{"key":"server","value":"uvicorn"},{"key":"x-user-token","value":"Bearer"},{"key":"content-length","value":"60"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"detail\": \"Please provide a valid user token in the header\"\n}"}],"_postman_id":"bd798a42-dbad-463b-a58a-26e9ae32f6ec"}],"id":"952185d7-94b6-4220-8bc1-f94e917ee9d0","_postman_id":"952185d7-94b6-4220-8bc1-f94e917ee9d0","description":""},{"name":"Payment Method","item":[{"name":"Create Payment Method","id":"e95b6805-3133-4be9-b6b7-b2c23d442264","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"X-User-ID","value":"7e84e1a5-5fd7-4ba0-9fa1-a4c74f2c8a60","type":"text"},{"key":"X-Developer-Token","value":"8659920e-245c-44ce-8269-3a696d90194f","type":"text"},{"key":"X-App-ID","value":"bf98189f-09d5-4a18-99b7-989e0a5ff96a","type":"text"}],"body":{"mode":"raw","raw":"{\r\n     \"payment_method_id\":\"pm_card_visa\",\r\n        \"type\": \"card\",\r\n        \"preferred\":false\r\n}","options":{"raw":{"language":"json"}}},"url":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/payment-methods","urlObject":{"path":["api","v1","payment-methods"],"host":["https://commercecore-payment-api-bbdd0516ee91.herokuapp.com"],"query":[],"variable":[]}},"response":[],"_postman_id":"e95b6805-3133-4be9-b6b7-b2c23d442264"}],"id":"2b693fe9-c7d5-4010-be51-edb3ef3791bb","_postman_id":"2b693fe9-c7d5-4010-be51-edb3ef3791bb","description":""}],"id":"f6e8d1d7-ca24-4888-858d-a17c2744f1bd","description":"<h2 id=\"1overview\">1.Overview</h2>\n<p>Version 1 of the CommerceCore Payment Microservice API provides a comprehensive set of endpoints for managing payment operations in e-commerce applications. This API is designed to work seamlessly with Stripe's payment infrastructure while offering additional features and abstractions tailored for the CommerceCore ecosystem.</p>\n<p>Key features of Version 1 include:</p>\n<ul>\n<li><p>Management of Connected Accounts for multi-seller platforms</p>\n</li>\n<li><p>Processing of transactions with a two-step (create and confirm) approach</p>\n</li>\n<li><p>Handling of refunds</p>\n</li>\n<li><p>Secure authentication and authorization mechanisms</p>\n</li>\n<li><p>Comprehensive error reporting</p>\n</li>\n</ul>\n<p>This version of the API is suitable for a wide range of e-commerce applications, from single-vendor stores to complex multi-seller marketplaces.</p>\n<h2 id=\"2-base-url\">2. Base URL</h2>\n<p>All API requests should be made to the following base URL:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1\n\n</code></pre>\n<h2 id=\"3-authentication\">3. Authentication</h2>\n<p>The API uses a multi-layered authentication system to ensure security and proper attribution of actions. Different endpoints may require different combinations of the following authentication methods:</p>\n<ol>\n<li><p>CopyX-Developer-Token:</p>\n</li>\n<li><p>CopyX-User-ID:</p>\n</li>\n<li><p>CopyX-App-ID:</p>\n</li>\n</ol>\n<p>Ensure that you include the required headers for each endpoint as specified in their individual documentation.</p>\n<h2 id=\"4-connected-accounts\">4. Connected Accounts</h2>\n<p>Connected Accounts allow platforms to create and manage Stripe accounts for their sellers or service providers. This feature is crucial for marketplaces and multi-seller platforms.</p>\n<h3 id=\"41-create-connected-account\">4.1 Create Connected Account</h3>\n<p>Creates a new Stripe Connected Account for a seller on your platform.</p>\n<p><strong>Endpoint:</strong> <code>POST /connected-accounts</code></p>\n<p><strong>Authentication:</strong></p>\n<ul>\n<li>Required: <code>X-Developer-Token</code></li>\n</ul>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"email\": \"seller@example.com\"\n}\n\n</code></pre>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\": {\n        \"account_id\": \"acct_1Q05C3FNeyusjZzz\",\n        \"public_key\": \"pk_test_51PwVFgRoSQz2jDzeW3pxV97ssjskassdaeeaeeDuNBNLC......\",\n        \"message\": \"Connected account created successfully onboarding link expires in 18 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.comapi/v1/connected-accounts,\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_1Q05C3FNeyusjZzz....\"\n    }\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p>201: Created successfully</p>\n</li>\n<li><p>401: Unauthorized (invalid or missing developer token)</p>\n</li>\n</ul>\n<p><strong>Important Notes:</strong></p>\n<ul>\n<li><p>The <code>onboarding_url</code> in the response is crucial. Direct your seller to this URL to complete their account setup.</p>\n</li>\n<li><p>The onboarding link expires after 18 hours. Ensure your seller completes the process within this timeframe.</p>\n</li>\n<li><p>Store the <code>account_id</code> securely. You'll need it for future operations related to this seller.</p>\n</li>\n</ul>\n<h3 id=\"42-connected-account-onboarding\">4.2 Connected Account Onboarding</h3>\n<p>Initiates or checks the status of the onboarding process for a connected account.</p>\n<p>Please note that accounts that have not yet completed onboarding will be restricted to</p>\n<p>certain level of transactions.</p>\n<p><strong>Endpoint:</strong> <code>POST /connected-accounts/onboarding</code></p>\n<p><strong>Authentication:</strong></p>\n<ul>\n<li>Required: <code>X-Developer-Token</code></li>\n</ul>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"account_id\": \"acct_1Q05C3FNeyusjZzz\"\n}\n\n</code></pre>\n<p><strong>Response:</strong><br />The exact response format is not provided in the collection, but it typically includes:</p>\n<ul>\n<li><p>The current status of the onboarding process</p>\n</li>\n<li><p>Any missing information required to complete onboarding</p>\n</li>\n<li><p>A new onboarding URL if the previous one has expired</p>\n</li>\n</ul>\n<h3 id=\"43-login-to-connected-account-dashboard\">4.3 Login to Connected Account Dashboard</h3>\n<p>Generates a login link for a connected account's Stripe dashboard.</p>\n<p><strong>Endpoint:</strong> <code>POST /connected-accounts/login</code></p>\n<p><strong>Authentication:</strong></p>\n<ul>\n<li>Required: Bearer Token</li>\n</ul>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"account_id\": \"acct_1Q05C3FNeyusjZzz\"\n}\n\n</code></pre>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\": {\n        \"message\": \"Onboarding link expires in 13 hours use the 'onboarding_url' to complete the onboarding\"\n    },\n    \"meta\": {\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": \"http://127.0.0.1:8000/api/v1/connected-accounts/onboarding\",\n        \"onboarding_url\": \"https://connect.stripe.com/setup/e/acct_1Q05C3FNeyusjZzz/j4wO\"\n    }\n}\n\n</code></pre>\n<ul>\n<li>A one-time use URL for logging into the Stripe dashboard</li>\n</ul>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p>201: Created successfully</p>\n</li>\n<li><p>401: Unauthorized (invalid or missing developer token)</p>\n</li>\n<li><p>StartFragment500: Internal Server Error (if account hasn't completed onboarding)</p>\n</li>\n</ul>\n<p><strong>Important Notes:</strong></p>\n<ul>\n<li><p>The login link is temporary and should be used immediately.</p>\n</li>\n<li><p>This feature allows sellers to access their own Stripe dashboard for detailed reporting and account management.</p>\n</li>\n<li><p>Ensure the account has completed onboarding before attempting to generate a login link.</p>\n</li>\n</ul>\n<h2 id=\"5-transactions\">5. Transactions</h2>\n<p>The Transactions endpoints handle the creation and confirmation of payments.</p>\n<h3 id=\"51-create-transaction\">5.1 Create Transaction</h3>\n<p>Initiates a new transaction (creates a PaymentIntent in Stripe terminology).</p>\n<p><strong>Endpoint:</strong> <code>POST /transactions</code></p>\n<p><strong>Authentication:</strong></p>\n<ul>\n<li>Required: <code>X-Developer-Token</code>, <code>X-User-ID</code>, <code>X-App-ID</code></li>\n</ul>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"order_id\": \"2227222\",\n    \"account_id\": \"acct_xxxxxxxxxxxx\",\n    \"amount\": \"1000\"\n}\n\n</code></pre>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\"\",\n        \"status\": \"requires_payment_method\",\n        \"transaction_id\": \"pi_xxxxxxxxxxxxxxxxxx\"\n    },\n    \"meta\": {\n        \"message\": \"Payment initiated successfully\",\n        \"status_code\": 201\n    },\n    \"links\": {\n        \"self\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/transactions\n    }\n}\n\n</code></pre>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li>201: Created successfully</li>\n</ul>\n<p><strong>Important Notes:</strong></p>\n<ul>\n<li><p>The <code>amount</code> is in the smallest currency unit (e.g., cents for USD).</p>\n</li>\n<li><p>The <code>client_secret</code> is crucial for completing the payment on the client-side. Handle it securely.</p>\n</li>\n<li><p>The <code>transaction_id</code> (Stripe's PaymentIntent ID) is needed for the confirmation step.</p>\n</li>\n<li><p>if you don't know how to use stripe client <a href=\"https://docs.stripe.com/js\">read more on that</a></p>\n</li>\n</ul>\n<h3 id=\"52-confirm-transaction\">5.2 Confirm Transaction</h3>\n<p>Confirms a previously initiated transaction after the customer has provided payment details.</p>\n<p><strong>Endpoint:</strong> <code>POST /transactions/confirm</code></p>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"account_id\": \"acct_1Q05C3FNeyusjZzz\",\n    \"payment_method_id\": \"pm_card_visa\",\n    \"transaction_id\": \"pi_3Q1JMrFNeyusjZzz1RxOU8wm\"\n}\n\n</code></pre>\n<p><strong>Response:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"data\": {\n        \"message\": \"Payment confirmed successfully\",\n        \"status_code\": 200,\n        \"account_id\": \"acct_1Q05C3F21133\"\n    },\n    \"meta\": {\n        \"message\": \"Payment confirmed successfully\",\n        \"status_code\": 200\n    },\n    \"links\": {\n        \"self\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/transactions/confirm\n    }\n}\n\n</code></pre>\n<p>Typically includes:</p>\n<ul>\n<li>The final status of the transaction (succeeded, failed, requires action, etc.)</li>\n</ul>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p>500: Internal Server Error (if payment has already been confirmed)</p>\n</li>\n<li><p>201: Created successfully</p>\n</li>\n</ul>\n<p><strong>Important Notes:</strong></p>\n<ul>\n<li><p>Only confirm a transaction once. Attempting to confirm an already confirmed transaction will result in an error.</p>\n</li>\n<li><p>The <code>payment_method_id</code> should be obtained from the client-side after the customer enters their payment details.</p>\n</li>\n</ul>\n<h2 id=\"6-refunds\">6. Refunds</h2>\n<p>The Refunds endpoint allows you to process refunds for completed transactions.</p>\n<h3 id=\"61-request-refund\">6.1 Request Refund</h3>\n<p>Initiates a refund for a previously completed transaction.</p>\n<p><strong>Endpoint:</strong> <code>POST /refunds</code></p>\n<p><strong>Authentication:</strong></p>\n<ul>\n<li>Required: <code>X-User-ID</code>, <code>X-Developer-Token</code>, <code>X-App-ID</code></li>\n</ul>\n<p><strong>Request Body:</strong></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"order_id\": \"2227222\",\n    \"account_id\": \"acct_1Q05C3FNeyusjZzz\"\n}\n\n</code></pre>\n<p><strong>Response:</strong><br />The exact response format is not provided in the collection, but it typically includes:</p>\n<ul>\n<li><p>The status of the refund request</p>\n</li>\n<li><p>The refunded amount</p>\n</li>\n<li><p>A refund ID for future reference</p>\n</li>\n</ul>\n<p><strong>Status Codes:</strong></p>\n<ul>\n<li><p>400: Bad Request (if app_id is not provided)</p>\n</li>\n<li><p>401: Unauthorized (if user token is not provided)</p>\n</li>\n</ul>\n<p><strong>Important Notes:</strong></p>\n<ul>\n<li><p>Ensure that the <code>order_id</code> corresponds to a completed transaction.</p>\n</li>\n<li><p>Refunds are typically processed asynchronously. Your application should be prepared to handle webhook events for refund updates.</p>\n</li>\n<li><p>Partial refunds may be supported, though the current documentation doesn't specify this feature.</p>\n</li>\n</ul>\n<h2 id=\"7-error-handling\">7. Error Handling</h2>\n<p>The API uses standard HTTP status codes to indicate the success or failure of requests. In case of errors, the API returns a JSON object with details about the error.</p>\n<p>Example error response:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">jsonCopy{\n    \"error\": \"Bad Request\",\n    \"meta\": {\n        \"success\": false,\n        \"status_code\": 400,\n        \"request_method\": \"POST\",\n        \"request_path\": https://commercecore-payment-api-bbdd0516ee91.herokuapp.com/api/v1/refunds\n    },\n    \"details\": {\n        \"message\": \"Provide app_id in the header\"\n    }\n}\n\n</code></pre>\n<p>Common error scenarios to handle in your application:</p>\n<ul>\n<li><p>400 Bad Request: Check your request parameters and body</p>\n</li>\n<li><p>401 Unauthorized: Verify your authentication credentials</p>\n</li>\n<li><p>404 Not Found: Ensure you're using the correct endpoint and resource IDs</p>\n</li>\n<li><p>500 Internal Server Error: Contact CommerceCore support if this persists</p>\n</li>\n</ul>\n<h2 id=\"8-rate-limiting\">8. Rate Limiting</h2>\n<ul>\n<li><p>Implement exponential backoff in case of rate limit errors</p>\n</li>\n<li><p>Cache responses where appropriate to reduce the number of API calls</p>\n</li>\n</ul>\n<h2 id=\"9-webhook-events\">9. Webhook Events</h2>\n<ul>\n<li><p>Payment succeeded</p>\n</li>\n<li><p>Payment failed</p>\n</li>\n<li><p>Refund processed</p>\n</li>\n<li><p>Account updated</p>\n</li>\n</ul>\n<p>Implement a webhook endpoint in your application and register it with CommerceCore to receive real-time updates.</p>\n<h2 id=\"10-testing\">10. Testing</h2>\n<p>The collection includes a test payment method (<code>pm_card_visa</code>) which can be used for testing transactions in a sandbox environment.</p>\n<p>Best practices for testing:</p>\n<ul>\n<li><p>Use Stripe's test card numbers for various scenarios (successful payments, declined cards, etc.)</p>\n</li>\n<li><p>Test the entire payment flow, including refunds</p>\n</li>\n<li><p>Verify webhook handling with test events</p>\n</li>\n<li><p>To test with more stripe cards visit <a href=\"https://docs.stripe.com/testing?testing-method=payment-methods\">stripe.com</a></p>\n</li>\n</ul>\n<p>Always use test credentials and test card numbers when working in non-production environments.</p>\n","_postman_id":"f6e8d1d7-ca24-4888-858d-a17c2744f1bd"}],"event":[{"listen":"prerequest","script":{"id":"c7f018d6-81a6-4d01-b388-6a9b6f61522c","type":"text/javascript","packages":{},"exec":[""]}},{"listen":"test","script":{"id":"6e879024-c0fa-4f88-b254-22d4e4b20410","type":"text/javascript","packages":{},"exec":[""]}}],"variable":[{"key":"base_url","value":"https://commercecore-payment-api-bbdd0516ee91.herokuapp.com","type":"string"}]}