Result Objects
Note
API calls that don't have validations, such as searches, will return
a collection of requested objectsinstead of a result object.
Success results
If the API call was successful, the `is_success` on the result will return
{true}. The target object will be available as a member of the result
object.
- Python
result.is_success # True
transaction = result.transaction
Error results
If the API call was not successful, the success on the result will return
{false}. An error may be due to:
- A validation error caused by invalid parameters
- A processor decline or gateway rejection
- Other exceptional conditions
- Python
result.is_success # False
result.errors.deep_errors
- Python
result = gateway.customer.create({
"email": "invalid_email",
"credit_card": {
"number": "not_numeric"
}
})
for error in result.errors.deep_errors:
print(error.attribute)
print(error.code)
print(error.message)
for error in result.errors.for_object("customer"):
print(error.attribute)
print(error.code)
print(error.message)
for error in result.errors.for_object("customer").for_object("credit_card"):
print(error.attribute)
print(error.code)
print(error.message)
Message
The message on the error result gives a human-readable description of what went wrong,
regardless of the cause and nature of the error.
- Python
print(result.message)
"Amount is required.\nCredit card number is invalid."
Note
This was added in version {{sdkVersionForDate "Jul09_2010"}}
Params
Error results include the parameters that were submitted. This can be useful during
Transparent Redirects to repopulate your form if validations fail.
- Python
print(result.params)
# {"transaction": {"amount": "1.00"}, {"credit_card": {"cardholder_name": "John Doe"}}}