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
client.card_payment_service.authorize auth
client.card_payment_service.authorize auth
Request declined exception
auth = Paysafe::CardPayments::Authorization.new({
     merchantRefNum: "0f8fad5bd9cb469fa16570867728950e",
     amount: 4, # The bank has requested that you process the transaction manually by calling the card holder's credit card company.
     settleWithAuth: false,
     card: {
       cardNum: 4111111111111111,
       cvv: 123,
       cardExpiry: {
         month: "06",
         year: "2020"
       }
     },
     billingDetails: {
       zip: "M5H 2N2"
     }
   })

   client.card_payment_service.authorize auth
Invalid credentials exception
invalid_client = Paysafe::OptimalApiClient.new "1234", "5678", Paysafe::Environment::TEST, 12345
auth = Paysafe::CardPayments::Authorization.new({
  id: 1234567890
})

invalid_client.card_payment_service.get_auth auth
Entity not found exception
auth = Paysafe::CardPayments::Authorization.new({
  id: 1234
})

client.card_payment_service.get_auth auth
Invalid request exception
auth = Paysafe::CardPayments::Authorization.new({
  merchantRefNum: "0f8fad5bd9cb469fa16570867728950e",
  amount: 10,
  card: {
    cardNum: 4111111111111111,
    cvv: 123,
    cardExpiry: {
      month: "06",
      year: "2020"
    }
  }
})

client.card_payment_service.authorize auth
API exception
auth = Paysafe::CardPayments::Authorization.new({
  merchantRefNum: "0f8fad5bd9cb469fa16570867728950e",
  amount: 6, # Clearing house timeout (although the simulator returns immediately; if delay is desired, see amount 96).
  settleWithAuth: false,
  card: {
    cardNum: 4111111111111111,
    cvv: 123,
    cardExpiry: {
      month: "06",
      year: "2020"
    }
  },
  billingDetails: {
    zip: "M5H 2N2"
  }
})

client.card_payment_service.authorize auth
Did you find this page useful?