SaferPay.Netcore 1.51.0

dotnet add package SaferPay.Netcore --version 1.51.0
                    
NuGet\Install-Package SaferPay.Netcore -Version 1.51.0
                    
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="SaferPay.Netcore" Version="1.51.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SaferPay.Netcore" Version="1.51.0" />
                    
Directory.Packages.props
<PackageReference Include="SaferPay.Netcore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SaferPay.Netcore --version 1.51.0
                    
#r "nuget: SaferPay.Netcore, 1.51.0"
                    
#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.
#:package SaferPay.Netcore@1.51.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SaferPay.Netcore&version=1.51.0
                    
Install as a Cake Addin
#tool nuget:?package=SaferPay.Netcore&version=1.51.0
                    
Install as a Cake Tool

SaferPay.NetCore Json Api V1.51

This repository is an implementation of the SaferPay.Net library, with updates to use .NetCore 6.0 and RestSharp instead of HttpClient. All methods have been extended with sync and async calls.

The implementation is based on the latest version of the JSON API, v1.51, which can be found at the following URL: http://saferpay.github.io/jsonapi/#ChapterTransaction

You can find Test Cards and explanation of usage at: https://docs.saferpay.com/home/integration-guide/testing-and-go-live#visa-and-v-pay

What's New

  • Upgrade to .NetCore 6.0
  • HttpClient has been replaced by RestSharp
  • Updated to use the latest version of the JSON API, v1.51
  • Replaced BaseUri with SandBox mode. BaseUri is now generated based on SandBox mode for testing or live environments.
  • Updated and improved constructors for easier usage.
  • Added descriptions to Properties based on the API documentation.
  • Converted string properties to Enum values.
  • Added Examples and Test Console App in the Solution.
  • Added Interface Channels for ease of usage.
  • Added Extensions for the most used methods for direct use in the client.
  • Added IsSuccess and Error properties in ResultObject.
  • Updated all enum values, models, and interfaces.

Methods

Implemented all methods:

  • Payment Page Methods: Initialize, Assert
  • Transaction Methods: Initialize, Authorize, AuthorizeDirect, AuthorizeReferenced, Capture, MultipartCapture, AssertCapture, MultipartFinalize, Refund, AssertRefund, RefundDirect, Cancel, RedirectPayment, AssertRedirectPayment, Inquire, AlternativePayment, QueryAlternativePayment, DccInquiry
  • Secure Card Data: Insert, AssertInsert, InsertDirect, Update, Delete, Inquire
  • Batch: Close
  • Omni Channel: InsertAlias, AcquireTransaction

Global Settings and Usage (With Client Extensions)

Define Settings;

SaferPay.Config.Settings.Default.Username = "ApiUserName";
SaferPay.Config.Settings.Default.Password = "ApiPassword";
SaferPay.Config.Settings.Default.TerminalId = "TerminalId";
SaferPay.Config.Settings.Default.CustomerId = "CustomerId";
SaferPay.Config.Settings.Default.SandBox = true;

Get Client Instance;

ISaferPayClient Client = SaferPay.Config.Settings.Client();

Initialize request for Payment Page;

string OrderID = "123456";

InitializePaymentPageRequest req = new InitializePaymentPageRequest();
req.TerminalId = TestConfig.TerminalId;
req.Payment = new Payment(123.45M, "TRY", OrderID);
req.ReturnUrl = $"{TestConfig.WebPage}payment-page?orderId={OrderID}";

Call Api Async;

var result = await Client.InitializePaymentPageAsync(req);
if (result != null && result.IsSuccess)
{
    // Success
    Console.Write("Response Successful : ");
    Console.WriteLine(result.Json());
}
else if (result != null)
{
    // Failed
    Console.Write("Response Failed : ");
    Console.WriteLine(result.Error.Json());
}
else
{
    // Error
    Console.Write("Error !");
}

Call Api Sync;

var result = Client.InitializePaymentPage(req);
if (result != null && result.IsSuccess)
{
    // Success
    Console.Write("Response Successful : ");
    Console.WriteLine(result.Json());
} else if(result != null)
{
    // Failed
    Console.Write("Response Failed : ");
    Console.WriteLine(result.Error.Json());
} else
{
    // Error
    Console.Write("Error !");
}

Basic Usage With Interface Channels

Initialize the ApiClient;

ISaferPayClient Client = new SaferPayClient("CustomerId", "TerminalId", "UserName", "PassWord", true);

Get Interface Channel to use, example based on Transaction;

ITransaction payment = Client.Transaction;

Created Credit Card request;

string OrderID = "123456";

InitializeRequest req = new InitializeRequest(TestConfig.TerminalId, 123.45M, "TRY", OrderID, $"{TestConfig.WebPage}transaction?orderId={OrderID}").SetCard("9010004150000009", 12, 30, "123", "Card Holder Name");

Call Api Async;

var result = await payment.InitializeAsync(req);
if (result != null && result.IsSuccess)
{
    // Success
    Console.Write("Response Successful : ");
    Console.WriteLine(result.Json());
}
else if (result != null)
{
    // Failed
    Console.Write("Response Failed : ");
    Console.WriteLine(result.Error.Json());
}
else
{
    // Error
    Console.Write("Error !");
}

Call Api Sync;

var result = payment.Initialize(req);
if (result != null && result.IsSuccess)
{
    // Success
    Console.Write("Response Successful : ");
    Console.WriteLine(result.Json());
} else if(result != null)
{
    // Failed
    Console.Write("Response Failed : ");
    Console.WriteLine(result.Error.Json());
} else
{
    // Error
    Console.Write("Error !");
}

Changelog

v1.51

  • Updated to use the latest version of the JSON API, v1.51
  • added PAYPAL as valid value for field Type in Alias/Insert
  • added ONLINE_CHALLENGED as valid value for field Type of container Check in Alias/Insert
  • removed OK_AUTHENTICATED as valid value from field Result of container CheckResult.
  • removed INVOICE as valid value from PaymentMethods in PaymentPage/Initialize
  • added fields Authenticated and AuthenticationType to container AuthenticationResult. Removed field Result from container in return.
  • added field FundingSource to container Card
  • field CountryCode in container ForeignRetailer is now mandatory.

v1.50

  • Updated to use the latest version of the JSON API, v1.50
  • Added value ONLINE_STRONG to Type in the Check container and added new container ExternalThreeDS in Alias/InsertDirect
  • Added GIFTCARD as valid value for the field PaymentMethods
  • Introduced a new function to provide Dynamic Currency Conversion (DCC) inquiry details for your customer: Transaction\DccInquiry
  • The payment methods GIROPAY, PAYDIREKT, SOFORT and WLCRYPTOPAYMENTS are no longer supported.
  • Transaction/AuthorizeDirect is extended with the new subcontainer DCC, which references the response from Transaction/DccInquiry and payer's decision whether he accepts or declines DCC offer
  • Added WERO as valid value for the field PaymentMethods
  • Added HolderName and IBAN to the BankAccount container in PaymentPage/Assert
  • Transaction/RefundDirect is extended with the new subcontainer BankAccount. This is a required container for PostFinance Instant Payout

v1.46

  • Updated to use the latest version of the JSON API, v1.46
  • Added new subcontainer ExternalThreeDS to container Authentication. This affects the following requests: Transaction/AuthorizeDirect
  • Updated AuthorizeDirect method to use the new ExternalThreeDS subcontainer.

v1.45.01

  • Added REKA as alternative payment method to PaymentPagePaymentMethods.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.51.0 122 3/23/2026
1.50.0 172 1/26/2026
1.46.0 813 5/16/2025
1.45.2 926 4/28/2025
1.45.1 387 3/15/2025
1.43.1 267 11/29/2024
1.36.1 577 10/22/2023
1.33.2 1,284 4/18/2023
1.33.1 341 4/18/2023