Tamara.SDK
1.0.2
dotnet add package Tamara.SDK --version 1.0.2
NuGet\Install-Package Tamara.SDK -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tamara.SDK" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tamara.SDK --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tamara.SDK, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tamara.SDK as a Cake Addin
#addin nuget:?package=Tamara.SDK&version=1.0.2
// Install Tamara.SDK as a Cake Tool
#tool nuget:?package=Tamara.SDK&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DotNet SDK
Tamara .NET SDK is a wrapper for the Tamara API.
Installation
- Using package manager: Install-Package Tamara.SDK -Version 1.0.2
- Using Manage NuGet Packages from visual studio with filter parameter: tamara.sdk
Usage
####Configure in appsettings.json Add a "tamaraPayment" field with baseUrl is Tamara payment's Url, apiToken & notificationPrivateKey are provided in our service. Example:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"tamaraPayment": {
"clientVersion": "1.0.0",
"baseUrl": "https://api-sandbox.tamara.co",
"requestTimeout": 10,
"apiToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhY2NvdW50SWQiOiI0NWQwMzAzOC1kM2I2LTQ1ODctYWY2Ny1hNDNlY2FlYjFiZDMiLCJ0eXBlIjoibWVyY2hhbnQiLCJzYWx0IjoiOTIwNDFjZDVlOTJlNDQ1MDg1ZTQ2NzgyZWFhYTY3NjkiLCJpYXQiOjE1OTIxMzM5NTEsImlzcyI6IlRhbWFyYSJ9.HASQ6UR1fabagwqkivmCqL4cFVDOw2cgBMRm5XPlJiNSfJ-gsgwqnPnEEn6-T7Sj4sU6Niee8pUPqP4_WsVQ6DojignLFg2cmrIS_dMIZyOXrZwMbhH6Y0fX5xt2yBVpEVjRbXVaEY4xgHNfMzLwz3mIqmJ-_xuwDDA-hGQk7xibbewDVdCDviSYRHSdzOPtIhy7dcx0CkyYWOncqpJ9YyePrrA1aqZeyWclxgAuZ6zYzsHM_o2e0zwZDqKi1spY11-s1ULSd1WmAWNwoKwy1C4jThJWlXl_E4-bPR_5CUcMHgy7Je9uN3Zfwuq7XODr7ShTnsEZ-xAQW7BxejqvIA",
"notificationPrivateKey": "b28fbd1412c7e40ce7aa625c38763f71",
"paths": {
"getPaymentType": "/checkout/payment-types",
"createCheckout": "/checkout",
"authoriseOrder": "/orders/{orderId}/authorise",
"cancelOrder": "/orders/{orderId}/cancel",
"capture": "/payments/capture",
"refund": "/merchants/orders/{orderId}/refund",
"getOrderDetails": "/orders/{orderId}",
"updateOrderReferenceId": "/orders/{orderId}/reference-id",
"registerWebHook": "/webhooks",
"retrieveWebhook": "/webhooks/{webhookId}",
"removeWebhook": "/webhooks/{webhookId}",
"updateWebhook": "/webhooks/{webhookId}"
}
}
}
There are two ways:
1. Use factory
- Create a ApiConfiguration instance
- Create a Logger instance
var apiConfiguration = new ApiConfiguration();
var builder = new ConfigurationBuilder()
.SetBasePath(Path.Combine(AppContext.BaseDirectory))
.AddJsonFile("appsettings.json", optional: true);
IConfiguration configuation = builder.Build();
configuation.GetSection("tamaraPayment").Bind(apiConfiguration);
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddLog4Net(new Log4NetProviderOptions()
{
Name = "TamaraApiClient",
Log4NetConfigFileName = "App_Data/log4net.xml"
});
});
var logger = loggerFactory.CreateLogger<ClientTest>();
_apiClient = CheckoutServiceFactory.CreateClient(apiConfiguration, logger);
2. Use dependency injection
ApiConfiguration & Logger were created as the same way above.
services.AddScoped<ITamaraApiClient, TamaraApiClient>(provider => new TamaraApiClient(apiConfiguration, logger));
Notification Service
1. Register notification service
services.AddScoped<ITammaraNotificationService, TamaraNotificationService>(provider => new TamaraNotificationService(apiConfiguration.NotificationPrivateKey, logger));
2. Create a controller to receive notification from Tamara
[HttpPost]
public async Task<IActionResult> ReceiveAuthoriseNotification()
{
var request = HttpContext.Request;
var result = await _tammaraNotificationService.ProcessAuthoriseNotification(request);
return Json(result);
}
[HttpPost]
public async Task<IActionResult> ReceiveWebhookNotification()
{
var request = HttpContext.Request;
var result = await _tammaraNotificationService.ProcessWebhook(request);
return Json(result);
}
3. Test:
POST: https://localhost:2600/Notification/ReceiveNotification Header:
Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MDEzMDYwOTcsImlhdCI6MTYwMTMwNDI5NywiaXNzIjoiVGFtYXJhIn0.JuoMMVuStl5RLKxfNDRH7nxjFaQBp4YQr-FH9DDR9zk
Body:
{
"order_id": "16280ad8-cde0-4d27-b06d-e6658fe53382",
"order_reference_id": "50548981",
"order_status": "approved",
"data": []
}
API Support:
- GetPaymentTypes --- /checkout/payment-types
- CreateCheckout --- /checkout
- AuthoriseOrder --- /orders/{orderId}/authorise
- CancelOrder --- /orders/{orderId}/cancel
- Capture --- /payments/capture
- Refund --- /merchants/orders/{orderId}/refund
- GetOrderDetails --- /orders/{orderId}
- UpdateOrderReferenceId --- /orders/{orderId}/reference-id
- RegisterWebhook --- /webhooks
- RetrieveWebhook --- /webhooks/{webhookId}
- RemoveWebhook --- /webhooks/{webhookId}
- UpdateWebhook --- /webhooks/{webhookId}
- GetOrderDetailsByReference --- /merchants/orders/reference-id/{orderReferenceId}
Release notes:
1.0.2: updated simple refund flow
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- JWT (>= 7.2.2)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 3.1.8)
- Microsoft.Extensions.Logging.Abstractions (>= 3.1.8)
- Newtonsoft.Json (>= 12.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.0.2
- Fixed bugs
- Support Pay in X