Skip to content

unipag/unipag-net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unipag Client for .Net

Requirements

  • .NET Framework versions from 2.0 to 4.5
  • Newtonsoft.Json versions 4.5.x or 5.0.x

Installation

Install using NuGet (recommended):

PM> Install-Package Unipag

API keys configuration

To work with Unipag API, you will need to provide an API key. Get your API keys at https://my.unipag.com > API keys. API key can be defined globally in your App.config as following:

<appSettings>
    <add key="UnipagApiKey" value="<your-secret-API-key>"/>
</appSettings>

Another way of setting Unipag API key globally is to pass it to Unipag.Config class:

Please note that Unipag.Config setting will have priority over App.config.

API keys for multiple Unipag accounts

If your application deals with multiple Unipag accounts, you may find that the most convenient way will be to pass API keys directly to methods which interact with Unipag API:

Providing API key directly in method call has highest priority and will override both App.config and Unipag.Config settings.

When object instance is retrieved from Unipag, API key is stored in its ApiKey property and will be used for subsequent operations this object, so you will not have to provide it again. Consider the following example:

Sample usage

Create invoice

Create a new instance of Unipag.Invoice class and either call .Save() on it, or pass to Invoice.Create method. Both methods return Invoice instance with latest information updated from Unipag. Here is an example with Invoice.Create:

Handle webhook from Unipag

Create a standalone page on your website which will handle events sent by Unipag. Register URL of this page at https://my.unipag.com > Webhooks. Initialize page code as following (example for ASP.NET MVC):

Tip: webhooks can be a pain to debug. Check out Unipag Network Activity log, it is available at https://my.unipag.com > Network Activity. You may find it useful for your webhook handlers debugging.

Usage of Invoice.CustomData property

Invoice objects in Unipag API have an optional "custom_data" field, which can store up to 32KB of arbitrary data in JSON format. You can freely use this field to store additional application-specific information about your invoices.

In Unipag Client for .Net, custom_data field is mapped into CustomData property and has JToken type. Please refer to Json.Net documentation for full description of JToken API. Here is some very basic example:

Report bugs

Report issues to the project's Issues Tracking on Github.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages