Cancel a charge to prevent it from being originated for processing. The status of the charge must be created, scheduled, or on_hold.
Parameters
id: str
correlation_id: Optional[str]
idempotency_key: Optional[str]
request_id: Optional[str]
straddle_account_id: Optional[str]
Returns
Cancel a charge
from straddle import Straddle
client = Straddle(
api_key="My API Key",
)
charge_v1 = client.charges.cancel(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(charge_v1.data)
{
"data": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"amount": 10000,
"config": {
"balance_check": "required",
"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
}
],
"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"
},
"meta": {
"api_request_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"api_request_timestamp": "2019-12-27T18:11:19.117Z"
},
"response_type": "object"
}Returns Examples
{
"data": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"amount": 10000,
"config": {
"balance_check": "required",
"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
}
],
"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"
},
"meta": {
"api_request_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"api_request_timestamp": "2019-12-27T18:11:19.117Z"
},
"response_type": "object"
}