The Payabli C# library provides convenient access to the Payabli APIs from C#.
API reference documentation is available here.
This SDK requires:
dotnet add package PayabliApi
Instantiate and use the client with the following:
using PayabliApi;
var client = new PayabliApiClient("API_KEY");
await client.MoneyIn.GetpaidAsync(
new RequestPayment
{
Body = new TransRequestBody
{
CustomerData = new PayorDataRequest { CustomerId = 4440 },
EntryPoint = "f743aed24a",
Ipaddress = "255.255.255.255",
PaymentDetails = new PaymentDetail { ServiceFee = 0, TotalAmount = 100 },
PaymentMethod = new PayMethodCredit
{
Cardcvv = "999",
Cardexp = "02/27",
CardHolder = "Kassiane Cassian",
Cardnumber = "4111111111111111",
Cardzip = "12345",
Initiator = "payor",
Method = "card",
},
},
}
);
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.
using PayabliApi;
try {
var response = await client.MoneyIn.GetpaidAsync(...);
} catch (PayabliApiApiException e) {
System.Console.WriteLine(e.Body);
System.Console.WriteLine(e.StatusCode);
}
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retryable when any of the following HTTP status codes is returned:
Use the MaxRetries
request option to configure this behavior.
var response = await client.MoneyIn.GetpaidAsync(
...,
new RequestOptions {
MaxRetries: 0 // Override MaxRetries at the request level
}
);
The SDK defaults to a 30 second timeout. Use the Timeout
option to configure this behavior.
var response = await client.MoneyIn.GetpaidAsync(
...,
new RequestOptions {
Timeout: TimeSpan.FromSeconds(3) // Override timeout to 3s
}
);
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
A full reference for this library is available here.