Exceptions - PaySimple/PaySimpleSDK GitHub Wiki
Home | Account Service | Customer Service | Payment Service | Payment Schedule Service | PagedResult | Exceptions
PaySimpleException
PaySimpleException are thrown when an object cannot be validated.
PaySimpleException Topology
The PaySimpleException has the following members:
- IEnumerable<ValidationError> ValidationErrors
ValidationError contain information germane to validation errors found with objects passed into the SDK.
PaySimpleException Interrogation
The PaySimpleException can be interrogated in the following fashion
try
{
var settings = new PaySimpleSettings("AoOtRylA63570WmH3eqChyFRqwhTnA2g0dnsV7zzQko4s4yKWdBorA1WiT7dK2H2xz06P562Hqv0heYBdfNamfQyxX50drtpL8s7", "AUserName");
var customerService = new CustomerService(settings);
var customer = new Customer
{
FirstName = "River"
};
// LastName is required to create a customer so a PaySimpleException will be thrown
var result = await customerService.CreateCustomerAsync(Customer);
... do something interesting with the result ...
}
catch (PaySimpleException ex)
{
foreach (var e in ex.ValidationErrors)
{
... figure out what failed to validate ...
}
}
PaySimpleEndpointException
PaySimpleEndpointException are thrown when the PaySimple API returns a non successful HTTP Status Code.
PaySimpleEndpointException Topology
The PaySimpleEndpointException has the following members:
- IEnumerable<EndpointError> EndpointErrors
EndpointErrors contain information germane to HTTP Status errors returned from the Constant Contact API.
PaySimpleEndpointException Interrogation
The PaySimpleEndpointException can be interrogated in the following fashion
try
{
var settings = new PaySimpleSettings("AoOtRylA63570WmH3eqChyFRqwhTnA2g0dnsV7zzQko4s4yKWdBorA1WiT7dK2H2xz06P562Hqv0heYBdfNamfQyxX50drtpL8s7", "AUserName");
var paymentService = new PaymentService(settings);
var payment = new Payment
{
AccountId = 123456,
Amount = 10.00M
};
// Account 123456 does not exist
var result = await paymentService.CreatePayment(payment);
}
catch (PaySimpleEndpointException ex)
{
foreach (var e in ex.EndpointErrors)
{
... figure out what failed ...
}
}