Moyasar's .NET Client Library
This library targets following frameworks:
- .Net Standard 2.0
- .Net Framework 4.0
If you are using dotnet
command line tools you can add the library to
your project using the following command
dotnet add package moyasar
Or if you are using Nuget Package Manager
PM> Install-Package moyasar
Please note that this installation method is not recommended
To Install the library manually please download the last release from the releases section and reference it in your project.
Make sure to set the API key before proceeding
MoyasarService.ApiKey = "YouKeyHere";
Make sure you always try to catch the following exceptions:
ValidationException
NetworkException
ApiException
To fetch a payment from Moyasar, use the following:
Payment.Fetch("Payment-Id");
To refund a payment, one must have a Payment instance somePayment
then
invoke the following:
somePayment.Refund();
To update your payment, change Description
property on that payment,
then invoke Update
:
somePayment.Description = "Colombia, Narino Sandona, Medium Roast (Special)";
somePayment.Update();
To list or search for payments at Moyasar, do the following:
var result = Payment.List();
or
var result = Payment.List(new SearchQuery()
{
Id = "SomeId",
Source = "creditcard OR sadad",
Status = "some status",
Page = 2,
CreatedAfter = DateTime.Now.AddDays(-5),
CreatedBefore = DateTime.Now
});
All SearchQuery
parameters are optional, use what is needed
Use Invoice
class with the same methods as Payment
class, except
for the following:
To create an invoice for example:
var invoice = Invoice.Create(new InvoiceInfo()
{
Amount = 7000,
Currency = "SAR",
Description = "A 70 SAR invoice just because",
ExpiredAt = DateTime.Now.AddDays(3),
CallbackUrl = "http://www.example.com/invoice_callback"
});
To Cancel an Invoice:
someInvoice.Cancel();
For more details, please refer to the official documentation: https://moyasar.com/docs/api/
To run the tests use the following command
dotnet test