API Errors - nov/paypal-express GitHub Wiki

API Errors

When PayPal API returns failure response, paypal-express raises Paypal::Exception::APIError.

Since PayPal IPN API returns Failure as string and PayPal NVP API (includes Express API) returns Hash (form-urlencoded params), Paypal::Exception::APIError#response is String for IPN and Paypal::Exception::APIError::Response instance for NVP.

begin
  # Invalid API Request
rescue Paypal::Exception::APIError => e
  e.message # => 'PayPal API Error'
  e.response # => Paypal::Exception::APIError::Response
  e.response.details # => Array of Paypal::Exception::APIError::Response::Detail. This includes error details for each payment request.
end

See spec code for more details.

ref.) API Error Codes – PayPal Developers
https://developer.paypal.com/webapps/developer/docs/classic/api/errorcodes/

Appendix

When HTTP-level error occured, paypal-express raises Paypal::Exception::HttpError.
Both Paypal::Exception::HttpError and Paypal::Exception::APIError are subclass of Paypal::Exception.

⚠️ **GitHub.com Fallback** ⚠️