VNS.NetsEasy
4.0.0
dotnet add package VNS.NetsEasy --version 4.0.0
NuGet\Install-Package VNS.NetsEasy -Version 4.0.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="VNS.NetsEasy" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VNS.NetsEasy --version 4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VNS.NetsEasy, 4.0.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.
// Install VNS.NetsEasy as a Cake Addin #addin nuget:?package=VNS.NetsEasy&version=4.0.0 // Install VNS.NetsEasy as a Cake Tool #tool nuget:?package=VNS.NetsEasy&version=4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VNS NetsEasy
Simple integration to NetsEasy
Installation
Use the package manager nuget to install.
dotnet add package VNS.NetsEasy
Init payment
// Test variable
var _isTest = true;
// Keys - Find your keys in NetsEasy portal
var _secretKey = "test-secret-key-XXXXXXXX";
var _checkoutKey = "test-checkout-key-XXXXXXXX";
if(!_isTest){ // If not test, use live keys
_secretKey = "live-secret-key-XXXXXXXX";
_checkoutKey = "live-checkout-key-XXXXXXXX";
}
// Init and build order
var easy = new NetsEasy(_secretKey, _isTest){
TermsUrl = "https://domain.com/Terms",
ReturnUrl = "https://domain.com/ReturnUrl",
ShowMerchantName = true, // Display merchant name on payform
ShowSummary = true, // Display cart summery on payform
ChargeOrder = false, // Should the order be charged after complete
IsSubscription = false, // If it's a subscription or single payment
PricesIncludeTax = true, // Does prices include tax (Default 25% tax)
IntegrationType = IntegrationType.EmbeddedCheckout, // Integration type: EmbeddedCheckout or hostedPaymentPage
Customer = new VNS.NetsEasy.Customer() { // Customer object
Id = "0001",
CompanyName = "My Company",
FirstName = "John",
LastName = "Doe",
AddressLine1 = "My address",
ZipCode = "0000",
City = "My Cirt",
Phone = "00000000",
Email = "email@domain.com"
}
};
// Add items to order
for(int i = 1; i <= 1; i++){
easy.Items.Add(new VNS.NetsEasy.Item() {
Id = $"Item {i}",
Name = $"Vare {i}",
Amount = 1,
Unit = "stk",
Price = decimal.Parse("100")
});
}
// Add webhooks - See NetsEasy documentation for more information
easy.WebHooks.Add(new VNS.NetsEasy.WebHook(){
Auth = "MyAuthKey",
Name = "payment.checkout.completed", // See Webhook section or NetsEasy documentation for more information
Url = "https://domain.com/WebHook",
Headers = new { // Add as many as needed
name = "John Doe",
email = "email@domain.com",
}
});
// Init payment
var result = easy.InitPayment(out string payload);
// Debug stuff
var statusCode = easy.StatusCode; // Get status code from NetsEasy
var statusDescription = easy.StatusDescription; // Get status description from NetsEasy
var paymentId = easy.PaymentId; // Get the paymentId
var payload = payload; // Will return the raw json that is sent to NetsEasy
var result = result; // Will return the raw json that contains paymentid and/or hosted url
// Check integration type
if(_integrationType == _integrationType.EmbeddedCheckout){
var htmlForm = easy.GetEmbedHtml(_checkoutKey); // Will return the html for the payment form to embed
} else { // Hosted
var hostedUrl = easy.GetHostUrl(); // Will return the url to the payment form
}
Get payment
// Test variable
var _isTest = true;
// Keys - Find your keys in NetsEasy portal
var _secretKey = "test-secret-key-XXXXXXXX";
if(!_isTest){ // If not test, use live key
_secretKey = "live-secret-key-XXXXXXXX";
}
// Init
var easy = new NetsEasy(_secretKey, _isTest);
// Get payment
string paymentId = "";
var payment = easy.GetPayment(paymentId); // Will return raw json
Charge payment
// Test variable
var _isTest = true;
// Keys - Find your keys in NetsEasy portal
var _secretKey = "test-secret-key-XXXXXXXX";
if(!_isTest){ // If not test, use live key
_secretKey = "live-secret-key-XXXXXXXX";
}
// Init
var easy = new NetsEasy(_secretKey, _isTest);
// Charge payment
string paymentId = "";
var payment = easy.ChargePayment(paymentId) // Will return raw json
Cancel payment
// Test variable
var _isTest = true;
// Keys - Find your keys in NetsEasy portal
var _secretKey = "test-secret-key-XXXXXXXX";
if(!_isTest){ // If not test, use live key
_secretKey = "live-secret-key-XXXXXXXX";
}
// Init
var easy = new NetsEasy(_secretKey, _isTest);
// Cancel payment
string paymentId = "";
var payment = easy.CancelPayment(paymentId) // Will return raw json
Get subscription
// Test variable
var _isTest = true;
// Keys - Find your keys in NetsEasy portal
var _secretKey = "test-secret-key-XXXXXXXX";
if(!_isTest){ // If not test, use live key
_secretKey = "live-secret-key-XXXXXXXX";
}
// Init
var easy = new NetsEasy(_secretKey, _isTest);
// Get subscription
string subscriptionId = "";
var subscription = easy.GetSubscription(subscriptionId); // Will return raw json
Charge subscription
// Test variable
var _isTest = true;
// Keys - Find your keys in NetsEasy portal
var _secretKey = "test-secret-key-XXXXXXXX";
if(!_isTest){ // If not test, use live key
_secretKey = "live-secret-key-XXXXXXXX";
}
// Init
var easy = new NetsEasy(_secretKey, _isTest);
// Add items to order
for(int i = 1; i <= 1; i++){
easy.Items.Add(new VNS.NetsEasy.Item() {
Id = $"Item {i}",
Name = $"Vare {i}",
Amount = 1,
Unit = "stk",
Price = decimal.Parse("100")
});
}
// Add webhooks - See NetsEasy documentation for more information
easy.WebHooks.Add(new VNS.NetsEasy.WebHook(){
Auth = "MyAuthKey",
Name = "payment.checkout.completed", // See Webhook section or NetsEasy documentation for more information
Url = "https://domain.com/WebHook",
Headers = new { // Add as many as needed
name = "John Doe",
email = "email@domain.com",
}
});
// Charge subscription
string subscriptionId = "";
var subscription = easy.ChargeSubscription(subscriptionId); // Will return raw json
Webhook
/* Subscription Hook Names
payment.charge.created
payment.charge.created.v2
payment.charge.failed
*/
/* Payment Hook Names
payment.created
payment.reservation.created
payment.reservation.created.v2
payment.checkout.completed
payment.charge.created
payment.charge.created.v2
payment.charge.failed
payment.refund.initiated
payment.refund.initiated.v2
payment.refund.failed
payment.refund.completed
payment.cancel.created
payment.cancel.failed
*/
var auth = WebHook.GetAuth(); // Will return the string value from the auth tag set when building the webhook
var name = WebHook.GetName(); // Will return the name of the webhook
var headers = WebHook.GetHeaders(); // Will return IHeaderDictionary with all headers
var data = WebHook.GetData(); // Will return the posted body
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.