Skip to content

TransferZero SDK for .NET, including C# and VB.NET

License

Notifications You must be signed in to change notification settings

transferzero/transferzero-sdk-dotnet

Repository files navigation

TransferZero.Sdk - the C# library for the TransferZero API

TransferZero API

  • API version: 1.0

Reference documentation for the TransferZero API V1

For more information, please visit:

This .NET SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0
  • SDK version: 1.36.4
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Frameworks supported

  • .NET 4.5 or later
  • .NET Core >=2.0

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using TransferZero.Sdk.Api;
using TransferZero.Sdk.Client;
using TransferZero.Sdk.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out TransferZero.Sdk.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Getting Started

Please follow the installation instruction.

You can find examples in the examples directory on the features required by the Onboarding documentation for the following languages:

  • C# on .NET 4.5
  • VB.NET on .NET 4.5
  • C# on .NET Core 2.0

Webhooks

To parse webhooks you can use the following snippet:

C#

string webhookContent = "<data from webhook>";

string url = "<url of the webhook endpoint>";

Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("Authorization-Nonce", "<nonce from webhook headers>");
headers.Add("Authorization-Signature", "<signature from webhook headerse>");
headers.Add("Authorization-Key", "<key from webhook headers>");

if (configuration.ValidWebhookRequest(url, webhookContent, headers)) {
    Webhook webhook = configuration.ParseString<Webhook>(webhookContent);

    if (webhook.Event.StartsWith("transaction"))
    {
        TransactionWebhook transactionWebhook = configuration.ParseString<TransactionWebhook>(webhookContent);
        System.Console.WriteLine(transactionWebhook);
    }
    else if (webhook.Event.StartsWith("recipient"))
    {
        RecipientWebhook recipientWebhook = configuration.ParseString<RecipientWebhook>(webhookContent);
        System.Console.WriteLine(recipientWebhook);
    }
    else if (webhook.Event.StartsWith("sender"))
    {
        SenderWebhook senderWebhook = configuration.ParseString<SenderWebhook>(webhookContent);
        System.Console.WriteLine(senderWebhook);
    }
    else if (webhook.Event.StartsWith("document"))
    {
        DocumentWebhook documentWebhook = configuration.ParseString<DocumentWebhook>(webhookContent);
        System.Console.WriteLine(documentWebhook);
    }
    else if (webhook.Event.StartsWith("payout_method"))
    {
        PayoutMethodWebhook payoutMethodWebhook = configuration.ParseString<PayoutMethodWebhook>(webhookContent);
        System.Console.WriteLine(payoutMethodWebhook);
    }
}

VB.NET

Dim webhookContent As String = "{<data from webhook>}"

Dim url As String = "<url of webhook request>"
Dim headers As Dictionary(Of String, String) = New Dictionary(Of String, String)()

headers.Add("Authorization-Nonce", "<nonce from webhook headers>")
headers.Add("Authorization-Signature", "<signature from webhook headers>")
headers.Add("Authorization-Key", "<key from webhook headers>")

If configuration.ValidWebhookRequest(url, webhookContent, headers) Then
    Dim webhook As Webhook = configuration.ParseString(Of Webhook)(webhookContent)

    If webhook.[Event].StartsWith("transaction") Then
        Dim transactionWebhook As TransactionWebhook = configuration.ParseString(Of TransactionWebhook)(webhookContent)
        System.Console.WriteLine(transactionWebhook)
    ElseIf webhook.[Event].StartsWith("recipient") Then
        Dim recipientWebhook As RecipientWebhook = configuration.ParseString(Of RecipientWebhook)(webhookContent)
        System.Console.WriteLine(recipientWebhook)
    ElseIf webhook.[Event].StartsWith("sender") Then
        Dim senderWebhook As SenderWebhook = configuration.ParseString(Of SenderWebhook)(webhookContent)
        System.Console.WriteLine(senderWebhook)
    ElseIf webhook.[Event].StartsWith("document") Then
        Dim documentWebhook As DocumentWebhook = configuration.ParseString(Of DocumentWebhook)(webhookContent)
        System.Console.WriteLine(documentWebhook)
    ElseIf webhook.[Event].StartsWith("payout_method") Then
        Dim payoutMethodWebhook As PayoutMethodWebhook = configuration.ParseString(Of PayoutMethodWebhook)(webhookContent)
        System.Console.WriteLine(payoutMethodWebhook)
    End If
End If

Documentation for API Endpoints

All URIs are relative to https://api-sandbox.transferzero.com/v1

Class Method HTTP request Description
APILogsApi GetApiLog GET /api_logs/{API Log ID} Fetch an individual API log
APILogsApi GetApiLogs GET /api_logs Fetch a list of API logs
AccountDebitsApi PostAccountsDebits POST /accounts/debits Creating an account debit
AccountValidationApi PostAccountValidations POST /account_validations Validates the existence of a bank account or a mobile phone number
AccountsApi GetAccount GET /accounts/{Currency} Fetches account balance for specified currrency
AccountsApi GetAccounts GET /accounts Fetches account balances for all currencies
CurrencyInfoApi InfoCurrencies GET /info/currencies Getting a list of possible requested currencies
CurrencyInfoApi InfoCurrenciesIn GET /info/currencies/in Getting a list of possible input currencies
CurrencyInfoApi InfoCurrenciesOut GET /info/currencies/out Getting a list of possible output currencies
DocumentsApi GetDocument GET /documents/{Document ID} Fetching a document
DocumentsApi GetDocuments GET /documents Getting a list of documents
DocumentsApi PostDocuments POST /documents Creating a document
LogsApi GetWebhookLog GET /logs/{Webhook Log ID} Fetch an individual webhook log
LogsApi GetWebhookLogs GET /logs/webhooks Fetch a list of webhook logs
PayinMethodsApi DeletePayinMethod DELETE /payin_methods/{PayinMethod ID} Deleting a payin method
PayinMethodsApi GetPayinMethod GET /payin_methods/{PayinMethod ID} Fetching a payin method
PayinMethodsApi PatchPayinMethod PATCH /payin_methods/{PayinMethod ID} Updating a payin method
PayinMethodsApi RetryPayinMethod POST /payin_methods/{PayinMethod ID}/retry Retries PayinMethod
PaymentMethodsApi PaymentMethodsIn GET /info/payment_methods/in This method returns possible payin methods.
PaymentMethodsApi PaymentMethodsOut GET /info/payment_methods/out This method returns possible payout methods.
PayoutMethodsApi DeletePayoutMethod DELETE /payout_methods/{Payout Method ID} Deleting a payout method
PayoutMethodsApi GetPayoutMethod GET /payout_methods/{Payout Method ID} Fetching a payout method
PayoutMethodsApi GetPayoutMethods GET /payout_methods Listing payout methods
PayoutMethodsApi PatchPayoutMethod PATCH /payout_methods/{Payout Method ID} Updating a payout method
PayoutMethodsApi PostPayoutMethods POST /payout_methods Creating a payout method
RecipientsApi DeleteRecipient DELETE /recipients/{Recipient ID} Cancelling a recipient
RecipientsApi GetRecipients GET /recipients Getting a list of recipients with filtering
RecipientsApi PatchRecipient PATCH /recipients/{Recipient ID} Updating a recipient
RecipientsApi ProofOfPayments GET /recipients/{Recipient ID}/proof_of_payments Returns list of proof of payments
SendersApi DeleteSender DELETE /senders/{Sender ID} Deleting a sender
SendersApi GetSender GET /senders/{Sender ID} Fetching a sender
SendersApi GetSenders GET /senders Listing senders
SendersApi PatchSender PATCH /senders/{Sender ID} Updating a sender
SendersApi PostSenders POST /senders Creating a sender
TransactionsApi CalculateTransactions POST /transactions/calculate Calculates transaction amounts for a transaction payload
TransactionsApi CreateAndFundTransaction POST /transactions/create_and_fund Creates a new transaction and funds it from account balance
TransactionsApi GetTransaction GET /transactions/{Transaction ID} Fetch a single transaction
TransactionsApi GetTransactions GET /transactions Get a list of transactions
TransactionsApi PayinTransaction POST /transactions/{Transaction ID}/payin Creates a fake payin for transaction
TransactionsApi PayoutTransaction POST /transactions/{Transaction ID}/payout Creates a fake payout for transaction
TransactionsApi PostTransactions POST /transactions Creates a new transaction
TransactionsApi ValidateTransactions POST /transactions/validate Validates a transaction payload
WebhooksApi DeleteWebhook DELETE /webhooks/{Webhook ID} Unsubscribing from a webhook
WebhooksApi GetWebhook GET /webhooks/{Webhook ID} Find a webhook's details
WebhooksApi GetWebhookEvents GET /webhooks/events Find possible webhook events
WebhooksApi GetWebhooks GET /webhooks Listing webhooks
WebhooksApi PostWebhooks POST /webhooks Creating a webhook

Documentation for Models

Documentation for Authorization

You can set the API Key and Secret on the Configuration object for authentication:

C#

Configuration configuration = new Configuration();
configuration.ApiKey = "<key>";
configuration.ApiSecret = "<secret>";
configuration.BasePath = "https://api-sandbox.transferzero.com/v1";

VB.NET

Dim configuration As Configuration = New Configuration()
configuration.ApiKey = "<key>"
configuration.ApiSecret = "<secret>"
configuration.BasePath = "https://api-sandbox.transferzero.com/v1"

About

TransferZero SDK for .NET, including C# and VB.NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages