GithubHelp home page GithubHelp logo

moyasar / moyasar-dotnet Goto Github PK

View Code? Open in Web Editor NEW
14.0 10.0 5.0 185 KB

Moyasar .NET client library

Home Page: https://moyasar.com/docs/api/?csharp

License: MIT License

C# 100.00%
dotnet moyasar moyasar-dotnet invoice gateway csharp payment credit-card mada sadad

moyasar-dotnet's Introduction

Moyasar.Net

Build Status

Moyasar's .NET Client Library

Target Frameworks

This library targets following frameworks:

  1. .Net Standard 2.0
  2. .Net Framework 4.0

Installation

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

Manual Installation

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.

Usage

Setup

Make sure to set the API key before proceeding

MoyasarService.ApiKey = "YouKeyHere";

Payment

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

Invoice

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/

Testing

To run the tests use the following command

dotnet test

moyasar-dotnet's People

Contributors

abarrak avatar ahoshaiyan avatar ecleel avatar shoa48 avatar smss123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moyasar-dotnet's Issues

Unexpected character encountered while parsing value: R. Path '', line 0, position 0.

Hi there,

we have an exception when use List function like below:

Unexpected character encountered while parsing value: R. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue() at Newtonsoft.Json.JsonTextReader.Read() at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Moyasar.Providers.JsonSerializer.Deserialize[TType](String json) at Moyasar.MoyasarService.SendRequest(String httpMethod, String url, Dictionary`2 parameters) at Moyasar.Services.Payment.List(SearchQuery query)

assembly name : Newtonsoft.Json, Version=12.0.0.0, Culture=neutral
AssemblyVersion : v4.0.30319
ClassName :JsonTextReader
MethodName : ParseValue

Access transaction_url after creating a payment

It seems we can't access the transaction_url from the payment response.

if (this.SourceType == SourceType.CreditCard)
  {
    payment.Source = new CreditCard()
    {
      Type = (string)rs["source"]["type"],
      Company = (string)rs["source"]["company"],
      Name = (string)rs["source"]["name"],
      Number = (string)rs["source"]["number"],
      Message = (string)rs["source"]["message"]
    };
  }
return payment;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.