Stripe API Documentation Sample - pvega62/Portfolio GitHub Wiki

Introduction

The Stripe API allows merchants to build a platform, marketplace, or any other type of business with a solid foundation that allows for secure transactions and money movement.

The Stripe API allows a developer to:

  • Check a Stripe account's balance.
  • Retrieve an account's balance history, which includes a list of transactions (charges, payouts, etc.) that contributed to its balance.
  • List, create, update, and search for charges.
  • Create, cancel, or update refunds.

Connection Prerequisites

To connect to the Stripe API, you need the base URL: https://api.stripe.com/.

Authentication

Stripe API requires a secret API token for authentication. All requests must be authorized and made over HTTPS. Unauthorized requests or requests made over HTTP will fail.

These tokens, also called secret keys, are found on your Stripe dashboard. See Using Postman to Connect to the Stripe API for detailed instructions on generating the token and using it to authenticate your connection.

NOTE: For security purposes, the secret key must not be shared with other users.

Functionality

Balance

Obtain the balance of a Stripe account.

Endpoint: https://api.stripe.com/v1/balance.

Operation: ‘GET’.

Responses

Responses will return standard codes.

200: OK

{ "object": "balance", "available": [ { "amount": 0, "currency": "usd", "source_types": { "card": 0 } } ], "livemode": false, "pending": [ { "amount": 0, "currency": "usd", "source_types": { "card": 0 } } ] }

400: Bad Request

{ "error": { "message": "If passing an array with explicit keys (e.g.foo[0]=a&foo[1]=b) instead of as an array (e.g. foo[]=a&foo[]=b), the keys must be numeric and sequential starting from 0. You passed the keys 1, we expected to have a key with the value 0.", "param": "expand", "request_log_url": "https://dashboard.stripe.com/test/logs/req_kCeAL5FAly5bkh?t=1734734555", "type": "invalid_request_error" } }

401: Unauthorized

{ "error": { "message": "Invalid API Key provided: {{secret**ey}}", "type": "invalid_request_error" } }

Parameters

Query Parameters

  • expand [0] <string>: Specifies which fields in the response should be expanded.
  • expand [1] <string>: Specifies which fields in the response should be expanded.

Retrieve a Balance Transaction

Returns the transactions that make up the Stripe account's balance (e.g., charges, transfers, payouts, refunds, etc.). The Transactions are returned in sorted order, with the most recent transactions appearing first.

Endpoint: https://api.stripe.com/v1/balance_transactions/:id.

Operation: ‘GET’

Responses

Responses will return standard codes.

200: OK

{ "object": "balance", "available": [ { "amount": 0, "currency": "usd", "source_types": { "card": 0 } } ], "livemode": false, "pending": [ { "amount": 0, "currency": "usd", "source_types": { "card": 0 } } ] }

400: Bad Request

{ "error": { "message": "If passing an array with explicit keys (e.g.foo[0]=a&foo[1]=b) instead of as an array (e.g. foo[]=a&foo[]=b), the keys must be numeric and sequential starting from 0. You passed the keys 1, we expected to have a key with the value 0.", "param": "expand", "request_log_url": "https://dashboard.stripe.com/test/logs/req_kCeAL5FAly5bkh?t=1734734555", "type": "invalid_request_error" } }

401: Unauthorized

{ "error": { "message": "Invalid API Key provided: {{secret**ey}}", "type": "invalid_request_error" } }

Parameters

Query Parameters

  • expand[0] <string>: Specifies which fields in the response should be expanded.
  • expand[1] <string>: Specifies which fields in the response should be expanded.

Path Variables

id <string> (Required)

List all Payment Intents

Returns a list of Payment Intents.

Endpoint: https://api.stripe.com/v1/payment_intents/.

Operation: ‘GET’

Responses

Responses will return standard codes.

200: OK

{ "object": "balance", "available": [ { "amount": 0, "currency": "usd", "source_types": { "card": 0 } } ], "livemode": false, "pending": [ { "amount": 0, "currency": "usd", "source_types": { "card": 0 } } ] }

400: Bad Request

{ "error": { "message": "If passing an array with explicit keys (e.g.foo[0]=a&foo[1]=b) instead of as an array (e.g. foo[]=a&foo[]=b), the keys must be numeric and sequential starting from 0. You passed the keys 1, we expected to have a key with the value 0.", "param": "expand", "request_log_url": "https://dashboard.stripe.com/test/logs/req_kCeAL5FAly5bkh?t=1734734555", "type": "invalid_request_error" } }

401: Unauthorized

{ "error": { "message": "Invalid API Key provided: {{secret**ey}}", "type": "invalid_request_error" } }

Parameters

Query Parameters

  • created[gt] <integer>: A filter on the list, based on the object ‘created’ field. The value can be a string with an integer Unix timestamp or a dictionary with a number of different query options.
  • created[gte] <integer>: A filter on the list, based on the object ‘created’ field. The value can be a string with an integer Unix timestamp or a dictionary with a number of different query options.
  • created[lt] <integer>: A filter on the list, based on the object ‘created’ field. The value can be a string with an integer Unix timestamp or a dictionary with a number of different query options.
  • created[lte] <integer>: A filter on the list, based on the object ‘created’ field. The value can be a string with an integer Unix timestamp or a dictionary with a number of different query options.
  • customer <string> : Only return PaymentIntents for the customer that this customer ID specifies.
  • ending_before <string>: A cursor for use in pagination. ‘ending_before’ is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with ‘obj_bar’, your subsequent call can include ‘ending_before=obj_bar’ in order to fetch the previous page of the list.
  • expand[0] <string>: Specifies which fields in the response should be expanded.
  • expand[1] <string>: Specifies which fields in the response should be expanded.
  • limit <integer>: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
  • starting_after <string>: A cursor for use in pagination.‘starting_after’ is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with ‘obj_foo’, your subsequent call can include ‘starting_after=obj_foo’ in order to fetch the next page of the list.

Create a Payment Intent

Once a Payment Intent is created, attach a payment method and confirm to continue payment.

Using confirm=true during creation is equivalent to creating and confirming the Payment Intent in the same call. Applying confirm=true enables the use of any parameters in the confirm API.

Endpoint: https://api.stripe.com//v1/balance/.

Operation: ‘POST’

Responses

Responses will return standard codes.

200: OK

400: Bad Request

{ "error": { "code": "parameter_invalid_integer", "doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer", "message": "Invalid integer: <integer>", "param": "amount", "request_log_url": "https://dashboard.stripe.com/test/logs/req_UQf6XBwBl9yk66?t=1734829676", "type": "invalid_request_error" } }

401: Unauthorized

{ "error": { "message": "Invalid API Key provided: {{secret**ey}}", "type": "invalid_request_error" } }

Parameters

None

Search Payment Intents

Using Stripe’s Search Query Language, you can search for previously created Payment Intents.

Do not use the search request in read-after-write flows where strict consistency is needed. Under normal operation, data is searchable for less than a minute. Occasionally, the propagation of new or updated data can be up to an hour behind during outages.

NOTE: The search function is not available to merchants in India.

Endpoint: https://api.stripe.com/v1/payment_intents/search?query=%3cstring.

Operation: ‘GET’

Responses

Responses will return standard codes.

200: OK

{ "object": "search_result", "data": [], "has_more": false, "next_page": null, "url": "/v1/payment_intents/search" }

404: Not Found

{ "error": { "name": "mockRequestNotFoundError", "message": "Double check your method and the request path and try again.", "header": "No matching requests" } }

401: Unauthorized

{ "error": { "message": "Invalid API Key provided: {{secret**ey}}", "type": "invalid_request_error" } }

Parameters

Query Parameters

  • expand[0] <string>: Specifies which fields in the response should be expanded.
  • expand[1] <string>: Specifies which fields in the response should be expanded.
  • limit <integer>: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
  • page <string>: A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.
  • query <string>: (Required) The search query string. See search query language and the list of supported query fields for payment intents.
⚠️ **GitHub.com Fallback** ⚠️