Exceptions

The Paysafe APIs allow for certain exceptions to be requested, e.g., invalid credentials, thereby ensuring reliable payment processing.

Click the links below to view our code samples.

Request conflict exception
auth_obj = Authorization(None)
card_obj = Card(None)
cardExpiry_obj = CardExpiry(None)
billing_obj = BillingDetails(None)
auth_obj.merchantRefNum("41sdfsf21hjh1561dfd1341dfdf511")
auth_obj.amount("1")
auth_obj.settleWithAuth("false")
card_obj.cardNum("4111111111111111")
card_obj.cvv("123")
auth_obj.card(card_obj)
cardExpiry_obj.month("12")
cardExpiry_obj.year("2017")
card_obj.cardExpiry(cardExpiry_obj)
billing_obj.zip("M5H 2N2")
auth_obj.billingDetails(billing_obj)
response_object = self.client.card_payments_service_handler().create_authorization(auth_obj)
response_object = self.client.card_payments_service_handler().create_authorization(auth_obj)
Request declined exception
auth_obj = Authorization(None)
card_obj = Card(None)
cardExpiry_obj = CardExpiry(None)
billing_obj = BillingDetails(None)
auth_obj.merchantRefNum("41sdfsf111hjh1111dfd1111dfdf111")
auth_obj.amount("4")
auth_obj.settleWithAuth("true")
card_obj.cardNum("4111111111111111")
card_obj.cvv("123")
auth_obj.card(card_obj)
cardExpiry_obj.month("2")
cardExpiry_obj.year("2017")
card_obj.cardExpiry(cardExpiry_obj)
billing_obj.zip("M5H 2N2")
auth_obj.billingDetails(billing_obj)
response_object = self.client.card_payments_service_handler().create_authorization(auth_obj)
Invalid credentials exception
client_bad_req = OptimalApiClient("dev-53224", "89764-353224", "TEST")
auth_obj = Authorization(None)
card_obj = Card(None)
cardExpiry_obj = CardExpiry(None)
billing_obj = BillingDetails(None)
auth_obj.merchantRefNum(RandomTokenGenerator().generateToken())
auth_obj.amount("41")
auth_obj.settleWithAuth("true")
card_obj.cardNum("4111111111111111")
card_obj.cvv("123")
auth_obj.card(card_obj)
cardExpiry_obj.month("2")
cardExpiry_obj.year("2017")
card_obj.cardExpiry(cardExpiry_obj)
billing_obj.zip("M5H 2N2")
auth_obj.billingDetails(billing_obj)
response_object = self.client_bad_req.card_payments_service_handler().create_authorization(auth_obj)
Entity not found exception
auth_obj = Authorization(None)
auth_obj.id("8976435322347893749387345344")
response_object = self.client.card_payments_service_handler().lookup_authorization_with_id(auth_obj)
Invalid request exception
auth_obj = Authorization(None)
card_obj = Card(None)
cardExpiry_obj = CardExpiry(None)
auth_obj.merchantRefNum("787sdfsf4564hjh13434dfd343dfd3431")
auth_obj.amount("10")
auth_obj.settleWithAuth("true")
card_obj.cardNum("4111111111111111")
card_obj.cvv("123")
auth_obj.card(card_obj)
cardExpiry_obj.month("2")
cardExpiry_obj.year("2017")
card_obj.cardExpiry(cardExpiry_obj)
response_object = self.client.card_payments_service_handler().create_authorization(auth_obj)
API exception
auth_obj = Authorization(None)
card_obj = Card(None)
cardExpiry_obj = CardExpiry(None)
billing_obj = BillingDetails(None)
auth_obj.merchantRefNum("34534sdfsf54765hjh456dfd456dfdt7567")
auth_obj.amount("6")
auth_obj.settleWithAuth("true")
card_obj.cardNum("4111111111111111")
card_obj.cvv("123")
auth_obj.card(card_obj)
cardExpiry_obj.month("2")
cardExpiry_obj.year("2017")
card_obj.cardExpiry(cardExpiry_obj)
billing_obj.zip("M5H 2N2")
auth_obj.billingDetails(billing_obj)
response_object = self.client.card_payments_service_handler().create_authorization(auth_obj)
Did you find this page useful?