## Create a charge `charges.create(ChargeCreateParams**kwargs) -> ChargeV1` **post** `/v1/charges` Use charges to collect money from a customer for the sale of goods or services. ### Parameters - `amount: int` The amount of the charge in cents. - `config: Config` - `balance_check: Literal["required", "enabled", "disabled"]` Defines whether to check the customer's balance before processing the charge. - `"required"` - `"enabled"` - `"disabled"` - `auto_hold: Optional[bool]` Defines whether to automatically place this charge on hold after being created. - `auto_hold_message: Optional[str]` The reason the charge is being automatically held on creation. - `sandbox_outcome: Optional[Literal["standard", "paid", "on_hold_daily_limit", 8 more]]` Payment will simulate processing if not Standard. - `"standard"` - `"paid"` - `"on_hold_daily_limit"` - `"cancelled_for_fraud_risk"` - `"cancelled_for_balance_check"` - `"failed_insufficient_funds"` - `"reversed_insufficient_funds"` - `"failed_customer_dispute"` - `"reversed_customer_dispute"` - `"failed_closed_bank_account"` - `"reversed_closed_bank_account"` - `consent_type: Literal["internet", "signed"]` The channel or mechanism through which the payment was authorized. Use `internet` for payments made online or through a mobile app and `signed` for signed agreements where there is a consent form or contract. Use `signed` for PDF signatures. - `"internet"` - `"signed"` - `currency: str` The currency of the charge. Only USD is supported. - `description: Optional[str]` An arbitrary description for the charge. - `device: DeviceInfoV1` - `ip_address: str` The IP address of the device used when the customer authorized the charge or payout. Use `0.0.0.0` to represent an offline consent interaction. - `external_id: str` Unique identifier for the charge in your database. This value must be unique across all charges. - `paykey: str` Value of the `paykey` used for the charge. - `payment_date: Union[null, null]` The desired date on which the payment should be occur. For charges, this means the date you want the customer to be debited on. - `metadata: Optional[Dict[str, str]]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the charge in a structured format. - `correlation_id: Optional[str]` - `idempotency_key: Optional[str]` - `request_id: Optional[str]` - `straddle_account_id: Optional[str]` ### Returns - `class ChargeV1: …` - `data: Data` - `id: str` Unique identifier for the charge. - `amount: int` The amount of the charge in cents. - `config: DataConfig` Configuration options for the charge. - `balance_check: Literal["required", "enabled", "disabled"]` Defines whether to check the customer's balance before processing the charge. - `"required"` - `"enabled"` - `"disabled"` - `auto_hold: Optional[bool]` Defines whether to automatically place this charge on hold after being created. - `auto_hold_message: Optional[str]` The reason the charge is being automatically held on creation. - `sandbox_outcome: Optional[Literal["standard", "paid", "on_hold_daily_limit", 8 more]]` Payment will simulate processing if not Standard. - `"standard"` - `"paid"` - `"on_hold_daily_limit"` - `"cancelled_for_fraud_risk"` - `"cancelled_for_balance_check"` - `"failed_insufficient_funds"` - `"reversed_insufficient_funds"` - `"failed_customer_dispute"` - `"reversed_customer_dispute"` - `"failed_closed_bank_account"` - `"reversed_closed_bank_account"` - `consent_type: Literal["internet", "signed"]` The channel or mechanism through which the payment was authorized. Use `internet` for payments made online or through a mobile app and `signed` for signed agreements where there is a consent form or contract. Use `signed` for PDF signatures. - `"internet"` - `"signed"` - `created_at: Optional[datetime]` Timestamp of when the charge was created. - `currency: str` The currency of the charge. Only USD is supported. - `description: Optional[str]` An arbitrary description for the charge. - `device: DeviceInfoV1` Information about the device used when the customer authorized the payment. - `ip_address: str` The IP address of the device used when the customer authorized the charge or payout. Use `0.0.0.0` to represent an offline consent interaction. - `external_id: str` Unique identifier for the charge in your database. This value must be unique across all charges. - `funding_ids: List[str]` Funding Ids - `paykey: str` Value of the `paykey` used for the charge. - `payment_date: date` The desired date on which the payment should be occur. For charges, this means the date you want the customer to be debited on. - `status: Literal["created", "scheduled", "failed", 6 more]` The current status of the charge. - `"created"` - `"scheduled"` - `"failed"` - `"cancelled"` - `"on_hold"` - `"pending"` - `"paid"` - `"reversed"` - `"validating"` - `status_details: StatusDetailsV1` Additional details about the current status of the charge. - `changed_at: datetime` The time the status change occurred. - `message: str` A human-readable description of the current status. - `reason: Literal["insufficient_funds", "closed_bank_account", "invalid_bank_account", 24 more]` A machine-readable identifier for the specific status, useful for programmatic handling. - `"insufficient_funds"` - `"closed_bank_account"` - `"invalid_bank_account"` - `"invalid_routing"` - `"disputed"` - `"payment_stopped"` - `"owner_deceased"` - `"frozen_bank_account"` - `"risk_review"` - `"fraudulent"` - `"duplicate_entry"` - `"invalid_paykey"` - `"payment_blocked"` - `"amount_too_large"` - `"too_many_attempts"` - `"internal_system_error"` - `"user_request"` - `"ok"` - `"other_network_return"` - `"payout_refused"` - `"cancel_request"` - `"failed_verification"` - `"require_review"` - `"blocked_by_system"` - `"watchtower_review"` - `"validating"` - `"auto_hold"` - `source: Literal["watchtower", "bank_decline", "customer_dispute", 2 more]` Identifies the origin of the status change (e.g., `bank_decline`, `watchtower`). This helps in tracking the cause of status updates. - `"watchtower"` - `"bank_decline"` - `"customer_dispute"` - `"user_action"` - `"system"` - `code: Optional[str]` The status code if applicable. - `status_history: List[DataStatusHistory]` Status history. - `changed_at: datetime` The time the status change occurred. - `message: str` A human-readable description of the status. - `reason: Literal["insufficient_funds", "closed_bank_account", "invalid_bank_account", 24 more]` A machine-readable identifier for the specific status, useful for programmatic handling. - `"insufficient_funds"` - `"closed_bank_account"` - `"invalid_bank_account"` - `"invalid_routing"` - `"disputed"` - `"payment_stopped"` - `"owner_deceased"` - `"frozen_bank_account"` - `"risk_review"` - `"fraudulent"` - `"duplicate_entry"` - `"invalid_paykey"` - `"payment_blocked"` - `"amount_too_large"` - `"too_many_attempts"` - `"internal_system_error"` - `"user_request"` - `"ok"` - `"other_network_return"` - `"payout_refused"` - `"cancel_request"` - `"failed_verification"` - `"require_review"` - `"blocked_by_system"` - `"watchtower_review"` - `"validating"` - `"auto_hold"` - `source: Literal["watchtower", "bank_decline", "customer_dispute", 2 more]` Identifies the origin of the status change (e.g., `bank_decline`, `watchtower`). This helps in tracking the cause of status updates. - `"watchtower"` - `"bank_decline"` - `"customer_dispute"` - `"user_action"` - `"system"` - `status: Literal["created", "scheduled", "failed", 6 more]` The current status of the `charge` or `payout`. - `"created"` - `"scheduled"` - `"failed"` - `"cancelled"` - `"on_hold"` - `"pending"` - `"paid"` - `"reversed"` - `"validating"` - `code: Optional[str]` The status code if applicable. - `trace_ids: Dict[str, str]` Trace Ids. - `updated_at: Optional[datetime]` Timestamp of when the charge was last updated. - `customer_details: Optional[CustomerDetailsV1]` Information about the customer associated with the charge. - `id: str` Unique identifier for the customer - `customer_type: Literal["individual", "business"]` The type of customer - `"individual"` - `"business"` - `email: str` The customer's email address - `name: str` The name of the customer - `phone: str` The customer's phone number in E.164 format - `effective_at: Optional[datetime]` Timestamp of when the charge was effective in the customer's bank account, otherwise known as the date on which the customer is debited. - `metadata: Optional[Dict[str, str]]` Up to 20 additional user-defined key-value pairs. Useful for storing additional information about the charge in a structured format. - `paykey_details: Optional[PaykeyDetailsV1]` Information about the paykey used for the charge. - `id: str` Unique identifier for the paykey. - `customer_id: str` Unique identifier for the customer associated with the paykey. - `label: str` Human-readable label that combines the bank name and masked account number to help easility represent this paykey in a UI - `balance: Optional[int]` The most recent balance of the bank account associated with the paykey in dollars. - `payment_rail: Optional[Literal["ach"]]` The payment rail that the charge will be processed through. - `"ach"` - `processed_at: Optional[datetime]` Timestamp of when the charge was processed by Straddle and originated to the payment rail. - `related_payments: Optional[Dict[str, Literal["original", "resubmit", "refund"]]]` Related payments. - `"original"` - `"resubmit"` - `"refund"` - `meta: ResponseMetadata` Metadata about the API request, including an identifier and timestamp. - `api_request_id: str` Unique identifier for this API request, useful for troubleshooting. - `api_request_timestamp: datetime` Timestamp for this API request, useful for troubleshooting. - `response_type: Literal["object", "array", "error", "none"]` Indicates the structure of the returned content. - "object" means the `data` field contains a single JSON object. - "array" means the `data` field contains an array of objects. - "error" means the `data` field contains an error object with details of the issue. - "none" means no data is returned. - `"object"` - `"array"` - `"error"` - `"none"` ### Example ```python import os from datetime import date from straddle import Straddle client = Straddle( api_key=os.environ.get("STRADDLE_API_KEY"), # This is the default and can be omitted ) charge_v1 = client.charges.create( amount=10000, config={ "balance_check": "required" }, consent_type="internet", currency="currency", description="Monthly subscription fee", device={ "ip_address": "192.168.1.1" }, external_id="external_id", paykey="paykey", payment_date=date.fromisoformat("2019-12-27"), ) print(charge_v1.data) ``` #### Response ```json { "data": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "amount": 10000, "config": { "balance_check": "required", "auto_hold": true, "auto_hold_message": "auto_hold_message", "sandbox_outcome": "standard" }, "consent_type": "internet", "created_at": "2019-12-27T18:11:19.117Z", "currency": "currency", "description": "Monthly subscription fee", "device": { "ip_address": "192.168.1.1" }, "external_id": "external_id", "funding_ids": [ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" ], "paykey": "paykey", "payment_date": "2019-12-27", "status": "created", "status_details": { "changed_at": "2019-12-27T18:11:19.117Z", "message": "Payment successfully created and awaiting validation.", "reason": "insufficient_funds", "source": "system", "code": null }, "status_history": [ { "changed_at": "2019-12-27T18:11:19.117Z", "message": "Payment successfully created and awaiting validation.", "reason": "insufficient_funds", "source": "watchtower", "status": "created", "code": null } ], "trace_ids": { "foo": "string" }, "updated_at": "2019-12-27T18:11:19.117Z", "customer_details": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "customer_type": "individual", "email": "ron@swanson.com", "name": "Ron Swanson", "phone": "+1234567890" }, "effective_at": "2019-12-27T18:11:19.117Z", "metadata": { "foo": "string" }, "paykey_details": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "customer_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "label": "Bank of America ****1234", "balance": 0 }, "payment_rail": "ach", "processed_at": "2019-12-27T18:11:19.117Z", "related_payments": { "foo": "original" } }, "meta": { "api_request_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "api_request_timestamp": "2019-12-27T18:11:19.117Z" }, "response_type": "object" } ```