nl
stringlengths 52
6.18k
| code
stringlengths 34
10.1k
|
---|---|
AuthenticationThe Stripe API uses API keys to authenticate requests. You can view and manage your API keys in the Stripe Dashboard.Test mode secret keys have the prefix sk_test_ and live mode secret keys have the prefix sk_live_. Alternatively, you can use restricted API keys for granular permissions.Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.Use your API key by assigning it to stripe.api_key. The Python library will then automatically send this key in each request.You can also set a per-request key with an option. This is often useful for Connect applications that use multiple API keys during the lifetime of a process. Methods on the returned object reuse the same API key.All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail. | import stripe
import stripe
charge = stripe.Charge.retrieve(
"ch_3LSdyT2eZvKYlo2C0gCKd4XD",
api_key="sk_test_your_key"
)
charge.save() # Uses the same API Key.Your API KeyA sample test API key is included in all the examples here, so you can test any example right away. Do not submit any personally identifiable information in requests made with this key.To test requests using your account, replace the sample API key with your actual API key or sign in. |
Connected AccountsClients can make requests as connected accounts using the special header Stripe-Account which should contain a Stripe account ID (usually starting with the prefix acct_).The value is set per-request as shown in the adjacent code sample. Methods on the returned object reuse the same account ID.See also Making API calls for connected accounts | import stripe
charge = stripe.Charge.retrieve(
"ch_3LSdcO2eZvKYlo2C0QI5DNPX",
stripe_account="acct_1032D82eZvKYlo2C"
)
charge.save() # Uses the same account. |
ErrorsStripe uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx range indicate an error with Stripe's servers (these are rare).Some 4xx errors that could be handled programmatically (e.g., a card is declined) include an error code that briefly explains the error reported.Attributes type string The type of error returned. One of api_error, card_error, idempotency_error, or invalid_request_error code string For some errors that could be handled programmatically, a short string indicating the error code reported. decline_code string For card errors resulting from a card issuer decline, a short string indicating the card issuer’s reason for the decline if they provide one. message string A human-readable message providing more details about the error. For card errors, these messages can be shown to your users. param string If the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field. payment_intent hash The PaymentIntent object for errors returned on a request involving a PaymentIntent.Show child attributesMore attributesExpand all charge string doc_url string payment_method hash payment_method_type string setup_intent hash source hash | '''HTTP status code summary200 - OKEverything worked as expected.400 - Bad RequestThe request was unacceptable, often due to missing a required
parameter.401 - UnauthorizedNo valid API key provided.402 - Request FailedThe parameters were valid but the request failed.403 - ForbiddenThe API key doesn't have permissions to perform the request.404 - Not FoundThe requested resource doesn't exist.409 - ConflictThe request conflicts with another request (perhaps due to
using the same idempotent key).429 - Too Many RequestsToo many requests hit the API too quickly. We recommend an
exponential backoff of your requests.500, 502, 503, 504 - Server ErrorsSomething went wrong on Stripe's end. (These are rare.)Error typesapi_errorAPI errors cover any other type of problem (e.g., a temporary
problem with Stripe's servers), and are extremely
uncommon.card_errorCard errors are the most common type of error you should
expect to handle. They result when the user enters a card that
can't be charged for some reason.idempotency_errorIdempotency errors occur when an Idempotency-Key
is re-used on a request that does not match the first request's
API endpoint and parameters.invalid_request_errorInvalid request errors arise when your request has invalid
parameters.
''' |
Handling errorsOur Client libraries raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend writing code that gracefully handles all possible API exceptions. | '''PythoncURLStripe CLIRubyPythonPHPJavaNode.jsGo.NET12345678910111213141516171819202122232425262728293031try:
# Use Stripe's library to make requests...
pass
except stripe.error.CardError as e:
# Since it's a decline, stripe.error.CardError will be caught
print('Status is: %s' % e.http_status)
print('Code is: %s' % e.code)
# param is '' in this case
print('Param is: %s' % e.param)
print('Message is: %s' % e.user_message)
except stripe.error.RateLimitError as e:
# Too many requests made to the API too quickly
pass
except stripe.error.InvalidRequestError as e:
# Invalid parameters were supplied to Stripe's API
pass
except stripe.error.AuthenticationError as e:
# Authentication with Stripe's API failed
# (maybe you changed API keys recently)
pass
except stripe.error.APIConnectionError as e:
# Network communication with Stripe failed
pass
except stripe.error.StripeError as e:
# Display a very generic error to the user, and maybe send
# yourself an email
pass
except Exception as e:
# Something else happened, completely unrelated to Stripe
pass
''' |
Expanding ResponsesMany objects allow you to request additional information as an expanded response by using the expand request parameter. This parameter is available on all API requests, and applies to the response of that request only. Responses can be expanded in two ways.In many cases, an object contains the ID of a related object in its response properties. For example, a Charge may have an associated Customer ID. Those objects can be expanded inline with the expand request parameter. ID fields that can be expanded into objects are noted in this documentation with theexpandable label.In some cases, such as the Issuing Card object's number and cvc fields, there are available fields that are not included in responses by default. You can request these fields as an expanded response by using the expand request parameter. Fields that can be included in an expanded response are noted in this documentation with the expandable label.You can expand recursively by specifying nested fields after a dot (.). For example, requesting invoice.subscription on a charge will expand the invoice property into a full Invoice object, and will then expand the subscription property on that invoice into a full Subscription object.You can use the expand param on any endpoint which returns expandable fields, including list, create, and update endpoints.Expansions on list requests start with the data property. For example, you would expand data.customers on a request to list charges and associated customers. Many deep expansions on list requests can be slow.Expansions have a maximum depth of four levels (so for example, when listing charges,data.invoice.subscription.default_source is the deepest allowed).You can expand multiple objects at once by identifying multiple items in the expand array. | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.retrieve(
'ch_3LSdrM2eZvKYlo2C1A6YRLyL',
expand=['customer', 'invoice.subscription']
)
'''Response {
"id": "ch_3LSdrM2eZvKYlo2C1A6YRLyL",
"object": "charge",
"customer": {
"id": "cu_18CHts2eZvKYlo2CbmAAQORe",
"object": "customer",
...
},
"invoice": {
"id": "in_1LSdrM2eZvKYlo2CdjHtGeNU",
"object": "invoice",
"subscription": {
"id": "su_1JbiLB2eZvKYlo2CRmgET2WF",
"object": "subscription",
...
},
...
},
...
}''' |
Idempotent RequestsThe API supports idempotency for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. For example, if a request to create a charge does not respond due to a network connection error, you can retry the request with the same idempotency key to guarantee that no more than one charge is created.To perform an idempotent request, provide an additional idempotency_key element to the request options.Stripe's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key, regardless of whether it succeeded or failed. Subsequent requests with the same key return the same result, including 500 errors.An idempotency key is a unique value generated by the client which the server uses to recognize subsequent retries of the same request. How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. Idempotency keys can be up to 255 characters long.Keys are eligible to be removed from the system automatically after they're at least 24 hours old, and a new request is generated if a key is reused after the original has been pruned. The idempotency layer compares incoming parameters to those of the original request and errors unless they're the same to prevent accidental misuse.Results are only saved if an API endpoint started executing. If incoming parameters failed validation, or the request conflicted with another that was executing concurrently, no idempotent result is saved because no API endpoint began execution. It is safe to retry these requests.All POST requests accept idempotency keys. Sending idempotency keys in GET and DELETE requests has no effect and should be avoided, as these requests are idempotent by definition. | import stripe
stripe.api_key = "sk_test_your_key"
charge = stripe.Charge.create(
amount=2000,
currency="usd",
description="My First Test Charge (created for API docs at https://www.stripe.com/docs/api)",
source="tok_amex", # obtained with Stripe.js
idempotency_key='TR1auKhAiiFBWi5b'
) |
MetadataUpdateable Stripe objects—including Account, Charge, Customer, PaymentIntent, Refund, Subscription, and Transfer—have a metadata parameter. You can use this parameter to attach key-value data to these Stripe objects.You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long.Metadata is useful for storing additional, structured information on an object. As an example, you could store your user's full name and corresponding unique identifier from your system on a Stripe Customer object. Metadata is not used by Stripe—for example, not used to authorize or decline a charge—and won't be seen by your users unless you choose to show it to them.Some of the objects listed above also support a description parameter. You can use the description parameter to annotate a charge—with, for example, a human-readable description like 2 shirts for test@example.com. Unlike metadata, description is a single string, and your users may see it (e.g., in email receipts Stripe sends on your behalf).Do not store any sensitive information (bank account numbers, card details, etc.) as metadata or in the description parameter. | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.create(
amount=2000,
currency="usd",
source="tok_visa", # obtained with Stripe.js
metadata={'order_id': '6735'}
)
'''Response {
"id": "ch_3LSdrM2eZvKYlo2C1A6YRLyL",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518844,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {
"order_id": "6735"
},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdrL2eZvKYlo2CtnWPUQ1I",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdrM2eZvKYlo2C1A6YRLyL/rcpt_MAzrg6YgiqYH9yomNqsCRuLOeTiFRBy",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdrM2eZvKYlo2C1A6YRLyL/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}''' |
PaginationAll top-level API resources have support for bulk fetches via "list" API methods. For instance, you can list charges, list customers, and list invoices. These list API methods share a common structure, taking at least these three parameters: limit, starting_after, and ending_before.Stripe's list API methods utilize cursor-based pagination via the starting_after and ending_before parameters. Both parameters take an existing object ID value (see below) and return objects in reverse chronological order. The ending_before parameter returns objects listed before the named object. The starting_after parameter returns objects listed after the named object. These parameters are mutually exclusive -- only one of starting_after orending_before may be used.Our client libraries offer auto-pagination helpers to easily traverse all pages of a list. |
'''Response {
"object": "list",
"url": "/v1/customers",
"has_more": false,
"data": [
{
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": null,
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
},
{...},
{...}
]
}''' |
SearchSome top-level API resource have support for retrieval via "search" API methods. For example, you can search charges, search customers, and search subscriptions.Stripe's search API methods utilize cursor-based pagination via the page request parameter and next_page response parameter. For example, if you make a search request and receive "next_page": "pagination_key" in the response, your subsequent call can include page=pagination_key to fetch the next page of results.Our client libraries offer auto-pagination helpers to easily traverse all pages of a search result.Search request format query required The search query string. See search query language. limit optional A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. page optional 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.Search response format object string, value is "search_result" A string describing the object type returned. url string The URL for accessing this list. has_more boolean Whether or not there are more elements available after this
set. If false, this set comprises the end of
the list. data array An array containing the actual response elements, paginated
by any request parameters. next_page string A cursor for use in pagination. If has_more is true,
you can pass the value of next_page to a subsequent call to
fetch the next page of results. total_count optional positive integer or zero expandable The total number of objects that match the query, only accurate
up to 10,000. This field is not included by default. To include it in the response, expand the total_count field |
'''Response {
"object": "search_result",
"url": "/v1/customers/search",
"has_more": false,
"data": [
{
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {
"foo": "bar"
},
"name": "fakename",
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
},
{...},
{...}
]
}''' |
Auto-paginationOur libraries support auto-pagination. This feature easily handles fetching large lists of resources without having to manually paginate results and perform subsequent requests.To use the auto-pagination feature in Python, simply issue an initial "list" call with the parameters you need, then call auto_paging_iter() on the returned list object to iterate over all objects matching your initial parameters | import stripe
stripe.api_key = "sk_test_your_key"
customers = stripe.Customer.list(limit=3)
for customer in customers.auto_paging_iter():
# Do something with customer |
Request IDsEach API request has an associated request identifier. You can find this value in the response headers, under Request-Id. You can also find request identifiers in the URLs of individual request logs in your Dashboard. If you need to contact us about a specific request, providing the request identifier will ensure the fastest possible resolution | import stripe
stripe.api_key = "sk_test_your_key"
customer = stripe.Customer.create()
print(customer.last_response.request_id) |
VersioningWhen backwards-incompatible changes are made to the API, a new, dated version is released. The current version is 2022-08-01. Read our API upgrades guide to see our API changelog and to learn more about backwards compatibility.All requests use your account API settings, unless you override the API version. The changelog lists every available version. Note that by default webhook events are structured according to your account API version, unless you set an API version during endpoint creation.To override the API version, assign the version to the stripe.api_version property, or set it per-request as shown in the adjacent code sample. When overriding it per-request, methods on the returned object reuse the same Stripe version.You can visit your Dashboard to upgrade your API version. As a precaution, use API versioning to test a new API version before committing to an upgrade. | import stripe
stripe.api_key = "sk_test_your_key"
import stripe
intent = stripe.PaymentIntent.retrieve(
"pi_1DrPsv2eZvKYlo2CEDzqXfPH",
stripe_version="2022-08-01"
)
intent.capture() |
BalanceThis is an object representing your Stripe balance. You can retrieve it to see
the balance currently on your Stripe account.You can also retrieve the balance history, which contains a list of
transactions that contributed to the balance
(charges, payouts, and so forth).The available and pending amounts for each currency are broken down further by
payment source types. | '''Endpoints GET /v1/balance
''' |
The balance objectAttributes available array of hashes Funds that are available to be transferred or paid out, whether automatically by Stripe or explicitly via the Transfers API or Payouts API. The available balance for each currency and payment type can be found in the source_types property.Show child attributes pending array of hashes Funds that are not yet available in the balance, due to the 7-day rolling pay cycle. The pending balance for each currency, and for each payment type, can be found in the source_types property.Show child attributesMore attributesExpand all object string, value is "balance" connect_reserved array of hashes Connect only instant_available array of hashes issuing hash livemode boolean | '''The balance object {
"object": "balance",
"available": [
{
"amount": 2217713,
"currency": "cad",
"source_types": {
"bank_account": 0,
"card": 2217713
}
},
{
"amount": 2685,
"currency": "nok",
"source_types": {
"bank_account": 0,
"card": 2685
}
},
{
"amount": 7254790,
"currency": "gbp",
"source_types": {
"bank_account": 0,
"card": 7254790
}
},
{
"amount": 218420,
"currency": "nzd",
"source_types": {
"bank_account": 0,
"card": 218420
}
},
{
"amount": 779902,
"currency": "czk",
"source_types": {
"bank_account": 0,
"card": 779902
}
},
{
"amount": -1854,
"currency": "aud",
"source_types": {
"bank_account": 0,
"card": -1854
}
},
{
"amount": 457105499457,
"currency": "usd",
"source_types": {
"bank_account": 367939412,
"card": 456736007919
}
},
{
"amount": -76455,
"currency": "eur",
"source_types": {
"bank_account": 0,
"card": -76455
}
},
{
"amount": -40320,
"currency": "jpy",
"source_types": {
"bank_account": 0,
"card": -40320
}
},
{
"amount": 12000,
"currency": "brl",
"source_types": {
"bank_account": 0,
"card": 12000
}
},
{
"amount": -412,
"currency": "sek",
"source_types": {
"bank_account": 0,
"card": -412
}
}
],
"connect_reserved": [
{
"amount": 0,
"currency": "cad"
},
{
"amount": 0,
"currency": "nok"
},
{
"amount": 0,
"currency": "gbp"
},
{
"amount": 0,
"currency": "nzd"
},
{
"amount": 0,
"currency": "czk"
},
{
"amount": 0,
"currency": "aud"
},
{
"amount": 83080,
"currency": "usd"
},
{
"amount": 54584,
"currency": "eur"
},
{
"amount": 0,
"currency": "jpy"
},
{
"amount": 0,
"currency": "brl"
},
{
"amount": 0,
"currency": "sek"
}
],
"livemode": false,
"pending": [
{
"amount": 0,
"currency": "cad",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "nok",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "gbp",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "nzd",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "czk",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "aud",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 2624141650,
"currency": "usd",
"source_types": {
"bank_account": 0,
"card": 2624141650
}
},
{
"amount": 0,
"currency": "eur",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "jpy",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "brl",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "sek",
"source_types": {
"bank_account": 0,
"card": 0
}
}
]
}
''' |
Retrieve balanceRetrieves the current account balance, based on the authentication that was used to make the request.
For a sample request, see Accounting for negative balances.ParametersNo parameters.ReturnsReturns a balance object for the account that was authenticated in the request | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Balance.retrieve()
'''Response {
"object": "balance",
"available": [
{
"amount": 2217713,
"currency": "cad",
"source_types": {
"bank_account": 0,
"card": 2217713
}
},
{
"amount": 2685,
"currency": "nok",
"source_types": {
"bank_account": 0,
"card": 2685
}
},
{
"amount": 7254790,
"currency": "gbp",
"source_types": {
"bank_account": 0,
"card": 7254790
}
},
{
"amount": 218420,
"currency": "nzd",
"source_types": {
"bank_account": 0,
"card": 218420
}
},
{
"amount": 779902,
"currency": "czk",
"source_types": {
"bank_account": 0,
"card": 779902
}
},
{
"amount": -1854,
"currency": "aud",
"source_types": {
"bank_account": 0,
"card": -1854
}
},
{
"amount": 457105499457,
"currency": "usd",
"source_types": {
"bank_account": 367939412,
"card": 456736007919
}
},
{
"amount": -76455,
"currency": "eur",
"source_types": {
"bank_account": 0,
"card": -76455
}
},
{
"amount": -40320,
"currency": "jpy",
"source_types": {
"bank_account": 0,
"card": -40320
}
},
{
"amount": 12000,
"currency": "brl",
"source_types": {
"bank_account": 0,
"card": 12000
}
},
{
"amount": -412,
"currency": "sek",
"source_types": {
"bank_account": 0,
"card": -412
}
}
],
"connect_reserved": [
{
"amount": 0,
"currency": "cad"
},
{
"amount": 0,
"currency": "nok"
},
{
"amount": 0,
"currency": "gbp"
},
{
"amount": 0,
"currency": "nzd"
},
{
"amount": 0,
"currency": "czk"
},
{
"amount": 0,
"currency": "aud"
},
{
"amount": 83080,
"currency": "usd"
},
{
"amount": 54584,
"currency": "eur"
},
{
"amount": 0,
"currency": "jpy"
},
{
"amount": 0,
"currency": "brl"
},
{
"amount": 0,
"currency": "sek"
}
],
"livemode": false,
"pending": [
{
"amount": 0,
"currency": "cad",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "nok",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "gbp",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "nzd",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "czk",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "aud",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 2624141650,
"currency": "usd",
"source_types": {
"bank_account": 0,
"card": 2624141650
}
},
{
"amount": 0,
"currency": "eur",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "jpy",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "brl",
"source_types": {
"bank_account": 0,
"card": 0
}
},
{
"amount": 0,
"currency": "sek",
"source_types": {
"bank_account": 0,
"card": 0
}
}
]
}''' |
Balance TransactionsBalance transactions represent funds moving through your Stripe account.
They're created for every type of transaction that comes into or flows out of your Stripe account balance. | '''Endpoints GET /v1/balance_transactions/:id GET /v1/balance_transactions
''' |
The balance transaction objectAttributes id string Unique identifier for the object. amount integer Gross amount of the transaction, in cents. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. description string An arbitrary string attached to the object. Often useful for displaying to users. fee integer Fees (in cents) paid for this transaction. fee_details array of hashes Detailed breakdown of fees (in cents) paid for this transaction.Show child attributes net integer Net amount of the transaction, in cents. source string expandable The Stripe object to which this transaction is related. status string If the transaction’s net funds are available in the Stripe balance yet. Either available or pending. type string Transaction type: adjustment, advance, advance_funding, anticipation_repayment, application_fee, application_fee_refund, charge, connect_collection_transfer, contribution, issuing_authorization_hold, issuing_authorization_release, issuing_dispute, issuing_transaction, payment, payment_failure_refund, payment_refund, payout, payout_cancel, payout_failure, refund, refund_failure, reserve_transaction, reserved_funds, stripe_fee, stripe_fx_fee, tax_fee, topup, topup_reversal, transfer, transfer_cancel, transfer_failure, or transfer_refund. Learn more about balance transaction types and what they represent. If you are looking to classify transactions for accounting purposes, you might want to consider reporting_category instead.More attributesExpand all object string, value is "balance_transaction" available_on timestamp created timestamp exchange_rate decimal reporting_category string | '''The balance transaction object {
"id": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"object": "balance_transaction",
"amount": 400,
"available_on": 1386374400,
"created": 1385814763,
"currency": "usd",
"description": "Charge for test@example.com",
"exchange_rate": null,
"fee": 42,
"fee_details": [
{
"amount": 42,
"application": null,
"currency": "usd",
"description": "Stripe processing fees",
"type": "stripe_fee"
}
],
"net": 358,
"reporting_category": "charge",
"source": "ch_1032HU2eZvKYlo2C0FuZb3X7",
"status": "available",
"type": "charge"
}
''' |
Retrieve a balance transactionRetrieves the balance transaction with the given ID.
Note that this endpoint previously used the path /v1/balance/history/:id.ParametersNo parameters.ReturnsReturns a balance transaction if a valid balance transaction ID was provided. Raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.BalanceTransaction.retrieve(
"txn_1032HU2eZvKYlo2CEPtcnUvl",
)
'''Response {
"id": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"object": "balance_transaction",
"amount": 400,
"available_on": 1386374400,
"created": 1385814763,
"currency": "usd",
"description": "Charge for test@example.com",
"exchange_rate": null,
"fee": 42,
"fee_details": [
{
"amount": 42,
"application": null,
"currency": "usd",
"description": "Stripe processing fees",
"type": "stripe_fee"
}
],
"net": 358,
"reporting_category": "charge",
"source": "ch_1032HU2eZvKYlo2C0FuZb3X7",
"status": "available",
"type": "charge"
}''' |
List all balance transactionsReturns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history.Parameters payout optional For automatic Stripe payouts only, only returns transactions that were paid out on the specified payout ID. type optional Only returns transactions of the given type. One of: adjustment, advance, advance_funding, anticipation_repayment, application_fee, application_fee_refund, charge, connect_collection_transfer, contribution, issuing_authorization_hold, issuing_authorization_release, issuing_dispute, issuing_transaction, payment, payment_failure_refund, payment_refund, payout, payout_cancel, payout_failure, refund, refund_failure, reserve_transaction, reserved_funds, stripe_fee, stripe_fx_fee, tax_fee, topup, topup_reversal, transfer, transfer_cancel, transfer_failure, or transfer_refund.More parametersExpand all created optional dictionary currency optional ending_before optional limit optional source optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit transactions, starting after transaction starting_after. Each entry in the array is a separate transaction history object. If no more transactions are available, the resulting array will be empty | import stripe
stripe.api_key = "sk_test_your_key"
stripe.BalanceTransaction.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/balance_transactions",
"has_more": false,
"data": [
{
"id": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"object": "balance_transaction",
"amount": 400,
"available_on": 1386374400,
"created": 1385814763,
"currency": "usd",
"description": "Charge for test@example.com",
"exchange_rate": null,
"fee": 42,
"fee_details": [
{
"amount": 42,
"application": null,
"currency": "usd",
"description": "Stripe processing fees",
"type": "stripe_fee"
}
],
"net": 358,
"reporting_category": "charge",
"source": "ch_1032HU2eZvKYlo2C0FuZb3X7",
"status": "available",
"type": "charge"
},
{...},
{...}
]
}''' |
ChargesTo charge a credit or a debit card, you create a Charge object. You can
retrieve and refund individual charges as well as list all charges. Charges
are identified by a unique, random ID. | '''Endpoints POST /v1/charges GET /v1/charges/:id POST /v1/charges/:id POST /v1/charges/:id/capture GET /v1/charges GET /v1/charges/search
''' |
The charge objectAttributes id string Unique identifier for the object. amount positive integer or zero Amount intended to be collected by this payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). balance_transaction string expandable ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes). billing_details hash Billing information associated with the payment method at the time of the transaction.Show child attributes currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. customer string expandable ID of the customer this charge is for if one exists. description string An arbitrary string attached to the object. Often useful for displaying to users. disputed boolean Whether the charge has been disputed. invoice string expandable ID of the invoice this charge is for if one exists. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. payment_intent string expandable ID of the PaymentIntent associated with this charge, if one exists. payment_method_details hash Details about the payment method at the time of the transaction.Show child attributes receipt_email string This is the email address that the receipt for this charge was sent to. refunded boolean Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false. shipping hash Shipping information for the charge.Show child attributes statement_descriptor string For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters. statement_descriptor_suffix string Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. status enum The status of the payment is either succeeded, pending, or failed.Possible enum valuessucceeded pending failed More attributesExpand all object string, value is "charge" amount_captured positive integer or zero amount_refunded positive integer or zero application string expandable "application" Connect only application_fee string expandable Connect only application_fee_amount integer Connect only calculated_statement_descriptor string captured boolean created timestamp failure_balance_transaction string expandable failure_code string failure_message string fraud_details hash livemode boolean on_behalf_of string expandable Connect only outcome hash paid boolean payment_method string radar_options hash receipt_number string receipt_url string refunds list review string expandable source_transfer string expandable Connect only transfer string expandable Connect only transfer_data hash Connect only transfer_group string Connect only | '''The charge object {
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
''' |
Create a chargeTo charge a credit card or other payment source, you create a Charge object. If your API key is in test mode, the supplied payment source (e.g., card) won’t actually be charged, although everything else will occur as if in live mode. (Stripe assumes that the charge would have completed successfully).Parameters amount required Amount intended to be collected by this payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). currency required Three-letter ISO currency code, in lowercase. Must be a supported currency. customer optional The ID of an existing customer that will be charged in this request. description optional An arbitrary string which you can attach to a Charge object. It is displayed when in the web interface alongside the charge. Note that if you use Stripe to send automatic email receipts to your customers, your receipt emails will include the description of the charge(s) that they are describing. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. receipt_email optional The email address to which this charge’s receipt will be sent. The receipt will not be sent until the charge is paid, and no receipts will be sent for test mode charges. If this charge is for a Customer, the email address specified here will override the customer’s email address. If receipt_email is specified for a charge in live mode, a receipt will be sent regardless of your email settings. shipping optional dictionary Shipping information for the charge. Helps prevent fraud on charges for physical goods.Show child parameters source optional A payment source to be charged. This can be the ID of a card (i.e., credit or debit card), a bank account, a source, a token, or a connected account. For certain sources—namely, cards, bank accounts, and attached sources—you must also pass the ID of the associated customer. statement_descriptor optional For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters. statement_descriptor_suffix optional Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.More parametersExpand all application_fee_amount optional Connect only capture optional on_behalf_of optional Connect only radar_options optional dictionary transfer_data optional dictionary Connect only transfer_group optional Connect only ReturnsReturns the charge object if the charge succeeded.
This call will raise an error if something goes wrong.
A common source of error is an invalid or expired card,
or a valid card with insufficient available balance.Verification responsesIf the cvc parameter is provided, Stripe will attempt to check the correctness of the CVC,
and will return this check's result. Similarly, if address_line1 or address_zip are provided,
Stripe will try to check the validity of those parameters.Some card issuers do not support checking one or more of these parameters,
in which case Stripe will return an unavailable result.Also note that, depending on the card issuer,
charges can succeed even when passed incorrect CVC and address information.
CVC payment_method_details.card.checks.cvc_checkpassThe CVC provided is correct.failThe CVC provided is incorrect.unavailableThe customer's card issuer did not check the CVC provided.uncheckedThe CVC was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see Check if a card is valid without a charge.Address line payment_method_details.card.checks.address_line1_checkpassThe first address line provided is correct.failThe first address line provided is incorrect.unavailableThe customer's card issuer did not check the first address line provided.uncheckedThe first address line was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see Check if a card is valid without a charge.Address ZIP payment_method_details.card.checks.address_zip_checkpassThe ZIP code provided is correct.failThe ZIP code provided is incorrect.unavailableThe customer's card issuer did not check the ZIP code.uncheckedThe ZIP code was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see Check if a card is valid without a charge | import stripe
stripe.api_key = "sk_test_your_key"
# `source` is obtained with Stripe.js; see https://stripe.com/docs/payments/accept-a-payment-charges#web-create-token
stripe.Charge.create(
amount=2000,
currency="usd",
source="tok_mastercard",
description="My First Test Charge (created for API docs at https://www.stripe.com/docs/api)",
)
'''Response {
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 2000,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs at https://www.stripe.com/docs/api)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null,
"source": "tok_amex"
}''' |
Retrieve a chargeRetrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge.ParametersNo parameters.ReturnsReturns a charge if a valid identifier was provided, and raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.retrieve(
"ch_3LSdsa2eZvKYlo2C1pk5D2K6",
)
'''Response {
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}''' |
Update a chargeUpdates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.Parameters customer optional The ID of an existing customer that will be associated with this request. This field may only be updated if there is no existing associated customer with this charge. description optional An arbitrary string which you can attach to a charge object. It is displayed when in the web interface alongside the charge. Note that if you use Stripe to send automatic email receipts to your customers, your receipt emails will include the description of the charge(s) that they are describing. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. receipt_email optional This is the email address that the receipt for this charge will be sent to. If this field is updated, then a new email receipt will be sent to the updated address. shipping optional dictionary Shipping information for the charge. Helps prevent fraud on charges for physical goods.Show child parametersMore parametersExpand all fraud_details optional dictionary transfer_group optional Connect only ReturnsReturns the charge object if the update succeeded. This call will raise an error if update parameters are invalid | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.modify(
"ch_3LSdsa2eZvKYlo2C1pk5D2K6",
metadata={"order_id": "6735"},
)
'''Response {
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {
"order_id": "6735"
},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}''' |
Capture a chargeCapture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.
Uncaptured payments expire a set number of days after they are created (7 by default). If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable.Parameters amount optional The amount to capture, which must be less than or equal to the original amount. Any additional amount will be automatically refunded. receipt_email optional The email address to send this charge’s receipt to. This will override the previously-specified email address for this charge, if one was set. Receipts will not be sent in test mode. statement_descriptor optional For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters. statement_descriptor_suffix optional Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.More parametersExpand all application_fee_amount optional Connect only transfer_data optional dictionary Connect only transfer_group optional Connect only ReturnsReturns the charge object, with an updated captured property (set to true). Capturing a charge will always succeed, unless the charge is already refunded, expired, captured, or an invalid capture amount is specified, in which case this method will raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.capture(
"ch_3LSdsa2eZvKYlo2C1pk5D2K6",
)
'''Response {
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}''' |
List all chargesReturns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.Parameters customer optional Only return charges for the customer specified by this customer ID.More parametersExpand all created optional dictionary ending_before optional limit optional payment_intent optional starting_after optional transfer_group optional Connect only ReturnsA dictionary with a data property that contains an array of up to limit charges, starting after charge starting_after. Each entry in the array is a separate charge object. If no more charges are available, the resulting array will be empty. If you provide a non-existent customer ID, this call raises an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/charges",
"has_more": false,
"data": [
{
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 100,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
},
{...},
{...}
]
}''' |
Search chargesSearch for charges you’ve previously created using Stripe’s Search Query Language.
Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating
conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
to an hour behind during outages. Search functionality is not available to merchants in India.Parameters query required The search query string. See search query language and the list of supported query fields for charges. limit optional A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. page optional 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.ReturnsA dictionary with a data property that contains an array of up to limit charges. If no objects match the
query, the resulting array will be empty. See the related guide on expanding properties in lists | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Charge.search(
query="amount>999 AND metadata['order_id']:'6735'",
)
'''Response {
"object": "search_result",
"url": "/v1/charges/search",
"has_more": false,
"data": [
{
"id": "ch_3LSdsa2eZvKYlo2C1pk5D2K6",
"object": "charge",
"amount": 1000,
"amount_captured": 0,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1032HU2eZvKYlo2CEPtcnUvl",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": null,
"captured": false,
"created": 1659518920,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {
"order_id": "6735"
},
"on_behalf_of": null,
"outcome": null,
"paid": true,
"payment_intent": null,
"payment_method": "card_1LSdsU2eZvKYlo2C1BKhCSWF",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 8,
"exp_year": 2023,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_3LSdsa2eZvKYlo2C1pk5D2K6/rcpt_MAzsX8H9XHu2XoHLHOqQ1d3gDS78hzU",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_3LSdsa2eZvKYlo2C1pk5D2K6/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
},
{...},
{...}
]
}''' |
CustomersThis object represents a customer of your business. It lets you create recurring charges and track payments that belong to the same customer. | '''Endpoints POST /v1/customers GET /v1/customers/:id POST /v1/customers/:idDELETE /v1/customers/:id GET /v1/customers GET /v1/customers/search
''' |
The customer objectAttributes id string Unique identifier for the object. address hash The customer’s address.Show child attributes description string An arbitrary string attached to the object. Often useful for displaying to users. email string The customer’s email address. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. name string The customer’s full name or business name. phone string The customer’s phone number. shipping hash Mailing and shipping address for the customer. Appears on invoices emailed to this customer.Show child attributesMore attributesExpand all object string, value is "customer" balance integer cash_balance hash expandable preview feature created timestamp currency string default_source string expandable bank account, card, or source (e.g., card) delinquent boolean discount hash, discount object invoice_credit_balance hash expandable invoice_prefix string invoice_settings hash livemode boolean next_invoice_sequence integer preferred_locales array containing strings sources list expandable subscriptions list expandable tax hash expandable tax_exempt string tax_ids list expandable test_clock string expandable | '''The customer object {
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": null,
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}
''' |
Create a customerParameters address optional dictionary The customer’s address.Show child parameters description optional An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard. email optional Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. name optional The customer’s full name or business name. payment_method optional The ID of the PaymentMethod to attach to the customer. phone optional The customer’s phone number. shipping optional dictionary The customer’s shipping information. Appears on invoices emailed to this customer.Show child parametersMore parametersExpand all balance optional cash_balance optional dictionary preview feature coupon optional invoice_prefix optional invoice_settings optional dictionary next_invoice_sequence optional preferred_locales optional promotion_code optional source optional tax optional dictionary tax_exempt optional tax_id_data optional array of hashes test_clock optional ReturnsReturns the customer object if the update succeeded. Raises an error if create parameters are invalid (e.g. specifying an invalid coupon or an invalid source) | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Customer.create(
description="My First Test Customer (created for API docs at https://www.stripe.com/docs/api)",
)
'''Response {
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "My First Test Customer (created for API docs at https://www.stripe.com/docs/api)",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": null,
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}''' |
Retrieve a customerRetrieves a Customer object.ParametersNo parameters.ReturnsReturns the Customer object for a valid identifier. If it’s for a deleted Customer, a subset of the customer’s information is returned, including a deleted property that’s set to true | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Customer.retrieve("cus_8TEMHVY5moxIPI")
'''Response {
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": null,
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}''' |
Update a customerUpdates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior.
This request accepts mostly the same arguments as the customer creation call.Parameters address optional dictionary The customer’s address.Show child parameters description optional An arbitrary string that you can attach to a customer object. It is displayed alongside the customer in the dashboard. email optional Customer’s email address. It’s displayed alongside the customer in your dashboard and can be useful for searching and tracking. This may be up to 512 characters. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. name optional The customer’s full name or business name. phone optional The customer’s phone number. shipping optional dictionary The customer’s shipping information. Appears on invoices emailed to this customer.Show child parametersMore parametersExpand all balance optional cash_balance optional dictionary preview feature coupon optional default_source optional invoice_prefix optional invoice_settings optional dictionary next_invoice_sequence optional preferred_locales optional promotion_code optional source optional tax optional dictionary tax_exempt optional ReturnsReturns the customer object if the update succeeded. Raises an error if update parameters are invalid (e.g. specifying an invalid coupon or an invalid source) | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Customer.modify(
"cus_8TEMHVY5moxIPI",
metadata={"order_id": "6735"},
)
'''Response {
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {
"order_id": "6735"
},
"name": null,
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}''' |
Delete a customerPermanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.ParametersNo parameters.ReturnsReturns an object with a deleted parameter on success. If the customer ID does not exist, this call raises an error.
Unlike other objects, deleted customers can still be retrieved through the API, in order to be able to track the history of customers while still removing their credit card details and preventing any further operations to be performed (such as adding a new subscription) | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Customer.delete("cus_8TEMHVY5moxIPI")
'''Response {
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"deleted": true
}''' |
List all customersReturns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.Parameters email optional A case-sensitive filter on the list based on the customer’s email field. The value must be a string.More parametersExpand all created optional dictionary ending_before optional limit optional starting_after optional test_clock optional ReturnsA dictionary with a data property that contains an array of up to limit customers, starting after customer starting_after. Passing an optional email will result in filtering to customers with only that exact email address. Each entry in the array is a separate customer object. If no more customers are available, the resulting array will be empty. This request should never raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Customer.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/customers",
"has_more": false,
"data": [
{
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": null,
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
},
{...},
{...}
]
}''' |
Search customersSearch for customers you’ve previously created using Stripe’s Search Query Language.
Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating
conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up
to an hour behind during outages. Search functionality is not available to merchants in India.Parameters query required The search query string. See search query language and the list of supported query fields for customers. limit optional A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. page optional 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.ReturnsA dictionary with a data property that contains an array of up to limit customers. If no objects match the
query, the resulting array will be empty. See the related guide on expanding properties in lists | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Customer.search(
query="name:'fakename' AND metadata['foo']:'bar'",
)
'''Response {
"object": "search_result",
"url": "/v1/customers/search",
"has_more": false,
"data": [
{
"id": "cus_8TEMHVY5moxIPI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1463528816,
"currency": "usd",
"default_source": "card_18CHs82eZvKYlo2C9BGk8uHq",
"delinquent": true,
"description": "Ava Anderson",
"discount": null,
"email": "ava.anderson.22@example.com",
"invoice_prefix": "F899D8E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {
"foo": "bar"
},
"name": "fakename",
"next_invoice_sequence": 12,
"phone": null,
"preferred_locales": [],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
},
{...},
{...}
]
}''' |
DisputesA dispute occurs when a customer questions your charge with their card issuer.
When this happens, you're given the opportunity to respond to the dispute with
evidence that shows that the charge is legitimate. You can find more
information about the dispute process in our Disputes and
Fraud documentation. | '''Endpoints GET /v1/disputes/:id POST /v1/disputes/:id POST /v1/disputes/:id/close GET /v1/disputes
''' |
The dispute objectAttributes id string Unique identifier for the object. amount integer Disputed amount. Usually the amount of the charge, but can differ (usually because of currency fluctuation or because only part of the order is disputed). charge string expandable ID of the charge that was disputed. currency currency Three-letter ISO currency code, in lowercase. Must be a supported currency. evidence hash Evidence provided to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. payment_intent string expandable ID of the PaymentIntent that was disputed. reason string Reason given by cardholder for dispute. Possible values are bank_cannot_process, check_returned, credit_not_processed, customer_initiated, debit_not_authorized, duplicate, fraudulent, general, incorrect_account_details, insufficient_funds, product_not_received, product_unacceptable, subscription_canceled, or unrecognized. Read more about dispute reasons. status string Current status of dispute. Possible values are warning_needs_response, warning_under_review, warning_closed, needs_response, under_review, charge_refunded, won, or lost.More attributesExpand all object string, value is "dispute" balance_transactions array, contains: balance_transaction object created timestamp evidence_details hash is_charge_refundable boolean livemode boolean | '''The dispute object {
"id": "dp_1LSdrs2eZvKYlo2C7GrtVJtt",
"object": "dispute",
"amount": 1000,
"balance_transactions": [],
"charge": "ch_1AZtxr2eZvKYlo2CJDX8whov",
"created": 1659518876,
"currency": "usd",
"evidence": {
"access_activity_log": null,
"billing_address": null,
"cancellation_policy": null,
"cancellation_policy_disclosure": null,
"cancellation_rebuttal": null,
"customer_communication": null,
"customer_email_address": null,
"customer_name": null,
"customer_purchase_ip": null,
"customer_signature": null,
"duplicate_charge_documentation": null,
"duplicate_charge_explanation": null,
"duplicate_charge_id": null,
"product_description": null,
"receipt": null,
"refund_policy": null,
"refund_policy_disclosure": null,
"refund_refusal_explanation": null,
"service_date": null,
"service_documentation": null,
"shipping_address": null,
"shipping_carrier": null,
"shipping_date": null,
"shipping_documentation": null,
"shipping_tracking_number": null,
"uncategorized_file": null,
"uncategorized_text": null
},
"evidence_details": {
"due_by": 1661212799,
"has_evidence": false,
"past_due": false,
"submission_count": 0
},
"is_charge_refundable": true,
"livemode": false,
"metadata": {},
"payment_intent": null,
"reason": "general",
"status": "warning_needs_response"
}
''' |
The dispute evidence objectAttributes access_activity_log string Any server or activity logs showing proof that the customer accessed or downloaded the purchased digital product. This information should include IP addresses, corresponding timestamps, and any detailed recorded activity. billing_address string The billing address provided by the customer. cancellation_policy string expandable (ID of a file upload) Your subscription cancellation policy, as shown to the customer. cancellation_policy_disclosure string An explanation of how and when the customer was shown your refund policy prior to purchase. cancellation_rebuttal string A justification for why the customer’s subscription was not canceled. customer_communication string expandable (ID of a file upload) Any communication with the customer that you feel is relevant to your case. Examples include emails proving that the customer received the product or service, or demonstrating their use of or satisfaction with the product or service. customer_email_address string The email address of the customer. customer_name string The name of the customer. customer_purchase_ip string The IP address that the customer used when making the purchase. customer_signature string expandable (ID of a file upload) A relevant document or contract showing the customer’s signature. duplicate_charge_documentation string expandable (ID of a file upload) Documentation for the prior charge that can uniquely identify the charge, such as a receipt, shipping label, work order, etc. This document should be paired with a similar document from the disputed payment that proves the two payments are separate. duplicate_charge_explanation string An explanation of the difference between the disputed charge versus the prior charge that appears to be a duplicate. duplicate_charge_id string The Stripe ID for the prior charge which appears to be a duplicate of the disputed charge. product_description string A description of the product or service that was sold. receipt string expandable (ID of a file upload) Any receipt or message sent to the customer notifying them of the charge. refund_policy string expandable (ID of a file upload) Your refund policy, as shown to the customer. refund_policy_disclosure string Documentation demonstrating that the customer was shown your refund policy prior to purchase. refund_refusal_explanation string A justification for why the customer is not entitled to a refund. service_date string The date on which the customer received or began receiving the purchased service, in a clear human-readable format. service_documentation string expandable (ID of a file upload) Documentation showing proof that a service was provided to the customer. This could include a copy of a signed contract, work order, or other form of written agreement. shipping_address string The address to which a physical product was shipped. You should try to include as complete address information as possible. shipping_carrier string The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. If multiple carriers were used for this purchase, please separate them with commas. shipping_date string The date on which a physical product began its route to the shipping address, in a clear human-readable format. shipping_documentation string expandable (ID of a file upload) Documentation showing proof that a product was shipped to the customer at the same address the customer provided to you. This could include a copy of the shipment receipt, shipping label, etc. It should show the customer’s full shipping address, if possible. shipping_tracking_number string The tracking number for a physical product, obtained from the delivery service. If multiple tracking numbers were generated for this purchase, please separate them with commas. uncategorized_file string expandable (ID of a file upload) Any additional evidence or statements. uncategorized_text string Any additional evidence or statements | '''The dispute evidence object {
"access_activity_log": null,
"billing_address": null,
"cancellation_policy": null,
"cancellation_policy_disclosure": null,
"cancellation_rebuttal": null,
"customer_communication": null,
"customer_email_address": null,
"customer_name": null,
"customer_purchase_ip": null,
"customer_signature": null,
"duplicate_charge_documentation": null,
"duplicate_charge_explanation": null,
"duplicate_charge_id": null,
"product_description": null,
"receipt": null,
"refund_policy": null,
"refund_policy_disclosure": null,
"refund_refusal_explanation": null,
"service_date": null,
"service_documentation": null,
"shipping_address": null,
"shipping_carrier": null,
"shipping_date": null,
"shipping_documentation": null,
"shipping_tracking_number": null,
"uncategorized_file": null,
"uncategorized_text": null
}
''' |
Retrieve a disputeRetrieves the dispute with the given ID.ParametersNo parameters.ReturnsReturns a dispute if a valid dispute ID was provided. Raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Dispute.retrieve(
"dp_1LSdrs2eZvKYlo2C7GrtVJtt",
)
'''Response {
"id": "dp_1LSdrs2eZvKYlo2C7GrtVJtt",
"object": "dispute",
"amount": 1000,
"balance_transactions": [],
"charge": "ch_1AZtxr2eZvKYlo2CJDX8whov",
"created": 1659518876,
"currency": "usd",
"evidence": {
"access_activity_log": null,
"billing_address": null,
"cancellation_policy": null,
"cancellation_policy_disclosure": null,
"cancellation_rebuttal": null,
"customer_communication": null,
"customer_email_address": null,
"customer_name": null,
"customer_purchase_ip": null,
"customer_signature": null,
"duplicate_charge_documentation": null,
"duplicate_charge_explanation": null,
"duplicate_charge_id": null,
"product_description": null,
"receipt": null,
"refund_policy": null,
"refund_policy_disclosure": null,
"refund_refusal_explanation": null,
"service_date": null,
"service_documentation": null,
"shipping_address": null,
"shipping_carrier": null,
"shipping_date": null,
"shipping_documentation": null,
"shipping_tracking_number": null,
"uncategorized_file": null,
"uncategorized_text": null
},
"evidence_details": {
"due_by": 1661212799,
"has_evidence": false,
"past_due": false,
"submission_count": 0
},
"is_charge_refundable": true,
"livemode": false,
"metadata": {},
"payment_intent": null,
"reason": "general",
"status": "warning_needs_response"
}''' |
Update a disputeWhen you get a dispute, contacting your customer is always the best first step. If that doesn’t work, you can submit evidence to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to submit evidence programmatically.
Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. To figure out which evidence fields to provide, see our guide to dispute types.Parameters evidence optional dictionary Evidence to upload, to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. The combined character count of all fields is limited to 150,000.Show child parameters metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. submit optional Whether to immediately submit evidence to the bank. If false, evidence is staged on the dispute. Staged evidence is visible in the API and Dashboard, and can be submitted to the bank by making another request with this attribute set to true (the default).ReturnsReturns the dispute object | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Dispute.modify(
"dp_1LSdrs2eZvKYlo2C7GrtVJtt",
metadata={"order_id": "6735"},
)
'''Response {
"id": "dp_1LSdrs2eZvKYlo2C7GrtVJtt",
"object": "dispute",
"amount": 1000,
"balance_transactions": [],
"charge": "ch_1AZtxr2eZvKYlo2CJDX8whov",
"created": 1659518876,
"currency": "usd",
"evidence": {
"access_activity_log": null,
"billing_address": null,
"cancellation_policy": null,
"cancellation_policy_disclosure": null,
"cancellation_rebuttal": null,
"customer_communication": null,
"customer_email_address": null,
"customer_name": null,
"customer_purchase_ip": null,
"customer_signature": null,
"duplicate_charge_documentation": null,
"duplicate_charge_explanation": null,
"duplicate_charge_id": null,
"product_description": null,
"receipt": null,
"refund_policy": null,
"refund_policy_disclosure": null,
"refund_refusal_explanation": null,
"service_date": null,
"service_documentation": null,
"shipping_address": null,
"shipping_carrier": null,
"shipping_date": null,
"shipping_documentation": null,
"shipping_tracking_number": null,
"uncategorized_file": null,
"uncategorized_text": null
},
"evidence_details": {
"due_by": 1661212799,
"has_evidence": false,
"past_due": false,
"submission_count": 0
},
"is_charge_refundable": true,
"livemode": false,
"metadata": {
"order_id": "6735"
},
"payment_intent": null,
"reason": "general",
"status": "warning_needs_response"
}''' |
Close a disputeClosing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost.
The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible.ParametersNo parameters.ReturnsReturns the dispute object | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Dispute.close(
"dp_1LSdrs2eZvKYlo2C7GrtVJtt",
)
'''Response {
"id": "dp_1LSdrs2eZvKYlo2C7GrtVJtt",
"object": "dispute",
"amount": 1000,
"balance_transactions": [],
"charge": "ch_1AZtxr2eZvKYlo2CJDX8whov",
"created": 1659518876,
"currency": "usd",
"evidence": {
"access_activity_log": null,
"billing_address": null,
"cancellation_policy": null,
"cancellation_policy_disclosure": null,
"cancellation_rebuttal": null,
"customer_communication": null,
"customer_email_address": null,
"customer_name": null,
"customer_purchase_ip": null,
"customer_signature": null,
"duplicate_charge_documentation": null,
"duplicate_charge_explanation": null,
"duplicate_charge_id": null,
"product_description": null,
"receipt": null,
"refund_policy": null,
"refund_policy_disclosure": null,
"refund_refusal_explanation": null,
"service_date": null,
"service_documentation": null,
"shipping_address": null,
"shipping_carrier": null,
"shipping_date": null,
"shipping_documentation": null,
"shipping_tracking_number": null,
"uncategorized_file": null,
"uncategorized_text": null
},
"evidence_details": {
"due_by": 1661212799,
"has_evidence": false,
"past_due": false,
"submission_count": 0
},
"is_charge_refundable": true,
"livemode": false,
"metadata": {},
"payment_intent": null,
"reason": "general",
"status": "lost"
}''' |
List all disputesReturns a list of your disputes.Parameters charge optional Only return disputes associated to the charge specified by this charge ID. payment_intent optional Only return disputes associated to the PaymentIntent specified by this PaymentIntent ID.More parametersExpand all created optional dictionary ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit disputes, starting after dispute starting_after. Each entry in the array is a separate dispute object. If no more disputes are available, the resulting array will be empty. This request should never raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Dispute.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/disputes",
"has_more": false,
"data": [
{
"id": "dp_1LSdrs2eZvKYlo2C7GrtVJtt",
"object": "dispute",
"amount": 1000,
"balance_transactions": [],
"charge": "ch_1AZtxr2eZvKYlo2CJDX8whov",
"created": 1659518876,
"currency": "usd",
"evidence": {
"access_activity_log": null,
"billing_address": null,
"cancellation_policy": null,
"cancellation_policy_disclosure": null,
"cancellation_rebuttal": null,
"customer_communication": null,
"customer_email_address": null,
"customer_name": null,
"customer_purchase_ip": null,
"customer_signature": null,
"duplicate_charge_documentation": null,
"duplicate_charge_explanation": null,
"duplicate_charge_id": null,
"product_description": null,
"receipt": null,
"refund_policy": null,
"refund_policy_disclosure": null,
"refund_refusal_explanation": null,
"service_date": null,
"service_documentation": null,
"shipping_address": null,
"shipping_carrier": null,
"shipping_date": null,
"shipping_documentation": null,
"shipping_tracking_number": null,
"uncategorized_file": null,
"uncategorized_text": null
},
"evidence_details": {
"due_by": 1661212799,
"has_evidence": false,
"past_due": false,
"submission_count": 0
},
"is_charge_refundable": true,
"livemode": false,
"metadata": {},
"payment_intent": null,
"reason": "general",
"status": "warning_needs_response"
},
{...},
{...}
]
}''' |
EventsEvents are our way of letting you know when something interesting happens in
your account. When an interesting event occurs, we create a new Event
object. For example, when a charge succeeds, we create a charge.succeeded
event; and when an invoice payment attempt fails, we create an
invoice.payment_failed event. Note that many API requests may cause multiple
events to be created. For example, if you create a new subscription for a
customer, you will receive both a customer.subscription.created event and a
charge.succeeded event.Events occur when the state of another API resource changes. The state of that
resource at the time of the change is embedded in the event's data field. For
example, a charge.succeeded event will contain a charge, and an
invoice.payment_failed event will contain an invoice.As with other API resources, you can use endpoints to retrieve an
individual event or a list of events
from the API. We also have a separate
webhooks system for sending the
Event objects directly to an endpoint on your server. Webhooks are managed
in your
account settings,
and our Using Webhooks guide will help you get set up.When using Connect, you can also receive notifications of
events that occur in connected accounts. For these events, there will be an
additional account attribute in the received Event object.NOTE: Right now, access to events through the Retrieve Event API is
guaranteed only for 30 days | '''Endpoints GET /v1/events/:id GET /v1/events
''' |
The event objectAttributes id string Unique identifier for the object. api_version string The Stripe API version used to render data. Note: This property is populated only for events on or after October 31, 2014. data hash Object containing data associated with the event.Show child attributes request hash Information on the API request that instigated the event.Show child attributes type string Description of the event (e.g., invoice.created or charge.refunded).More attributesExpand all object string, value is "event" account string Connect only created timestamp livemode boolean pending_webhooks positive integer or zero | '''The event object {
"id": "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
"object": "event",
"api_version": "2018-05-21",
"created": 1530291411,
"data": {
"object": {
"id": "src_1CiPsl2eZvKYlo2CVVyt3LKy",
"object": "source",
"amount": 1000,
"client_secret": "src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6",
"created": 1530291339,
"currency": "eur",
"flow": "redirect",
"livemode": false,
"metadata": {},
"owner": {
"address": null,
"email": null,
"name": null,
"phone": null,
"verified_address": null,
"verified_email": null,
"verified_name": "Jenny Rosen",
"verified_phone": null
},
"redirect": {
"failure_reason": null,
"return_url": "https://minkpolice.com",
"status": "succeeded",
"url": "https://hooks.stripe.com/redirect/authenticate/src_1CiPsl2eZvKYlo2CVVyt3LKy?client_secret=src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6"
},
"sofort": {
"country": "DE",
"bank_code": "DEUT",
"bank_name": "Deutsche Bank",
"bic": "DEUTDE2H",
"iban_last4": "3000",
"statement_descriptor": null,
"preferred_language": null
},
"statement_descriptor": null,
"status": "chargeable",
"type": "sofort",
"usage": "single_use"
}
},
"livemode": false,
"pending_webhooks": 0,
"request": {
"id": null,
"idempotency_key": null
},
"type": "source.chargeable"
}
''' |
Retrieve an eventRetrieves the details of an event. Supply the unique identifier of the event, which you might have received in a webhook.ParametersNo parameters.ReturnsReturns an event object if a valid identifier was provided. All events share a common structure, detailed to the right. The only property that will differ is the data property.
In each case, the data dictionary will have an attribute called object and its value will be the same as retrieving the same object directly from the API. For example, a customer.created event will have the same information as retrieving the relevant customer would.
In cases where the attributes of an object have changed, data will also contain a dictionary containing the changes | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Event.retrieve(
"evt_1CiPtv2eZvKYlo2CcUZsDcO6",
)
'''Response {
"id": "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
"object": "event",
"api_version": "2018-05-21",
"created": 1530291411,
"data": {
"object": {
"id": "src_1CiPsl2eZvKYlo2CVVyt3LKy",
"object": "source",
"amount": 1000,
"client_secret": "src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6",
"created": 1530291339,
"currency": "eur",
"flow": "redirect",
"livemode": false,
"metadata": {},
"owner": {
"address": null,
"email": null,
"name": null,
"phone": null,
"verified_address": null,
"verified_email": null,
"verified_name": "Jenny Rosen",
"verified_phone": null
},
"redirect": {
"failure_reason": null,
"return_url": "https://minkpolice.com",
"status": "succeeded",
"url": "https://hooks.stripe.com/redirect/authenticate/src_1CiPsl2eZvKYlo2CVVyt3LKy?client_secret=src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6"
},
"sofort": {
"country": "DE",
"bank_code": "DEUT",
"bank_name": "Deutsche Bank",
"bic": "DEUTDE2H",
"iban_last4": "3000",
"statement_descriptor": null,
"preferred_language": null
},
"statement_descriptor": null,
"status": "chargeable",
"type": "sofort",
"usage": "single_use"
}
},
"livemode": false,
"pending_webhooks": 0,
"request": {
"id": null,
"idempotency_key": null
},
"type": "source.chargeable"
}''' |
List all eventsList events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in event object api_version attribute (not according to your current Stripe API version or Stripe-Version header).Parameters types optional An array of up to 20 strings containing specific event names. The list will be filtered to include only events with a matching event property. You may pass either type or types, but not both.More parametersExpand all created optional dictionary delivery_success optional ending_before optional limit optional starting_after optional type optional ReturnsA dictionary with a data property that contains an array of up to limit events, starting after event starting_after. Each entry in the array is a separate event object. If no more events are available, the resulting array will be empty. This request should never raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Event.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/events",
"has_more": false,
"data": [
{
"id": "evt_1CiPtv2eZvKYlo2CcUZsDcO6",
"object": "event",
"api_version": "2018-05-21",
"created": 1530291411,
"data": {
"object": {
"id": "src_1CiPsl2eZvKYlo2CVVyt3LKy",
"object": "source",
"amount": 1000,
"client_secret": "src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6",
"created": 1530291339,
"currency": "eur",
"flow": "redirect",
"livemode": false,
"metadata": {},
"owner": {
"address": null,
"email": null,
"name": null,
"phone": null,
"verified_address": null,
"verified_email": null,
"verified_name": "Jenny Rosen",
"verified_phone": null
},
"redirect": {
"failure_reason": null,
"return_url": "https://minkpolice.com",
"status": "succeeded",
"url": "https://hooks.stripe.com/redirect/authenticate/src_1CiPsl2eZvKYlo2CVVyt3LKy?client_secret=src_client_secret_D8hHhtdrGWQyK8bLM4M3uFQ6"
},
"sofort": {
"country": "DE",
"bank_code": "DEUT",
"bank_name": "Deutsche Bank",
"bic": "DEUTDE2H",
"iban_last4": "3000",
"statement_descriptor": null,
"preferred_language": null
},
"statement_descriptor": null,
"status": "chargeable",
"type": "sofort",
"usage": "single_use"
}
},
"livemode": false,
"pending_webhooks": 0,
"request": {
"id": null,
"idempotency_key": null
},
"type": "source.chargeable"
},
{...},
{...}
]
}''' |
FilesThis is an object representing a file hosted on Stripe's servers. The
file may have been uploaded by yourself using the create file
request (for example, when uploading dispute evidence) or it may have
been created by Stripe (for example, the results of a Sigma scheduled
query). | '''Endpoints POST https://files.stripe.com/v1/files GET /v1/files/:id GET /v1/files
''' |
The file objectAttributes id string Unique identifier for the object. purpose enum The purpose of the uploaded file.Possible enum valuesaccount_requirement Additional documentation requirements that can be requested for an account.additional_verification Additional verification for custom accounts.business_icon A business icon.business_logo A business logo.customer_signature Customer signature image.dispute_evidence Evidence to submit with a dispute response.document_provider_identity_document Show 7 more type string The type of the file returned (e.g., csv, pdf, jpg, or png).More attributesExpand all object string, value is "file" created timestamp expires_at timestamp filename string links list size integer title string url string | '''The file object {
"id": "file_1JXy922eZvKYlo2CV17dW6tI",
"object": "file",
"created": 1631235788,
"expires_at": null,
"filename": "dd.jpeg",
"links": {
"object": "list",
"data": [
{
"id": "link_1LSe2N2eZvKYlo2CHLmSYQJz",
"object": "file_link",
"created": 1659519527,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfNHU3YmpneDlIUFBQMTlSS3lmWDQxQlRW00nKWaZzGr"
},
{
"id": "link_1LSe2I2eZvKYlo2C2jFw0Gzq",
"object": "file_link",
"created": 1659519522,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRVA2UDR5S1ZyVmRMbFF4WExHWlNOa1Ax004VazMKbc"
},
{
"id": "link_1LSe2D2eZvKYlo2CslI29SvC",
"object": "file_link",
"created": 1659519517,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMVB4OFBvdmMyY2FidnpTQ1VYZ0dDYkJ100MClkyr0o"
},
{
"id": "link_1LSe2B2eZvKYlo2C00aTaqRQ",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfREVTazB5blMxZkFQRlIyS3hkeDZHcXMy00iB0i12NG"
},
{
"id": "link_1LSe2B2eZvKYlo2CZTvXtwWS",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfU0owQ3dwT0dPOVdRaXFSZ3FYSndBcVNh00lmt1vuwG"
},
{
"id": "link_1LSe292eZvKYlo2ChsRxIlRc",
"object": "file_link",
"created": 1659519513,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaDdEVllBdTJ4UmpUMnRsTDhtaDlTeGJm00OOXT4IRf"
},
{
"id": "link_1LSe252eZvKYlo2CopSZDvuE",
"object": "file_link",
"created": 1659519509,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRzNtQmhaMkpvN3J3OG1YSVdiOGZiTGhE00SRpVuhS8"
},
{
"id": "link_1LSe232eZvKYlo2CAAwj4nge",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMjJ0Wm5weFBDWlVPeEZDaWQ0REpvSUVO00I4gJcWng"
},
{
"id": "link_1LSe232eZvKYlo2C1jAhdzY0",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3Rfb1pTQVJiaWg0QTFxS3dxc0NzU2FGZ0NK00Pvbw9x17"
},
{
"id": "link_1LSe212eZvKYlo2CgiTVrVFi",
"object": "file_link",
"created": 1659519505,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaE5qQ0NJb2FWbEpxS0JtejJHZ2plV0hX00xhjC9hjC"
}
],
"has_more": true,
"url": "/v1/file_links?file=file_1JXy922eZvKYlo2CV17dW6tI"
},
"purpose": "business_icon",
"size": 6283,
"title": null,
"type": "png",
"url": "https://files.stripe.com/v1/files/file_1JXy922eZvKYlo2CV17dW6tI/contents"
}
''' |
Create a fileTo upload a file to Stripe, you’ll need to send a request of type multipart/form-data. The request should contain the file you would like to upload, as well as the parameters for creating a file.
All of Stripe’s officially supported Client libraries should have support for sending multipart/form-data.Parameters file required A file to upload. The file should follow the specifications of RFC 2388 (which defines file transfers for the multipart/form-data protocol). purpose required The purpose of the uploaded file.Possible enum valuesaccount_requirement Additional documentation requirements that can be requested for an account.additional_verification Additional verification for custom accounts.business_icon A business icon.business_logo A business logo.customer_signature Customer signature image.dispute_evidence Evidence to submit with a dispute response.identity_document A document to verify the identity of an account owner during account provisioning.pci_document A self-assessment PCI questionnaire.tax_document_user_upload A user-uploaded tax document.More parametersExpand all file_link_data optional dictionary ReturnsReturns the file object | import stripe
stripe.api_key = "sk_test_your_key"
with open("/path/to/a/file.jpg", "rb") as fp:
stripe.File.create(
purpose="dispute_evidence",
file=fp
)
'''Response {
"id": "file_1JXy922eZvKYlo2CV17dW6tI",
"object": "file",
"created": 1631235788,
"expires_at": null,
"filename": "dd.jpeg",
"links": {
"object": "list",
"data": [
{
"id": "link_1LSe2N2eZvKYlo2CHLmSYQJz",
"object": "file_link",
"created": 1659519527,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfNHU3YmpneDlIUFBQMTlSS3lmWDQxQlRW00nKWaZzGr"
},
{
"id": "link_1LSe2I2eZvKYlo2C2jFw0Gzq",
"object": "file_link",
"created": 1659519522,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRVA2UDR5S1ZyVmRMbFF4WExHWlNOa1Ax004VazMKbc"
},
{
"id": "link_1LSe2D2eZvKYlo2CslI29SvC",
"object": "file_link",
"created": 1659519517,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMVB4OFBvdmMyY2FidnpTQ1VYZ0dDYkJ100MClkyr0o"
},
{
"id": "link_1LSe2B2eZvKYlo2C00aTaqRQ",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfREVTazB5blMxZkFQRlIyS3hkeDZHcXMy00iB0i12NG"
},
{
"id": "link_1LSe2B2eZvKYlo2CZTvXtwWS",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfU0owQ3dwT0dPOVdRaXFSZ3FYSndBcVNh00lmt1vuwG"
},
{
"id": "link_1LSe292eZvKYlo2ChsRxIlRc",
"object": "file_link",
"created": 1659519513,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaDdEVllBdTJ4UmpUMnRsTDhtaDlTeGJm00OOXT4IRf"
},
{
"id": "link_1LSe252eZvKYlo2CopSZDvuE",
"object": "file_link",
"created": 1659519509,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRzNtQmhaMkpvN3J3OG1YSVdiOGZiTGhE00SRpVuhS8"
},
{
"id": "link_1LSe232eZvKYlo2CAAwj4nge",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMjJ0Wm5weFBDWlVPeEZDaWQ0REpvSUVO00I4gJcWng"
},
{
"id": "link_1LSe232eZvKYlo2C1jAhdzY0",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3Rfb1pTQVJiaWg0QTFxS3dxc0NzU2FGZ0NK00Pvbw9x17"
},
{
"id": "link_1LSe212eZvKYlo2CgiTVrVFi",
"object": "file_link",
"created": 1659519505,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaE5qQ0NJb2FWbEpxS0JtejJHZ2plV0hX00xhjC9hjC"
}
],
"has_more": true,
"url": "/v1/file_links?file=file_1JXy922eZvKYlo2CV17dW6tI"
},
"purpose": "dispute_evidence",
"size": 6283,
"title": null,
"type": "png",
"url": "https://files.stripe.com/v1/files/file_1JXy922eZvKYlo2CV17dW6tI/contents",
"file": "{a file descriptor}"
}''' |
Retrieve a fileRetrieves the details of an existing file object. Supply the unique file ID from a file, and Stripe will return the corresponding file object. To access file contents, see the File Upload Guide.ParametersNo parameters.ReturnsReturns a file object if a valid identifier was provided, and raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.File.retrieve(
"file_1JXy922eZvKYlo2CV17dW6tI",
)
'''Response {
"id": "file_1JXy922eZvKYlo2CV17dW6tI",
"object": "file",
"created": 1631235788,
"expires_at": null,
"filename": "dd.jpeg",
"links": {
"object": "list",
"data": [
{
"id": "link_1LSe2N2eZvKYlo2CHLmSYQJz",
"object": "file_link",
"created": 1659519527,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfNHU3YmpneDlIUFBQMTlSS3lmWDQxQlRW00nKWaZzGr"
},
{
"id": "link_1LSe2I2eZvKYlo2C2jFw0Gzq",
"object": "file_link",
"created": 1659519522,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRVA2UDR5S1ZyVmRMbFF4WExHWlNOa1Ax004VazMKbc"
},
{
"id": "link_1LSe2D2eZvKYlo2CslI29SvC",
"object": "file_link",
"created": 1659519517,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMVB4OFBvdmMyY2FidnpTQ1VYZ0dDYkJ100MClkyr0o"
},
{
"id": "link_1LSe2B2eZvKYlo2C00aTaqRQ",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfREVTazB5blMxZkFQRlIyS3hkeDZHcXMy00iB0i12NG"
},
{
"id": "link_1LSe2B2eZvKYlo2CZTvXtwWS",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfU0owQ3dwT0dPOVdRaXFSZ3FYSndBcVNh00lmt1vuwG"
},
{
"id": "link_1LSe292eZvKYlo2ChsRxIlRc",
"object": "file_link",
"created": 1659519513,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaDdEVllBdTJ4UmpUMnRsTDhtaDlTeGJm00OOXT4IRf"
},
{
"id": "link_1LSe252eZvKYlo2CopSZDvuE",
"object": "file_link",
"created": 1659519509,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRzNtQmhaMkpvN3J3OG1YSVdiOGZiTGhE00SRpVuhS8"
},
{
"id": "link_1LSe232eZvKYlo2CAAwj4nge",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMjJ0Wm5weFBDWlVPeEZDaWQ0REpvSUVO00I4gJcWng"
},
{
"id": "link_1LSe232eZvKYlo2C1jAhdzY0",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3Rfb1pTQVJiaWg0QTFxS3dxc0NzU2FGZ0NK00Pvbw9x17"
},
{
"id": "link_1LSe212eZvKYlo2CgiTVrVFi",
"object": "file_link",
"created": 1659519505,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaE5qQ0NJb2FWbEpxS0JtejJHZ2plV0hX00xhjC9hjC"
}
],
"has_more": true,
"url": "/v1/file_links?file=file_1JXy922eZvKYlo2CV17dW6tI"
},
"purpose": "business_icon",
"size": 6283,
"title": null,
"type": "png",
"url": "https://files.stripe.com/v1/files/file_1JXy922eZvKYlo2CV17dW6tI/contents"
}''' |
List all filesReturns a list of the files that your account has access to. The files are returned sorted by creation date, with the most recently created files appearing first.Parameters purpose optional The file purpose to filter queries by. If none is provided, files will not be filtered by purpose.More parametersExpand all created optional dictionary ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit files, starting after file starting_after. Each entry in the array is a separate file object. If no more files are available, the resulting array will be empty. This request should never raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.File.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/files",
"has_more": false,
"data": [
{
"id": "file_1JXy922eZvKYlo2CV17dW6tI",
"object": "file",
"created": 1631235788,
"expires_at": null,
"filename": "dd.jpeg",
"links": {
"object": "list",
"data": [
{
"id": "link_1LSe2N2eZvKYlo2CHLmSYQJz",
"object": "file_link",
"created": 1659519527,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfNHU3YmpneDlIUFBQMTlSS3lmWDQxQlRW00nKWaZzGr"
},
{
"id": "link_1LSe2I2eZvKYlo2C2jFw0Gzq",
"object": "file_link",
"created": 1659519522,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRVA2UDR5S1ZyVmRMbFF4WExHWlNOa1Ax004VazMKbc"
},
{
"id": "link_1LSe2D2eZvKYlo2CslI29SvC",
"object": "file_link",
"created": 1659519517,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMVB4OFBvdmMyY2FidnpTQ1VYZ0dDYkJ100MClkyr0o"
},
{
"id": "link_1LSe2B2eZvKYlo2C00aTaqRQ",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfREVTazB5blMxZkFQRlIyS3hkeDZHcXMy00iB0i12NG"
},
{
"id": "link_1LSe2B2eZvKYlo2CZTvXtwWS",
"object": "file_link",
"created": 1659519515,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfU0owQ3dwT0dPOVdRaXFSZ3FYSndBcVNh00lmt1vuwG"
},
{
"id": "link_1LSe292eZvKYlo2ChsRxIlRc",
"object": "file_link",
"created": 1659519513,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaDdEVllBdTJ4UmpUMnRsTDhtaDlTeGJm00OOXT4IRf"
},
{
"id": "link_1LSe252eZvKYlo2CopSZDvuE",
"object": "file_link",
"created": 1659519509,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfRzNtQmhaMkpvN3J3OG1YSVdiOGZiTGhE00SRpVuhS8"
},
{
"id": "link_1LSe232eZvKYlo2CAAwj4nge",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfMjJ0Wm5weFBDWlVPeEZDaWQ0REpvSUVO00I4gJcWng"
},
{
"id": "link_1LSe232eZvKYlo2C1jAhdzY0",
"object": "file_link",
"created": 1659519507,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3Rfb1pTQVJiaWg0QTFxS3dxc0NzU2FGZ0NK00Pvbw9x17"
},
{
"id": "link_1LSe212eZvKYlo2CgiTVrVFi",
"object": "file_link",
"created": 1659519505,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfaE5qQ0NJb2FWbEpxS0JtejJHZ2plV0hX00xhjC9hjC"
}
],
"has_more": true,
"url": "/v1/file_links?file=file_1JXy922eZvKYlo2CV17dW6tI"
},
"purpose": "business_icon",
"size": 6283,
"title": null,
"type": "png",
"url": "https://files.stripe.com/v1/files/file_1JXy922eZvKYlo2CV17dW6tI/contents"
},
{...},
{...}
]
}''' |
File LinksTo share the contents of a File object with non-Stripe users, you can
create a FileLink. FileLinks contain a URL that can be used to
retrieve the contents of the file without authentication | '''Endpoints POST /v1/file_links GET /v1/file_links/:id POST /v1/file_links/:id GET /v1/file_links
''' |
The file link objectAttributes id string Unique identifier for the object. expires_at timestamp Time at which the link expires. file string expandable The file object this link points to. metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. url string The publicly accessible URL to download the file.More attributesExpand all object string, value is "file_link" created timestamp expired boolean livemode boolean | '''The file link object {
"id": "link_1LSdch2eZvKYlo2ChSmmACpZ",
"object": "file_link",
"created": 1659517935,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfSElFUVo0aE9oN3BxUjl3TE1BYWZqZ3lW00WFy5PY6L"
}
''' |
Create a file linkCreates a new file link object.Parameters file required The ID of the file. The file’s purpose must be one of the following: business_icon, business_logo, customer_signature, dispute_evidence, finance_report_run, identity_document_downloadable, pci_document, selfie, sigma_scheduled_query, or tax_document_user_upload. expires_at optional A future timestamp after which the link will no longer be usable. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns the file link object if successful, and raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.FileLink.create(
file="file_1JXy922eZvKYlo2CV17dW6tI",
)
'''Response {
"id": "link_1LSdch2eZvKYlo2ChSmmACpZ",
"object": "file_link",
"created": 1659517935,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfSElFUVo0aE9oN3BxUjl3TE1BYWZqZ3lW00WFy5PY6L"
}''' |
Retrieve a file linkRetrieves the file link with the given ID.ParametersNo parameters.ReturnsReturns a file link object if a valid identifier was provided, and raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.FileLink.retrieve(
"link_1LSdch2eZvKYlo2ChSmmACpZ",
)
'''Response {
"id": "link_1LSdch2eZvKYlo2ChSmmACpZ",
"object": "file_link",
"created": 1659517935,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfSElFUVo0aE9oN3BxUjl3TE1BYWZqZ3lW00WFy5PY6L"
}''' |
Update a file linkUpdates an existing file link object. Expired links can no longer be updated.Parameters expires_at optional A future timestamp after which the link will no longer be usable, or now to expire the link immediately. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.ReturnsReturns the file link object if successful, and raises an error otherwise | import stripe
stripe.api_key = "sk_test_your_key"
stripe.FileLink.modify(
"link_1LSdch2eZvKYlo2ChSmmACpZ",
metadata={"order_id": "6735"},
)
'''Response {
"id": "link_1LSdch2eZvKYlo2ChSmmACpZ",
"object": "file_link",
"created": 1659517935,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfSElFUVo0aE9oN3BxUjl3TE1BYWZqZ3lW00WFy5PY6L"
}''' |
List all file linksReturns a list of file links.ParametersExpand all created optional dictionary ending_before optional expired optional file optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit file links, starting after file link starting_after. Each entry in the array is a separate file link object. If no more file links are available, the resulting array will be empty. This request should never raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.FileLink.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/file_links",
"has_more": false,
"data": [
{
"id": "link_1LSdch2eZvKYlo2ChSmmACpZ",
"object": "file_link",
"created": 1659517935,
"expired": false,
"expires_at": null,
"file": "file_1JXy922eZvKYlo2CV17dW6tI",
"livemode": false,
"metadata": {},
"url": "https://files.stripe.com/links/MDB8YWNjdF8xMDMyRDgyZVp2S1lsbzJDfGZsX3Rlc3RfSElFUVo0aE9oN3BxUjl3TE1BYWZqZ3lW00WFy5PY6L"
},
{...},
{...}
]
}''' |
MandatesA Mandate is a record of the permission a customer has given you to debit their payment method | '''Endpoints GET /v1/mandates/:id
''' |
The Mandates objectAttributes id string Unique identifier for the object. customer_acceptance hash Details about the customer’s acceptance of the mandate.Show child attributes payment_method string expandable ID of the payment method associated with this mandate. payment_method_details hash Additional mandate information specific to the payment method type.Show child attributes status enum The status of the mandate, which indicates whether it can be used to initiate a payment.Possible enum valuesactive The mandate can be used to initiate a payment.inactive The mandate was rejected, revoked, or previously used, and may not be used to initiate future payments.pending The mandate is newly created and is not yet active or inactive. type enum The type of the mandate.Possible enum valuesmulti_use Represents permission given for multiple payments.single_use Represents a one-time permission given for a single payment.More attributesExpand all object string, value is "mandate" livemode boolean multi_use hash single_use hash | '''The Mandates object {
"id": "mandate_1LSdrY2eZvKYlo2CKPFyEpcJ",
"object": "mandate",
"customer_acceptance": {
"accepted_at": 123456789,
"online": {
"ip_address": "127.0.0.0",
"user_agent": "device"
},
"type": "online"
},
"livemode": false,
"multi_use": {},
"payment_method": "pm_123456789",
"payment_method_details": {
"sepa_debit": {
"reference": "123456789",
"url": ""
},
"type": "sepa_debit"
},
"status": "active",
"type": "multi_use"
}
''' |
Retrieve a MandateRetrieves a Mandate object.ParametersNo parameters.ReturnsReturns a Mandate object | import stripe
stripe.api_key = "sk_test_your_key"
stripe.Mandate.retrieve(
"mandate_1LSdrY2eZvKYlo2CKPFyEpcJ",
)
'''Response {
"id": "mandate_1LSdrY2eZvKYlo2CKPFyEpcJ",
"object": "mandate",
"customer_acceptance": {
"accepted_at": 123456789,
"online": {
"ip_address": "127.0.0.0",
"user_agent": "device"
},
"type": "online"
},
"livemode": false,
"multi_use": {},
"payment_method": "pm_123456789",
"payment_method_details": {
"sepa_debit": {
"reference": "123456789",
"url": ""
},
"type": "sepa_debit"
},
"status": "active",
"type": "multi_use"
}''' |
PaymentIntentsA PaymentIntent guides you through the process of collecting a payment from your customer.
We recommend that you create exactly one PaymentIntent for each order or
customer session in your system. You can reference the PaymentIntent later to
see the history of payment attempts for a particular session.A PaymentIntent transitions through
multiple statuses
throughout its lifetime as it interfaces with Stripe.js to perform
authentication flows and ultimately creates at most one successful charge. | '''Endpoints POST /v1/payment_intents GET /v1/payment_intents/:id POST /v1/payment_intents/:id POST /v1/payment_intents/:id/confirm POST /v1/payment_intents/:id/capture POST /v1/payment_intents/:id/cancel GET /v1/payment_intents POST /v1/payment_intents/:id/increment_authorization GET /v1/payment_intents/search POST /v1/payment_intents/:id/verify_microdeposits POST /v1/payment_intents/:id/apply_customer_balance
''' |
The PaymentIntent objectAttributes id string retrievable with publishable key Unique identifier for the object. amount integer retrievable with publishable key Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). automatic_payment_methods hash retrievable with publishable key Settings to configure compatible payment methods from the Stripe DashboardShow child attributes charges list Charges that were created by this PaymentIntent, if any.Show child attributes client_secret string retrievable with publishable key The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.
The client secret can be used to complete a payment from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.
Refer to our docs to accept a payment and learn about how client_secret should be handled. currency currency retrievable with publishable key Three-letter ISO currency code, in lowercase. Must be a supported currency. customer string expandable ID of the Customer this PaymentIntent belongs to, if one exists.
Payment methods attached to other Customers cannot be used with this PaymentIntent.
If present in combination with setup_future_usage, this PaymentIntent’s payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete. description string retrievable with publishable key An arbitrary string attached to the object. Often useful for displaying to users. last_payment_error hash retrievable with publishable key The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason.Show child attributes metadata hash Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. For more information, see the documentation. next_action hash retrievable with publishable key If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source.Show child attributes payment_method string expandable retrievable with publishable key ID of the payment method used in this PaymentIntent. payment_method_types array containing strings retrievable with publishable key The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. receipt_email string retrievable with publishable key Email address that the receipt for the resulting payment will be sent to. If receipt_email is specified for a payment in live mode, a receipt will be sent regardless of your email settings. setup_future_usage enum retrievable with publishable key Indicates that you intend to make future payments with this PaymentIntent’s payment method.
Providing this parameter will attach the payment method to the PaymentIntent’s Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be attached to a Customer after the transaction completes.
When processing card payments, Stripe also uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules, such as SCA.Possible enum valueson_session Use on_session if you intend to only reuse the payment method when your customer is present in your checkout flow.off_session Use off_session if your customer may or may not be present in your checkout flow. shipping hash retrievable with publishable key Shipping information for this PaymentIntent.Show child attributes statement_descriptor string For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters. statement_descriptor_suffix string Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. status string retrievable with publishable key Status of this PaymentIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, requires_capture, canceled, or succeeded. Read more about each PaymentIntent status.More attributesExpand all object string, value is "payment_intent" retrievable with publishable key amount_capturable integer amount_details hash amount_received integer application string expandable "application" Connect only application_fee_amount integer Connect only canceled_at timestamp retrievable with publishable key cancellation_reason string retrievable with publishable key capture_method enum retrievable with publishable key confirmation_method enum retrievable with publishable key created timestamp retrievable with publishable key invoice string expandable livemode boolean retrievable with publishable key on_behalf_of string expandable Connect only payment_method_options hash processing hash retrievable with publishable key review string expandable transfer_data hash Connect only transfer_group string Connect only | '''The PaymentIntent object {
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 1099,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "manual",
"charges": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_DDAO0OLHB8Q8oN5btYX9rg9j2",
"confirmation_method": "automatic",
"created": 1547212637,
"currency": "usd",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}
''' |
Create a PaymentIntentCreates a PaymentIntent object.
After the PaymentIntent is created, attach a payment method and confirm
to continue the payment. You can read more about the different payment flows
available via the Payment Intents API here.
When confirm=true is used during creation, it is equivalent to creating
and confirming the PaymentIntent in the same call. You may use any parameters
available in the confirm API when confirm=true
is supplied.Parameters amount required Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). currency required Three-letter ISO currency code, in lowercase. Must be a supported currency. automatic_payment_methods optional dictionary When enabled, this PaymentIntent will accept payment methods that you have enabled in the Dashboard and are compatible with this PaymentIntent’s other parameters.Show child parameters confirm optional Set to true to attempt to confirm this PaymentIntent immediately. This parameter defaults to false. When creating and confirming a PaymentIntent at the same time, parameters available in the confirm API may also be provided. customer optional ID of the Customer this PaymentIntent belongs to, if one exists.
Payment methods attached to other Customers cannot be used with this PaymentIntent.
If present in combination with setup_future_usage, this PaymentIntent’s payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete. description optional An arbitrary string attached to the object. Often useful for displaying to users. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. off_session optional only when confirm=true Set to true to indicate that the customer is not in your checkout flow during this payment attempt, and therefore is unable to authenticate. This parameter is intended for scenarios where you collect card details and charge them later. This parameter can only be used with confirm=true. payment_method optional ID of the payment method (a PaymentMethod, Card, or compatible Source object) to attach to this PaymentIntent.
If this parameter is omitted with confirm=true, customer.default_source will be attached as this PaymentIntent’s payment instrument to improve the migration experience for users of the Charges API. We recommend that you explicitly provide the payment_method going forward. payment_method_types optional The list of payment method types that this PaymentIntent is allowed to use.
If this is not provided, defaults to [“card”].
Valid payment method types include: acss_debit, affirm, afterpay_clearpay, alipay, au_becs_debit, bacs_debit, bancontact, blik, boleto, card, card_present, eps, fpx, giropay, grabpay, ideal, klarna, konbini, link, oxxo, p24, paynow, promptpay, sepa_debit, sofort, us_bank_account, and wechat_pay. receipt_email optional Email address that the receipt for the resulting payment will be sent to. If receipt_email is specified for a payment in live mode, a receipt will be sent regardless of your email settings. setup_future_usage optional enum Indicates that you intend to make future payments with this PaymentIntent’s payment method.
Providing this parameter will attach the payment method to the PaymentIntent’s Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be attached to a Customer after the transaction completes.
When processing card payments, Stripe also uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules, such as SCA.Possible enum valueson_session Use on_session if you intend to only reuse the payment method when your customer is present in your checkout flow.off_session Use off_session if your customer may or may not be present in your checkout flow. shipping optional dictionary Shipping information for this PaymentIntent.Show child parameters statement_descriptor optional For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters. statement_descriptor_suffix optional Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.More parametersExpand all application_fee_amount optional Connect only capture_method optional enum confirmation_method optional enum error_on_requires_action optional only when confirm=true mandate optional only when confirm=true mandate_data optional dictionary only when confirm=true on_behalf_of optional Connect only payment_method_data optional dictionary payment_method_options optional dictionary radar_options optional dictionary return_url optional only when confirm=true transfer_data optional dictionary Connect only transfer_group optional Connect only use_stripe_sdk optional ReturnsReturns a PaymentIntent object | import stripe
stripe.api_key = "sk_test_your_key"
stripe.PaymentIntent.create(
amount=2000,
currency="usd",
payment_method_types=["card"],
)
'''Response {
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 2000,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "manual",
"charges": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_DDAO0OLHB8Q8oN5btYX9rg9j2",
"confirmation_method": "automatic",
"created": 1547212637,
"currency": "usd",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}''' |
Retrieve a PaymentIntentRetrieves the details of a PaymentIntent that has previously been created.
Client-side retrieval using a publishable key is allowed when the client_secret is provided in the query string.
When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the payment intent object reference for more details.Parameters client_secret Required if using publishable key The client secret of the PaymentIntent. Required if a publishable key is used to retrieve the source.ReturnsReturns a PaymentIntent if a valid identifier was provided | import stripe
stripe.api_key = "sk_test_your_key"
stripe.PaymentIntent.retrieve(
"pi_1DrPsv2eZvKYlo2CEDzqXfPH",
)
'''Response {
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 1099,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "manual",
"charges": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_DDAO0OLHB8Q8oN5btYX9rg9j2",
"confirmation_method": "automatic",
"created": 1547212637,
"currency": "usd",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}''' |
Update a PaymentIntentUpdates properties on a PaymentIntent object without confirming.
Depending on which properties you update, you may need to confirm the
PaymentIntent again. For example, updating the payment_method will
always require you to confirm the PaymentIntent again. If you prefer to
update and confirm at the same time, we recommend updating properties via
the confirm API instead.Parameters amount optional Amount intended to be collected by this PaymentIntent. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). currency optional Three-letter ISO currency code, in lowercase. Must be a supported currency. customer optional ID of the Customer this PaymentIntent belongs to, if one exists.
Payment methods attached to other Customers cannot be used with this PaymentIntent.
If present in combination with setup_future_usage, this PaymentIntent’s payment method will be attached to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete. description optional An arbitrary string attached to the object. Often useful for displaying to users. metadata optional dictionary Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. payment_method optional ID of the payment method (a PaymentMethod, Card, or compatible Source object) to attach to this PaymentIntent. payment_method_types optional The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. Use automatic_payment_methods to manage payment methods from the Stripe Dashboard. receipt_email optional Email address that the receipt for the resulting payment will be sent to. If receipt_email is specified for a payment in live mode, a receipt will be sent regardless of your email settings. setup_future_usage optional enum Indicates that you intend to make future payments with this PaymentIntent’s payment method.
Providing this parameter will attach the payment method to the PaymentIntent’s Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be attached to a Customer after the transaction completes.
When processing card payments, Stripe also uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules, such as SCA.
If setup_future_usage is already set and you are performing a request using a publishable key, you may only update the value from on_session to off_session.Possible enum valueson_session Use on_session if you intend to only reuse the payment method when your customer is present in your checkout flow.off_session Use off_session if your customer may or may not be present in your checkout flow. shipping optional dictionary Shipping information for this PaymentIntent.Show child parameters statement_descriptor optional For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters. statement_descriptor_suffix optional Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.More parametersExpand all application_fee_amount optional Connect only capture_method optional enum secret key only payment_method_data optional dictionary payment_method_options optional dictionary transfer_data optional dictionary Connect only transfer_group optional Connect only ReturnsReturns a PaymentIntent object | import stripe
stripe.api_key = "sk_test_your_key"
stripe.PaymentIntent.modify(
"pi_1DrPsv2eZvKYlo2CEDzqXfPH",
metadata={"order_id": "6735"},
)
'''Response {
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 1099,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "manual",
"charges": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_DDAO0OLHB8Q8oN5btYX9rg9j2",
"confirmation_method": "automatic",
"created": 1547212637,
"currency": "usd",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {
"order_id": "6735"
},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
}''' |
Confirm a PaymentIntentConfirm that your customer intends to pay with current or provided
payment method. Upon confirmation, the PaymentIntent will attempt to initiate
a payment.
If the selected payment method requires additional authentication steps, the
PaymentIntent will transition to the requires_action status and
suggest additional actions via next_action. If payment fails,
the PaymentIntent will transition to the requires_payment_method status. If
payment succeeds, the PaymentIntent will transition to the succeeded
status (or requires_capture, if capture_method is set to manual).
If the confirmation_method is automatic, payment may be attempted
using our client SDKs
and the PaymentIntent’s client_secret.
After next_actions are handled by the client, no additional
confirmation is required to complete the payment.
If the confirmation_method is manual, all payment attempts must be
initiated using a secret key.
If any actions are required for the payment, the PaymentIntent will
return to the requires_confirmation state
after those actions are completed. Your server needs to then
explicitly re-confirm the PaymentIntent to initiate the next payment
attempt. Read the expanded documentation
to learn more about manual confirmation.Parameters payment_method optional ID of the payment method (a PaymentMethod, Card, or compatible Source object) to attach to this PaymentIntent. receipt_email optional Email address that the receipt for the resulting payment will be sent to. If receipt_email is specified for a payment in live mode, a receipt will be sent regardless of your email settings. setup_future_usage optional enum Indicates that you intend to make future payments with this PaymentIntent’s payment method.
Providing this parameter will attach the payment method to the PaymentIntent’s Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be attached to a Customer after the transaction completes.
When processing card payments, Stripe also uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules, such as SCA.
If setup_future_usage is already set and you are performing a request using a publishable key, you may only update the value from on_session to off_session.Possible enum valueson_session Use on_session if you intend to only reuse the payment method when your customer is present in your checkout flow.off_session Use off_session if your customer may or may not be present in your checkout flow. shipping optional dictionary Shipping information for this PaymentIntent.Show child parametersMore parametersExpand all capture_method optional enum secret key only error_on_requires_action optional mandate optional secret key only mandate_data optional dictionary off_session optional secret key only payment_method_data optional dictionary payment_method_options optional dictionary secret key only payment_method_types optional secret key only radar_options optional dictionary secret key only return_url optional use_stripe_sdk optional ReturnsReturns the resulting PaymentIntent after all possible transitions are applied | import stripe
stripe.api_key = "sk_test_your_key"
# To create a PaymentIntent for confirmation, see our guide at: https://stripe.com/docs/payments/payment-intents/creating-payment-intents#creating-for-automatic
stripe.PaymentIntent.confirm(
"pi_1DrPsv2eZvKYlo2CEDzqXfPH",
payment_method="pm_card_visa",
)
'''Response {
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 1000,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 1000,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"charges": {
"object": "list",
"data": [
{
"id": "ch_1EXUPv2eZvKYlo2CStIqOmbY",
"object": "charge",
"amount": 1000,
"amount_captured": 1000,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1EXUPv2eZvKYlo2CNUI18wV8",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": "Stripe",
"captured": true,
"created": 1557239835,
"currency": "usd",
"customer": null,
"description": "One blue fish",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"risk_score": 9,
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"payment_intent": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"payment_method": "pm_1EXUPv2eZvKYlo2CUkqZASBe",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": null
},
"country": "US",
"exp_month": 5,
"exp_year": 2020,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": "1230-7299",
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_1EXUPv2eZvKYlo2CStIqOmbY/rcpt_F1XUd7YIQjmM5TVGoaOmzEpU0FBogb2",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_1EXUPv2eZvKYlo2CStIqOmbY/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_9J35eTzWlxVmfbbQhmkNbewuL",
"confirmation_method": "automatic",
"created": 1524505326,
"currency": "usd",
"customer": null,
"description": "One blue fish",
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": "pm_1EXUPv2eZvKYlo2CUkqZASBe",
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}''' |
Capture a PaymentIntentCapture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.
Uncaptured PaymentIntents will be canceled a set number of days after they are created (7 by default).
Learn more about separate authorization and capture.Parameters amount_to_capture optional The amount to capture from the PaymentIntent, which must be less than or equal to the original amount. Any additional amount will be automatically refunded. Defaults to the full amount_capturable if not provided.More parametersExpand all application_fee_amount optional Connect only statement_descriptor optional statement_descriptor_suffix optional transfer_data optional dictionary Connect only ReturnsReturns a PaymentIntent object with status="succeeded" if the PaymentIntent was capturable. Returns an error if the PaymentIntent was not capturable or an invalid amount to capture was provided | import stripe
stripe.api_key = "sk_test_your_key"
# To create a requires_capture PaymentIntent, see our guide at: https://stripe.com/docs/payments/capture-later
stripe.PaymentIntent.capture(
"pi_1DrP8j2eZvKYlo2C7iVEN8ko",
)
'''Response {
"id": "pi_1DrP8j2eZvKYlo2C7iVEN8ko",
"object": "payment_intent",
"amount": 1000,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 1000,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"charges": {
"object": "list",
"data": [
{
"id": "ch_1EXUPv2eZvKYlo2CStIqOmbY",
"object": "charge",
"amount": 1000,
"amount_captured": 1000,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1EXUPv2eZvKYlo2CNUI18wV8",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"calculated_statement_descriptor": "Stripe",
"captured": true,
"created": 1557239835,
"currency": "usd",
"customer": null,
"description": "One blue fish",
"disputed": false,
"failure_balance_transaction": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"risk_score": 9,
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"payment_intent": "pi_1DrP8j2eZvKYlo2C7iVEN8ko",
"payment_method": "pm_1EXUPv2eZvKYlo2CUkqZASBe",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": null
},
"country": "US",
"exp_month": 5,
"exp_year": 2020,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"moto": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": "1230-7299",
"receipt_url": "https://pay.stripe.com/receipts/acct_1032D82eZvKYlo2C/ch_1EXUPv2eZvKYlo2CStIqOmbY/rcpt_F1XUd7YIQjmM5TVGoaOmzEpU0FBogb2",
"redaction": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges/ch_1EXUPv2eZvKYlo2CStIqOmbY/refunds"
},
"review": null,
"shipping": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrP8j2eZvKYlo2C7iVEN8ko"
},
"client_secret": "pi_1DrP8j2eZvKYlo2C7iVEN8ko_secret_9J35eTzWlxVmfbbQhmkNbewuL",
"confirmation_method": "automatic",
"created": 1524505326,
"currency": "usd",
"customer": null,
"description": "One blue fish",
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": "pm_1EXUPv2eZvKYlo2CUkqZASBe",
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}''' |
Cancel a PaymentIntentA PaymentIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action, or processing.
Once canceled, no additional charges will be made by the PaymentIntent and any operations on the PaymentIntent will fail with an error. For PaymentIntents with status=’requires_capture’, the remaining amount_capturable will automatically be refunded.
You cannot cancel the PaymentIntent for a Checkout Session. Expire the Checkout Session insteadParameters cancellation_reason optional Reason for canceling this PaymentIntent. Possible values are duplicate, fraudulent, requested_by_customer, or abandonedReturnsReturns a PaymentIntent object if the cancellation succeeded. Returns an error if the PaymentIntent has already been canceled or is not in a cancelable state | import stripe
stripe.api_key = "sk_test_your_key"
# To create a PaymentIntent, see our guide at: https://stripe.com/docs/payments/payment-intents/creating-payment-intents#creating-for-automatic
stripe.PaymentIntent.cancel(
"pi_1DrPsv2eZvKYlo2CEDzqXfPH",
)
'''Response {
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 1099,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "manual",
"charges": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_DDAO0OLHB8Q8oN5btYX9rg9j2",
"confirmation_method": "automatic",
"created": 1547212637,
"currency": "usd",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "canceled",
"transfer_data": null,
"transfer_group": null
}''' |
List all PaymentIntentsReturns a list of PaymentIntents.Parameters customer optional Only return PaymentIntents for the customer specified by this customer ID.More parametersExpand all created optional dictionary ending_before optional limit optional starting_after optional ReturnsA dictionary with a data property that contains an array of up to limit PaymentIntents, starting after PaymentIntent starting_after. Each entry in the array is a separate PaymentIntent object. If no more PaymentIntents are available, the resulting array will be empty. This request should never raise an error | import stripe
stripe.api_key = "sk_test_your_key"
stripe.PaymentIntent.list(limit=3)
'''Response {
"object": "list",
"url": "/v1/payment_intents",
"has_more": false,
"data": [
{
"id": "pi_1DrPsv2eZvKYlo2CEDzqXfPH",
"object": "payment_intent",
"amount": 1099,
"amount_capturable": 0,
"amount_details": {
"tip": {}
},
"amount_received": 0,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "manual",
"charges": {
"object": "list",
"data": [],
"has_more": false,
"url": "/v1/charges?payment_intent=pi_1DrPsv2eZvKYlo2CEDzqXfPH"
},
"client_secret": "pi_1DrPsv2eZvKYlo2CEDzqXfPH_secret_DDAO0OLHB8Q8oN5btYX9rg9j2",
"confirmation_method": "automatic",
"created": 1547212637,
"currency": "usd",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": null,
"payment_method_options": {},
"payment_method_types": [
"card"
],
"processing": null,
"receipt_email": null,
"redaction": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "requires_payment_method",
"transfer_data": null,
"transfer_group": null
},
{...},
{...}
]
}''' |
End of preview. Expand
in Dataset Viewer.
No dataset card yet
New: Create and edit this dataset card directly on the website!
Contribute a Dataset Card- Downloads last month
- 8