aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-01-30 01:41:08 +0100
committerivarlovlie <git@ivarlovlie.no>2022-01-30 01:41:08 +0100
commit36afcdf0988e753ae2178fb8220b02f2c4d0b2b2 (patch)
treed27cb629cd53eeef6737ddc86915d51a9ac4b9c3
parentbbe0fb036a790b6a23a478d3f047add63b3b07a6 (diff)
downloaddotnet-vipps-ecommerce-36afcdf0988e753ae2178fb8220b02f2c4d0b2b2.tar.xz
dotnet-vipps-ecommerce-36afcdf0988e753ae2178fb8220b02f2c4d0b2b2.zip
refactor: Convert solution for file-scoped namespaces
-rw-r--r--src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs25
-rw-r--r--src/IOL.VippsEcommerce.Tests/Helpers.cs25
-rw-r--r--src/IOL.VippsEcommerce/Helpers.cs121
-rw-r--r--src/IOL.VippsEcommerce/IVippsEcommerceService.cs75
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/EErrorGroupEnum.cs73
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/EStatusEnum.cs37
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/ETransactionStatus.cs35
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TAdditionalTransactionData.cs67
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TCustomerInfo.cs19
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TMerchantInfo.cs103
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TMerchantInfoPayment.cs19
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TShippingDetails.cs49
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TTransaction.cs31
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TTransactionInfo.cs19
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TTransactionInfoInitiate.cs89
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/TTransactionSummary.cs67
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsAuthorizationTokenResponse.cs95
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsErrorResponse.cs57
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsForceApproveRequest.cs31
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsGetPaymentDetailsResponse.cs173
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentRequest.cs39
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentResponse.cs31
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionRequest.cs27
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionResponse.cs51
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsPaymentInitiationCallbackResponse.cs165
-rw-r--r--src/IOL.VippsEcommerce/Models/Api/VippsRequestException.cs17
-rw-r--r--src/IOL.VippsEcommerce/Models/VippsConfiguration.cs211
-rw-r--r--src/IOL.VippsEcommerce/Models/VippsConfigurationKeyName.cs25
-rw-r--r--src/IOL.VippsEcommerce/Models/VippsConfigurationKeyNames.cs33
-rw-r--r--src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs47
-rw-r--r--src/IOL.VippsEcommerce/VippsEcommerceService.cs933
31 files changed, 1379 insertions, 1410 deletions
diff --git a/src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs b/src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs
index 0890043..366dcbb 100644
--- a/src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs
+++ b/src/IOL.VippsEcommerce.Tests/ConfigurationTests.cs
@@ -1,19 +1,18 @@
using Xunit;
-namespace IOL.VippsEcommerce.Tests
+namespace IOL.VippsEcommerce.Tests;
+
+public class InitialisationTests
{
- public class InitialisationTests
- {
- [Fact]
- public void Succeed_On_Valid_Minimal_Configuration() {
- var vippsEcommerceService = Helpers.GetVippsEcommerceService(o => {
- o.ApiUrl = "https://validuri.no";
- o.ClientId = "asdf";
- o.ClientSecret = "asdf";
- o.SecondarySubscriptionKey = "asdf";
- });
+ [Fact]
+ public void Succeed_On_Valid_Minimal_Configuration() {
+ var vippsEcommerceService = Helpers.GetVippsEcommerceService(o => {
+ o.ApiUrl = "https://validuri.no";
+ o.ClientId = "asdf";
+ o.ClientSecret = "asdf";
+ o.SecondarySubscriptionKey = "asdf";
+ });
- vippsEcommerceService.Configuration.Verify();
- }
+ vippsEcommerceService.Configuration.Verify();
}
}
diff --git a/src/IOL.VippsEcommerce.Tests/Helpers.cs b/src/IOL.VippsEcommerce.Tests/Helpers.cs
index 6c70cd8..53dd49b 100644
--- a/src/IOL.VippsEcommerce.Tests/Helpers.cs
+++ b/src/IOL.VippsEcommerce.Tests/Helpers.cs
@@ -3,20 +3,19 @@ using IOL.VippsEcommerce.Models;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Sdk;
-namespace IOL.VippsEcommerce.Tests
-{
- public static class Helpers
- {
- public static IVippsEcommerceService GetVippsEcommerceService(Action<VippsConfiguration> conf) {
- var services = new ServiceCollection();
- services.AddVippsEcommerceService(conf);
- var provider = services.BuildServiceProvider();
- var vippsEcommerceService = provider.GetService<IVippsEcommerceService>();
- if (vippsEcommerceService == default) {
- throw new NullException(nameof(vippsEcommerceService));
- }
+namespace IOL.VippsEcommerce.Tests;
- return vippsEcommerceService;
+public static class Helpers
+{
+ public static IVippsEcommerceService GetVippsEcommerceService(Action<VippsConfiguration> conf) {
+ var services = new ServiceCollection();
+ services.AddVippsEcommerceService(conf);
+ var provider = services.BuildServiceProvider();
+ var vippsEcommerceService = provider.GetService<IVippsEcommerceService>();
+ if (vippsEcommerceService == default) {
+ throw new NullException(nameof(vippsEcommerceService));
}
+
+ return vippsEcommerceService;
}
}
diff --git a/src/IOL.VippsEcommerce/Helpers.cs b/src/IOL.VippsEcommerce/Helpers.cs
index f7645a5..7e61181 100644
--- a/src/IOL.VippsEcommerce/Helpers.cs
+++ b/src/IOL.VippsEcommerce/Helpers.cs
@@ -4,82 +4,81 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
-namespace IOL.VippsEcommerce
+namespace IOL.VippsEcommerce;
+
+internal static class Helpers
{
- internal static class Helpers
- {
- private const int AES_BLOCK_BYTE_SIZE = 128 / 8;
- private static readonly RandomNumberGenerator _random = RandomNumberGenerator.Create();
+ private const int AES_BLOCK_BYTE_SIZE = 128 / 8;
+ private static readonly RandomNumberGenerator _random = RandomNumberGenerator.Create();
- public static bool IsNullOrWhiteSpace(this string value) => string.IsNullOrWhiteSpace(value);
- public static bool IsPresent(this string value) => !string.IsNullOrWhiteSpace(value);
+ public static bool IsNullOrWhiteSpace(this string value) => string.IsNullOrWhiteSpace(value);
+ public static bool IsPresent(this string value) => !string.IsNullOrWhiteSpace(value);
- public static bool IsDirectoryWritable(this string dirPath, bool throwIfFails = false) {
- try {
- using (var fs = File.Create(Path.Combine(dirPath, Path.GetRandomFileName()),
- 1,
- FileOptions.DeleteOnClose)
- ) { }
+ public static bool IsDirectoryWritable(this string dirPath, bool throwIfFails = false) {
+ try {
+ using (var fs = File.Create(Path.Combine(dirPath, Path.GetRandomFileName()),
+ 1,
+ FileOptions.DeleteOnClose)
+ ) { }
- return true;
- } catch {
- if (throwIfFails)
- throw;
+ return true;
+ } catch {
+ if (throwIfFails)
+ throw;
- return false;
- }
+ return false;
}
+ }
- //https://tomrucki.com/posts/aes-encryption-in-csharp/
- public static string EncryptWithAes(this string toEncrypt, string password) {
- var key = GetKey(password);
+ //https://tomrucki.com/posts/aes-encryption-in-csharp/
+ public static string EncryptWithAes(this string toEncrypt, string password) {
+ var key = GetKey(password);
- using var aes = CreateAes();
- var iv = GenerateRandomBytes(AES_BLOCK_BYTE_SIZE);
- var plainText = Encoding.UTF8.GetBytes(toEncrypt);
+ using var aes = CreateAes();
+ var iv = GenerateRandomBytes(AES_BLOCK_BYTE_SIZE);
+ var plainText = Encoding.UTF8.GetBytes(toEncrypt);
- using var encryptor = aes.CreateEncryptor(key, iv);
- var cipherText = encryptor
- .TransformFinalBlock(plainText, 0, plainText.Length);
+ using var encryptor = aes.CreateEncryptor(key, iv);
+ var cipherText = encryptor
+ .TransformFinalBlock(plainText, 0, plainText.Length);
- var result = new byte[iv.Length + cipherText.Length];
- iv.CopyTo(result, 0);
- cipherText.CopyTo(result, iv.Length);
+ var result = new byte[iv.Length + cipherText.Length];
+ iv.CopyTo(result, 0);
+ cipherText.CopyTo(result, iv.Length);
- return Convert.ToBase64String(result);
- }
+ return Convert.ToBase64String(result);
+ }
- private static Aes CreateAes() {
- var aes = Aes.Create();
- aes.Mode = CipherMode.CBC;
- aes.Padding = PaddingMode.PKCS7;
- return aes;
- }
+ private static Aes CreateAes() {
+ var aes = Aes.Create();
+ aes.Mode = CipherMode.CBC;
+ aes.Padding = PaddingMode.PKCS7;
+ return aes;
+ }
- public static string DecryptWithAes(this string input, string password) {
- var key = GetKey(password);
- var encryptedData = Convert.FromBase64String(input);
+ public static string DecryptWithAes(this string input, string password) {
+ var key = GetKey(password);
+ var encryptedData = Convert.FromBase64String(input);
- using var aes = CreateAes();
- var iv = encryptedData.Take(AES_BLOCK_BYTE_SIZE).ToArray();
- var cipherText = encryptedData.Skip(AES_BLOCK_BYTE_SIZE).ToArray();
+ using var aes = CreateAes();
+ var iv = encryptedData.Take(AES_BLOCK_BYTE_SIZE).ToArray();
+ var cipherText = encryptedData.Skip(AES_BLOCK_BYTE_SIZE).ToArray();
- using var decryptor = aes.CreateDecryptor(key, iv);
- var decryptedBytes = decryptor
- .TransformFinalBlock(cipherText, 0, cipherText.Length);
- return Encoding.UTF8.GetString(decryptedBytes);
- }
+ using var decryptor = aes.CreateDecryptor(key, iv);
+ var decryptedBytes = decryptor
+ .TransformFinalBlock(cipherText, 0, cipherText.Length);
+ return Encoding.UTF8.GetString(decryptedBytes);
+ }
- private static byte[] GetKey(string password) {
- var keyBytes = Encoding.UTF8.GetBytes(password);
- using var md5 = MD5.Create();
- return md5.ComputeHash(keyBytes);
- }
+ private static byte[] GetKey(string password) {
+ var keyBytes = Encoding.UTF8.GetBytes(password);
+ using var md5 = MD5.Create();
+ return md5.ComputeHash(keyBytes);
+ }
- private static byte[] GenerateRandomBytes(int numberOfBytes) {
- var randomBytes = new byte[numberOfBytes];
- _random.GetBytes(randomBytes);
- return randomBytes;
- }
+ private static byte[] GenerateRandomBytes(int numberOfBytes) {
+ var randomBytes = new byte[numberOfBytes];
+ _random.GetBytes(randomBytes);
+ return randomBytes;
}
-}
+} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/IVippsEcommerceService.cs b/src/IOL.VippsEcommerce/IVippsEcommerceService.cs
index a93080b..9ee2c69 100644
--- a/src/IOL.VippsEcommerce/IVippsEcommerceService.cs
+++ b/src/IOL.VippsEcommerce/IVippsEcommerceService.cs
@@ -3,50 +3,49 @@ using System.Threading.Tasks;
using IOL.VippsEcommerce.Models;
using IOL.VippsEcommerce.Models.Api;
-namespace IOL.VippsEcommerce
+namespace IOL.VippsEcommerce;
+
+public interface IVippsEcommerceService
{
- public interface IVippsEcommerceService
- {
- public VippsConfiguration Configuration { get; }
+ public VippsConfiguration Configuration { get; }
- public Task<VippsInitiatePaymentResponse> InitiatePaymentAsync(
- VippsInitiatePaymentRequest payload,
- CancellationToken ct = default
- );
+ public Task<VippsInitiatePaymentResponse> InitiatePaymentAsync(
+ VippsInitiatePaymentRequest payload,
+ CancellationToken ct = default
+ );
- public Task<VippsPaymentActionResponse> CapturePaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- );
+ public Task<VippsPaymentActionResponse> CapturePaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ );
- public Task<VippsPaymentActionResponse> CancelPaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- );
+ public Task<VippsPaymentActionResponse> CancelPaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ );
- public Task<VippsPaymentActionResponse> AuthorizePaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- );
+ public Task<VippsPaymentActionResponse> AuthorizePaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ );
- public Task<VippsPaymentActionResponse> RefundPaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- );
+ public Task<VippsPaymentActionResponse> RefundPaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ );
- public Task<bool> ForceApprovePaymentAsync(
- string orderId,
- VippsForceApproveRequest payload,
- CancellationToken ct = default
- );
+ public Task<bool> ForceApprovePaymentAsync(
+ string orderId,
+ VippsForceApproveRequest payload,
+ CancellationToken ct = default
+ );
- public Task<VippsGetPaymentDetailsResponse> GetPaymentDetailsAsync(
- string orderId,
- CancellationToken ct = default
- );
- }
+ public Task<VippsGetPaymentDetailsResponse> GetPaymentDetailsAsync(
+ string orderId,
+ CancellationToken ct = default
+ );
}
diff --git a/src/IOL.VippsEcommerce/Models/Api/EErrorGroupEnum.cs b/src/IOL.VippsEcommerce/Models/Api/EErrorGroupEnum.cs
index 8c6bf2f..c6a2a91 100644
--- a/src/IOL.VippsEcommerce/Models/Api/EErrorGroupEnum.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/EErrorGroupEnum.cs
@@ -1,47 +1,46 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+/// <summary>
+/// The error group. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-groups
+/// </summary>
+public enum EErrorGroupEnum
{
- /// <summary>
- /// The error group. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-groups
- /// </summary>
- public enum EErrorGroupEnum
- {
- /// <summary>
- /// Enum Authentication for value: Authentication
- /// </summary>
- [JsonPropertyName("Authentication")]
- AUTHENTICATION = 1,
+ /// <summary>
+ /// Enum Authentication for value: Authentication
+ /// </summary>
+ [JsonPropertyName("Authentication")]
+ AUTHENTICATION = 1,
- /// <summary>
- /// Enum Payments for value: Payments
- /// </summary>
- [JsonPropertyName("Payments")]
- PAYMENTS = 2,
+ /// <summary>
+ /// Enum Payments for value: Payments
+ /// </summary>
+ [JsonPropertyName("Payments")]
+ PAYMENTS = 2,
- /// <summary>
- /// Enum InvalidRequest for value: InvalidRequest
- /// </summary>
- [JsonPropertyName("InvalidRequest")]
- INVALID_REQUEST = 3,
+ /// <summary>
+ /// Enum InvalidRequest for value: InvalidRequest
+ /// </summary>
+ [JsonPropertyName("InvalidRequest")]
+ INVALID_REQUEST = 3,
- /// <summary>
- /// Enum VippsError for value: VippsError
- /// </summary>
- [JsonPropertyName("VippsError")]
- VIPPS_ERROR = 4,
+ /// <summary>
+ /// Enum VippsError for value: VippsError
+ /// </summary>
+ [JsonPropertyName("VippsError")]
+ VIPPS_ERROR = 4,
- /// <summary>
- /// Enum User for value: User
- /// </summary>
- [JsonPropertyName("User")]
- USER = 5,
+ /// <summary>
+ /// Enum User for value: User
+ /// </summary>
+ [JsonPropertyName("User")]
+ USER = 5,
- /// <summary>
- /// Enum Merchant for value: Merchant
- /// </summary>
- [JsonPropertyName("Merchant")]
- MERCHANT = 6
+ /// <summary>
+ /// Enum Merchant for value: Merchant
+ /// </summary>
+ [JsonPropertyName("Merchant")]
+ MERCHANT = 6
- }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/EStatusEnum.cs b/src/IOL.VippsEcommerce/Models/Api/EStatusEnum.cs
index bf579a4..7a38412 100644
--- a/src/IOL.VippsEcommerce/Models/Api/EStatusEnum.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/EStatusEnum.cs
@@ -1,25 +1,24 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public enum EStatusEnum
{
- public enum EStatusEnum
- {
- /// <summary>
- /// Enum Cancelled for value: Cancelled
- /// </summary>
- [JsonPropertyName("Cancelled")]
- CANCELLED = 1,
+ /// <summary>
+ /// Enum Cancelled for value: Cancelled
+ /// </summary>
+ [JsonPropertyName("Cancelled")]
+ CANCELLED = 1,
- /// <summary>
- /// Enum Captured for value: Captured
- /// </summary>
- [JsonPropertyName("Captured")]
- CAPTURED = 2,
+ /// <summary>
+ /// Enum Captured for value: Captured
+ /// </summary>
+ [JsonPropertyName("Captured")]
+ CAPTURED = 2,
- /// <summary>
- /// Enum Refund for value: Refund
- /// </summary>
- [JsonPropertyName("Refund")]
- REFUND = 3
- }
+ /// <summary>
+ /// Enum Refund for value: Refund
+ /// </summary>
+ [JsonPropertyName("Refund")]
+ REFUND = 3
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/ETransactionStatus.cs b/src/IOL.VippsEcommerce/Models/Api/ETransactionStatus.cs
index 303a4e9..d66bcea 100644
--- a/src/IOL.VippsEcommerce/Models/Api/ETransactionStatus.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/ETransactionStatus.cs
@@ -1,22 +1,21 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public enum ETransactionStatus
{
- public enum ETransactionStatus
- {
- [JsonPropertyName("RESERVED")]
- RESERVED,
- [JsonPropertyName("SALE")]
- SALE,
- [JsonPropertyName("CANCELLED")]
- CANCELLED,
- [JsonPropertyName("REJECTED")]
- REJECTED,
- [JsonPropertyName("AUTO_CANCEL")]
- AUTO_CANCEL,
- [JsonPropertyName("SALE_FAILED")]
- SALE_FAILED,
- [JsonPropertyName("RESERVE_FAILED")]
- RESERVE_FAILED
- }
+ [JsonPropertyName("RESERVED")]
+ RESERVED,
+ [JsonPropertyName("SALE")]
+ SALE,
+ [JsonPropertyName("CANCELLED")]
+ CANCELLED,
+ [JsonPropertyName("REJECTED")]
+ REJECTED,
+ [JsonPropertyName("AUTO_CANCEL")]
+ AUTO_CANCEL,
+ [JsonPropertyName("SALE_FAILED")]
+ SALE_FAILED,
+ [JsonPropertyName("RESERVE_FAILED")]
+ RESERVE_FAILED
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TAdditionalTransactionData.cs b/src/IOL.VippsEcommerce/Models/Api/TAdditionalTransactionData.cs
index 692c7be..8da5bb7 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TAdditionalTransactionData.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TAdditionalTransactionData.cs
@@ -1,42 +1,41 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TAdditionalTransactionData
{
- public class TAdditionalTransactionData
- {
- /// <summary>
- /// Passenger name, initials, and a title.
- /// </summary>
- /// <value>Passenger name, initials, and a title.</value>
- [JsonPropertyName("passengerName")]
- public string PassengerName { get; set; }
+ /// <summary>
+ /// Passenger name, initials, and a title.
+ /// </summary>
+ /// <value>Passenger name, initials, and a title.</value>
+ [JsonPropertyName("passengerName")]
+ public string PassengerName { get; set; }
- /// <summary>
- /// IATA 3-digit accounting code (PAX); numeric. It identifies the carrier. eg KLM &#x3D; 074
- /// </summary>
- /// <value>IATA 3-digit accounting code (PAX); numeric. It identifies the carrier. eg KLM &#x3D; 074</value>
- [JsonPropertyName("airlineCode")]
- public string AirlineCode { get; set; }
+ /// <summary>
+ /// IATA 3-digit accounting code (PAX); numeric. It identifies the carrier. eg KLM &#x3D; 074
+ /// </summary>
+ /// <value>IATA 3-digit accounting code (PAX); numeric. It identifies the carrier. eg KLM &#x3D; 074</value>
+ [JsonPropertyName("airlineCode")]
+ public string AirlineCode { get; set; }
- /// <summary>
- /// IATA 2-letter accounting code (PAX); alphabetical. It identifies the carrier. Eg KLM &#x3D; KL
- /// </summary>
- /// <value>IATA 2-letter accounting code (PAX); alphabetical. It identifies the carrier. Eg KLM &#x3D; KL</value>
- [JsonPropertyName("airlineDesignatorCode")]
- public string AirlineDesignatorCode { get; set; }
+ /// <summary>
+ /// IATA 2-letter accounting code (PAX); alphabetical. It identifies the carrier. Eg KLM &#x3D; KL
+ /// </summary>
+ /// <value>IATA 2-letter accounting code (PAX); alphabetical. It identifies the carrier. Eg KLM &#x3D; KL</value>
+ [JsonPropertyName("airlineDesignatorCode")]
+ public string AirlineDesignatorCode { get; set; }
- /// <summary>
- /// The ticket&#x27;s unique identifier.
- /// </summary>
- /// <value>The ticket&#x27;s unique identifier.</value>
- [JsonPropertyName("ticketNumber")]
- public string TicketNumber { get; set; }
+ /// <summary>
+ /// The ticket&#x27;s unique identifier.
+ /// </summary>
+ /// <value>The ticket&#x27;s unique identifier.</value>
+ [JsonPropertyName("ticketNumber")]
+ public string TicketNumber { get; set; }
- /// <summary>
- /// Reference number for the invoice, issued by the agency.
- /// </summary>
- /// <value>Reference number for the invoice, issued by the agency.</value>
- [JsonPropertyName("agencyInvoiceNumber")]
- public string AgencyInvoiceNumber { get; set; }
- }
+ /// <summary>
+ /// Reference number for the invoice, issued by the agency.
+ /// </summary>
+ /// <value>Reference number for the invoice, issued by the agency.</value>
+ [JsonPropertyName("agencyInvoiceNumber")]
+ public string AgencyInvoiceNumber { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TCustomerInfo.cs b/src/IOL.VippsEcommerce/Models/Api/TCustomerInfo.cs
index a558638..7978a19 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TCustomerInfo.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TCustomerInfo.cs
@@ -1,14 +1,13 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TCustomerInfo
{
- public class TCustomerInfo
- {
- /// <summary>
- /// Mobile number of the user who has to pay for the transation from Vipps. Allowed format: xxxxxxxx. No country code.
- /// </summary>
- /// <value>Mobile number of the user who has to pay for the transation from Vipps. Allowed format: xxxxxxxx. No country code.</value>
- [JsonPropertyName("mobileNumber")]
- public string MobileNumber { get; set; }
- }
+ /// <summary>
+ /// Mobile number of the user who has to pay for the transation from Vipps. Allowed format: xxxxxxxx. No country code.
+ /// </summary>
+ /// <value>Mobile number of the user who has to pay for the transation from Vipps. Allowed format: xxxxxxxx. No country code.</value>
+ [JsonPropertyName("mobileNumber")]
+ public string MobileNumber { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TMerchantInfo.cs b/src/IOL.VippsEcommerce/Models/Api/TMerchantInfo.cs
index 881bc16..20b67b7 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TMerchantInfo.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TMerchantInfo.cs
@@ -1,65 +1,64 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TMerchantInfo
{
- public class TMerchantInfo
- {
- /// <summary>
- /// Authorization token that the merchant could share to make callbacks more secure. If provided this token will be returned as an &#x60;Authorization&#x60; header for our callbacks. This includes shipping details and callback.
- /// </summary>
- /// <value>Authorization token that the merchant could share to make callbacks more secure. If provided this token will be returned as an &#x60;Authorization&#x60; header for our callbacks. This includes shipping details and callback.</value>
- //[JsonPropertyName("authToken")]
- //public string AuthToken { get; set; }
+ /// <summary>
+ /// Authorization token that the merchant could share to make callbacks more secure. If provided this token will be returned as an &#x60;Authorization&#x60; header for our callbacks. This includes shipping details and callback.
+ /// </summary>
+ /// <value>Authorization token that the merchant could share to make callbacks more secure. If provided this token will be returned as an &#x60;Authorization&#x60; header for our callbacks. This includes shipping details and callback.</value>
+ //[JsonPropertyName("authToken")]
+ //public string AuthToken { get; set; }
- /// <summary>
- /// This is an URL for Vipps to call at the merchant&#x27;s server to provide updated information about the order after the payment request. Domain name and context path should be provided by merchant as the value for this parameter. Vipps will add &#x60;/v2/payments/{orderId}&#x60; to the end or this URL. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.
- /// </summary>
- /// <value>This is an URL for Vipps to call at the merchant&#x27;s server to provide updated information about the order after the payment request. Domain name and context path should be provided by merchant as the value for this parameter. Vipps will add &#x60;/v2/payments/{orderId}&#x60; to the end or this URL. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.</value>
- [JsonPropertyName("callbackPrefix")]
- public string CallbackPrefix { get; set; }
+ /// <summary>
+ /// This is an URL for Vipps to call at the merchant&#x27;s server to provide updated information about the order after the payment request. Domain name and context path should be provided by merchant as the value for this parameter. Vipps will add &#x60;/v2/payments/{orderId}&#x60; to the end or this URL. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.
+ /// </summary>
+ /// <value>This is an URL for Vipps to call at the merchant&#x27;s server to provide updated information about the order after the payment request. Domain name and context path should be provided by merchant as the value for this parameter. Vipps will add &#x60;/v2/payments/{orderId}&#x60; to the end or this URL. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.</value>
+ [JsonPropertyName("callbackPrefix")]
+ public string CallbackPrefix { get; set; }
- /// <summary>
- /// Required for Vipps Hurtigkasse (express checkout) payments. This callback URL will be used by Vipps to inform the merchant that the user has revoked his/her consent: This Vipps user does do not want the merchant to store or use his/her personal information anymore. Required by GDPR. Vipps will add &#x60;/v2/consents/{userId}&#x60; to the end or this URL. URLs passed to Vipps should be URL-encoded, and must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.
- /// </summary>
- /// <value>Required for Vipps Hurtigkasse (express checkout) payments. This callback URL will be used by Vipps to inform the merchant that the user has revoked his/her consent: This Vipps user does do not want the merchant to store or use his/her personal information anymore. Required by GDPR. Vipps will add &#x60;/v2/consents/{userId}&#x60; to the end or this URL. URLs passed to Vipps should be URL-encoded, and must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.</value>
- //[JsonPropertyName("consentRemovalPrefix")]
- //public string ConsentRemovalPrefix { get; set; }
+ /// <summary>
+ /// Required for Vipps Hurtigkasse (express checkout) payments. This callback URL will be used by Vipps to inform the merchant that the user has revoked his/her consent: This Vipps user does do not want the merchant to store or use his/her personal information anymore. Required by GDPR. Vipps will add &#x60;/v2/consents/{userId}&#x60; to the end or this URL. URLs passed to Vipps should be URL-encoded, and must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.
+ /// </summary>
+ /// <value>Required for Vipps Hurtigkasse (express checkout) payments. This callback URL will be used by Vipps to inform the merchant that the user has revoked his/her consent: This Vipps user does do not want the merchant to store or use his/her personal information anymore. Required by GDPR. Vipps will add &#x60;/v2/consents/{userId}&#x60; to the end or this URL. URLs passed to Vipps should be URL-encoded, and must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html). We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.</value>
+ //[JsonPropertyName("consentRemovalPrefix")]
+ //public string ConsentRemovalPrefix { get; set; }
- /// <summary>
- /// Vipps will use the fallBack URL to redirect the Vipps user to the merchant’s confirmation page once the payment is completed in Vipps. This is normally the “success page”, although the “fallback” name is ambiguous (the same URL is also used if payment was not successful). In other words: This is the URL Vipps sends the Vipps user back to. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html).
- /// </summary>
- /// <value>Vipps will use the fallBack URL to redirect the Vipps user to the merchant’s confirmation page once the payment is completed in Vipps. This is normally the “success page”, although the “fallback” name is ambiguous (the same URL is also used if payment was not successful). In other words: This is the URL Vipps sends the Vipps user back to. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html).</value>
- [JsonPropertyName("fallBack")]
- public string FallBack { get; set; }
+ /// <summary>
+ /// Vipps will use the fallBack URL to redirect the Vipps user to the merchant’s confirmation page once the payment is completed in Vipps. This is normally the “success page”, although the “fallback” name is ambiguous (the same URL is also used if payment was not successful). In other words: This is the URL Vipps sends the Vipps user back to. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html).
+ /// </summary>
+ /// <value>Vipps will use the fallBack URL to redirect the Vipps user to the merchant’s confirmation page once the payment is completed in Vipps. This is normally the “success page”, although the “fallback” name is ambiguous (the same URL is also used if payment was not successful). In other words: This is the URL Vipps sends the Vipps user back to. URLs passed to Vipps must validate with the Apache Commons [UrlValidator](https://commons.apache.org/proper/commons-validator/apidocs/org/apache/commons/validator/routines/UrlValidator.html).</value>
+ [JsonPropertyName("fallBack")]
+ public string FallBack { get; set; }
- /// <summary>
- /// This parameter indicates whether payment request is triggered from Mobile App or Web browser. Based on this value, response will be redirect URL for Vipps landing page or deeplink URL to connect vipps App. When isApp is set to true, URLs passed to Vipps will not be validated as regular URLs.
- /// </summary>
- /// <value>This parameter indicates whether payment request is triggered from Mobile App or Web browser. Based on this value, response will be redirect URL for Vipps landing page or deeplink URL to connect vipps App. When isApp is set to true, URLs passed to Vipps will not be validated as regular URLs.</value>
- [JsonPropertyName("isApp")]
- public bool? IsApp { get; set; }
+ /// <summary>
+ /// This parameter indicates whether payment request is triggered from Mobile App or Web browser. Based on this value, response will be redirect URL for Vipps landing page or deeplink URL to connect vipps App. When isApp is set to true, URLs passed to Vipps will not be validated as regular URLs.
+ /// </summary>
+ /// <value>This parameter indicates whether payment request is triggered from Mobile App or Web browser. Based on this value, response will be redirect URL for Vipps landing page or deeplink URL to connect vipps App. When isApp is set to true, URLs passed to Vipps will not be validated as regular URLs.</value>
+ [JsonPropertyName("isApp")]
+ public bool? IsApp { get; set; }
- /// <summary>
- /// Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.
- /// </summary>
- /// <value>Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.</value>
- [JsonPropertyName("merchantSerialNumber")]
- public string MerchantSerialNumber { get; set; }
+ /// <summary>
+ /// Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.
+ /// </summary>
+ /// <value>Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.</value>
+ [JsonPropertyName("merchantSerialNumber")]
+ public string MerchantSerialNumber { get; set; }
- /// <summary>
- /// In case of Vipps Hurtigkasse (express checkout) payment, merchant should pass this prefix to let Vipps fetch shipping cost and method related details. Vipps will add &#x60;/v2/payments/{orderId}/shippingDetails&#x60; to the end or this URL. We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.
- /// </summary>
- /// <value>In case of Vipps Hurtigkasse (express checkout) payment, merchant should pass this prefix to let Vipps fetch shipping cost and method related details. Vipps will add &#x60;/v2/payments/{orderId}/shippingDetails&#x60; to the end or this URL. We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.</value>
- [JsonPropertyName("shippingDetailsPrefix")]
- public string ShippingDetailsPrefix { get; set; }
+ /// <summary>
+ /// In case of Vipps Hurtigkasse (express checkout) payment, merchant should pass this prefix to let Vipps fetch shipping cost and method related details. Vipps will add &#x60;/v2/payments/{orderId}/shippingDetails&#x60; to the end or this URL. We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.
+ /// </summary>
+ /// <value>In case of Vipps Hurtigkasse (express checkout) payment, merchant should pass this prefix to let Vipps fetch shipping cost and method related details. Vipps will add &#x60;/v2/payments/{orderId}/shippingDetails&#x60; to the end or this URL. We don&#x27;t send requests to all ports, so to be safe use common ports such as: 80, 443, 8080.</value>
+ [JsonPropertyName("shippingDetailsPrefix")]
+ public string ShippingDetailsPrefix { get; set; }
- /// <summary>
- /// If shipping method and cost are always a fixed value, for example 50 NOK, then the method and price can be provided during the initiate call. The shippingDetailsPrefix callback will not be used if this value is provided. This will result in a faster checkout and a better customer experience.
- /// </summary>
- /// <value>If shipping method and cost are always a fixed value, for example 50 NOK, then the method and price can be provided during the initiate call. The shippingDetailsPrefix callback will not be used if this value is provided. This will result in a faster checkout and a better customer experience.</value>
- [JsonPropertyName("staticShippingDetails")]
- public List<TShippingDetails> StaticShippingDetails { get; set; }
- }
+ /// <summary>
+ /// If shipping method and cost are always a fixed value, for example 50 NOK, then the method and price can be provided during the initiate call. The shippingDetailsPrefix callback will not be used if this value is provided. This will result in a faster checkout and a better customer experience.
+ /// </summary>
+ /// <value>If shipping method and cost are always a fixed value, for example 50 NOK, then the method and price can be provided during the initiate call. The shippingDetailsPrefix callback will not be used if this value is provided. This will result in a faster checkout and a better customer experience.</value>
+ [JsonPropertyName("staticShippingDetails")]
+ public List<TShippingDetails> StaticShippingDetails { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TMerchantInfoPayment.cs b/src/IOL.VippsEcommerce/Models/Api/TMerchantInfoPayment.cs
index ce0cbc3..cb77121 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TMerchantInfoPayment.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TMerchantInfoPayment.cs
@@ -1,15 +1,14 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TMerchantInfoPayment
{
- public class TMerchantInfoPayment
- {
- /// <summary>
- /// Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.
- /// </summary>
- /// <value>Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.</value>
- [JsonPropertyName("merchantSerialNumber")]
- public string MerchantSerialNumber { get; set; }
- }
+ /// <summary>
+ /// Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.
+ /// </summary>
+ /// <value>Unique id for this merchant&#x27;s sales channel: website, mobile app etc. Short name: MSN.</value>
+ [JsonPropertyName("merchantSerialNumber")]
+ public string MerchantSerialNumber { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TShippingDetails.cs b/src/IOL.VippsEcommerce/Models/Api/TShippingDetails.cs
index 72ac7f2..cc3f509 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TShippingDetails.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TShippingDetails.cs
@@ -1,32 +1,31 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TShippingDetails
{
- public class TShippingDetails
- {
- /// <summary>
- /// Gets or Sets Priority
- /// </summary>
- [JsonPropertyName("priority")]
- public int? Priority { get; set; }
+ /// <summary>
+ /// Gets or Sets Priority
+ /// </summary>
+ [JsonPropertyName("priority")]
+ public int? Priority { get; set; }
- /// <summary>
- /// Gets or Sets ShippingCost
- /// </summary>
- [JsonPropertyName("shippingCost")]
- public double? ShippingCost { get; set; }
+ /// <summary>
+ /// Gets or Sets ShippingCost
+ /// </summary>
+ [JsonPropertyName("shippingCost")]
+ public double? ShippingCost { get; set; }
- /// <summary>
- /// Shipping method. Max length: 256 characters. Recommended length for readability on most screens: 25 characters.
- /// </summary>
- /// <value>Shipping method. Max length: 256 characters. Recommended length for readability on most screens: 25 characters.</value>
- [JsonPropertyName("shippingMethod")]
- public string ShippingMethod { get; set; }
+ /// <summary>
+ /// Shipping method. Max length: 256 characters. Recommended length for readability on most screens: 25 characters.
+ /// </summary>
+ /// <value>Shipping method. Max length: 256 characters. Recommended length for readability on most screens: 25 characters.</value>
+ [JsonPropertyName("shippingMethod")]
+ public string ShippingMethod { get; set; }
- /// <summary>
- /// Gets or Sets ShippingMethodId
- /// </summary>
- [JsonPropertyName("shippingMethodId")]
- public string ShippingMethodId { get; set; }
- }
+ /// <summary>
+ /// Gets or Sets ShippingMethodId
+ /// </summary>
+ [JsonPropertyName("shippingMethodId")]
+ public string ShippingMethodId { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TTransaction.cs b/src/IOL.VippsEcommerce/Models/Api/TTransaction.cs
index 9e09758..ec56231 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TTransaction.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TTransaction.cs
@@ -1,21 +1,20 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TTransaction
{
- public class TTransaction
- {
- /// <summary>
- /// Amount in øre, if amount is 0 or not provided then full capture will be performed. 32 Bit Integer (2147483647)
- /// </summary>
- /// <value>Amount in øre, if amount is 0 or not provided then full capture will be performed. 32 Bit Integer (2147483647)</value>
- [JsonPropertyName("amount")]
- public int? Amount { get; set; }
+ /// <summary>
+ /// Amount in øre, if amount is 0 or not provided then full capture will be performed. 32 Bit Integer (2147483647)
+ /// </summary>
+ /// <value>Amount in øre, if amount is 0 or not provided then full capture will be performed. 32 Bit Integer (2147483647)</value>
+ [JsonPropertyName("amount")]
+ public int? Amount { get; set; }
- /// <summary>
- /// Transaction text to be displayed in Vipps
- /// </summary>
- /// <value>Transaction text to be displayed in Vipps</value>
- [JsonPropertyName("transactionText")]
- public string TransactionText { get; set; }
- }
+ /// <summary>
+ /// Transaction text to be displayed in Vipps
+ /// </summary>
+ /// <value>Transaction text to be displayed in Vipps</value>
+ [JsonPropertyName("transactionText")]
+ public string TransactionText { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TTransactionInfo.cs b/src/IOL.VippsEcommerce/Models/Api/TTransactionInfo.cs
index 30e62f9..9374fe3 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TTransactionInfo.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TTransactionInfo.cs
@@ -1,15 +1,14 @@
using System.Text.Json.Serialization;
using IOL.VippsEcommerce.Models.Api;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TTransactionInfo
{
- public class TTransactionInfo
- {
- /// <summary>
- /// Status which gives the current state of the payment within Vipps. See the [API guide](https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#responses-from-requests) for more information.
- /// </summary>
- /// <value>Status which gives the current state of the payment within Vipps. See the [API guide](https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#responses-from-requests) for more information.</value>
- [JsonPropertyName("status")]
- public EStatusEnum Status { get; set; }
- }
+ /// <summary>
+ /// Status which gives the current state of the payment within Vipps. See the [API guide](https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#responses-from-requests) for more information.
+ /// </summary>
+ /// <value>Status which gives the current state of the payment within Vipps. See the [API guide](https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#responses-from-requests) for more information.</value>
+ [JsonPropertyName("status")]
+ public EStatusEnum Status { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TTransactionInfoInitiate.cs b/src/IOL.VippsEcommerce/Models/Api/TTransactionInfoInitiate.cs
index 7ad989b..dc08630 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TTransactionInfoInitiate.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TTransactionInfoInitiate.cs
@@ -1,57 +1,56 @@
using System;
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TTransactionInfoInitiate
{
- public class TTransactionInfoInitiate
- {
- /// <summary>
- /// Amount in øre. 32 bit Integer (2147483647). Must be non-zero.
- /// </summary>
- /// <value>Amount in øre. 32 bit Integer (2147483647). Must be non-zero.</value>
- [JsonPropertyName("amount")]
- public int? Amount { get; set; }
+ /// <summary>
+ /// Amount in øre. 32 bit Integer (2147483647). Must be non-zero.
+ /// </summary>
+ /// <value>Amount in øre. 32 bit Integer (2147483647). Must be non-zero.</value>
+ [JsonPropertyName("amount")]
+ public int? Amount { get; set; }
- /// <summary>
- /// Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.
- /// </summary>
- /// <value>Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.</value>
- [JsonPropertyName("orderId")]
- public string OrderId { get; set; }
+ /// <summary>
+ /// Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.
+ /// </summary>
+ /// <value>Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.</value>
+ [JsonPropertyName("orderId")]
+ public string OrderId { get; set; }
- /// <summary>
- /// ISO formatted date time string.
- /// </summary>
- /// <value>ISO formatted date time string.</value>
- [JsonPropertyName("timeStamp")]
- public string TimeStamp { get; set; }
+ /// <summary>
+ /// ISO formatted date time string.
+ /// </summary>
+ /// <value>ISO formatted date time string.</value>
+ [JsonPropertyName("timeStamp")]
+ public string TimeStamp { get; set; }
- /// <summary>
- /// Transaction text to be displayed in Vipps
- /// </summary>
- /// <value>Transaction text to be displayed in Vipps</value>
- [JsonPropertyName("transactionText")]
- public string TransactionText { get; set; }
+ /// <summary>
+ /// Transaction text to be displayed in Vipps
+ /// </summary>
+ /// <value>Transaction text to be displayed in Vipps</value>
+ [JsonPropertyName("transactionText")]
+ public string TransactionText { get; set; }
- /// <summary>
- /// Skips the landing page for whitelisted sale units. Requires a valid customerInfo.mobileNumber.
- /// </summary>
- /// <value>Skips the landing page for whitelisted sale units. Requires a valid customerInfo.mobileNumber.</value>
- [JsonPropertyName("skipLandingPage")]
- public bool? SkipLandingPage { get; set; }
+ /// <summary>
+ /// Skips the landing page for whitelisted sale units. Requires a valid customerInfo.mobileNumber.
+ /// </summary>
+ /// <value>Skips the landing page for whitelisted sale units. Requires a valid customerInfo.mobileNumber.</value>
+ [JsonPropertyName("skipLandingPage")]
+ public bool? SkipLandingPage { get; set; }
- /// <summary>
- /// Gets or Sets AdditionalData
- /// </summary>
- [JsonPropertyName("additionalData")]
- public TAdditionalTransactionData AdditionalData { get; set; }
+ /// <summary>
+ /// Gets or Sets AdditionalData
+ /// </summary>
+ [JsonPropertyName("additionalData")]
+ public TAdditionalTransactionData AdditionalData { get; set; }
- /// <summary>
- /// Use the extended UX flow for express checkout which forces users to confirm their address and shipping choices
- /// </summary>
- /// <value>Use the extended UX flow for express checkout which forces users to confirm their address and shipping choices</value>
- [JsonPropertyName("useExplicitCheckoutFlow")]
- public bool? UseExplicitCheckoutFlow { get; set; }
- }
+ /// <summary>
+ /// Use the extended UX flow for express checkout which forces users to confirm their address and shipping choices
+ /// </summary>
+ /// <value>Use the extended UX flow for express checkout which forces users to confirm their address and shipping choices</value>
+ [JsonPropertyName("useExplicitCheckoutFlow")]
+ public bool? UseExplicitCheckoutFlow { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/TTransactionSummary.cs b/src/IOL.VippsEcommerce/Models/Api/TTransactionSummary.cs
index 786bcaa..479c0dc 100644
--- a/src/IOL.VippsEcommerce/Models/Api/TTransactionSummary.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/TTransactionSummary.cs
@@ -1,42 +1,41 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class TTransactionSummary
{
- public class TTransactionSummary
- {
- /// <summary>
- /// Total amount captured
- /// </summary>
- /// <value>Total amount captured</value>
- [JsonPropertyName("capturedAmount")]
- public int? CapturedAmount { get; set; }
+ /// <summary>
+ /// Total amount captured
+ /// </summary>
+ /// <value>Total amount captured</value>
+ [JsonPropertyName("capturedAmount")]
+ public int? CapturedAmount { get; set; }
- /// <summary>
- /// Total refunded amount of the order
- /// </summary>
- /// <value>Total refunded amount of the order</value>
- [JsonPropertyName("refundedAmount")]
- public int? RefundedAmount { get; set; }
+ /// <summary>
+ /// Total refunded amount of the order
+ /// </summary>
+ /// <value>Total refunded amount of the order</value>
+ [JsonPropertyName("refundedAmount")]
+ public int? RefundedAmount { get; set; }
- /// <summary>
- /// Total remaining amount to capture
- /// </summary>
- /// <value>Total remaining amount to capture</value>
- [JsonPropertyName("remainingAmountToCapture")]
- public int? RemainingAmountToCapture { get; set; }
+ /// <summary>
+ /// Total remaining amount to capture
+ /// </summary>
+ /// <value>Total remaining amount to capture</value>
+ [JsonPropertyName("remainingAmountToCapture")]
+ public int? RemainingAmountToCapture { get; set; }
- /// <summary>
- /// Total remaining amount to refund
- /// </summary>
- /// <value>Total remaining amount to refund</value>
- [JsonPropertyName("remainingAmountToRefund")]
- public int? RemainingAmountToRefund { get; set; }
+ /// <summary>
+ /// Total remaining amount to refund
+ /// </summary>
+ /// <value>Total remaining amount to refund</value>
+ [JsonPropertyName("remainingAmountToRefund")]
+ public int? RemainingAmountToRefund { get; set; }
- /// <summary>
- /// Bank Identification Number, first 6 digit of card number
- /// </summary>
- /// <value>Bank Identification Number, first 6 digit of card number</value>
- [JsonPropertyName("bankIdentificationNumber")]
- public string BankIdentificationNumber { get; set; }
- }
+ /// <summary>
+ /// Bank Identification Number, first 6 digit of card number
+ /// </summary>
+ /// <value>Bank Identification Number, first 6 digit of card number</value>
+ [JsonPropertyName("bankIdentificationNumber")]
+ public string BankIdentificationNumber { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsAuthorizationTokenResponse.cs b/src/IOL.VippsEcommerce/Models/Api/VippsAuthorizationTokenResponse.cs
index b870ddb..44ab083 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsAuthorizationTokenResponse.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsAuthorizationTokenResponse.cs
@@ -1,58 +1,57 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+/// <summary>
+/// AuthorizationTokenResponse
+/// </summary>
+public class VippsAuthorizationTokenResponse
{
- /// <summary>
- /// AuthorizationTokenResponse
- /// </summary>
- public class VippsAuthorizationTokenResponse
- {
- /// <summary>
- /// String containing the type for the Access Token.
- /// </summary>
- /// <value>String containing the type for the Access Token.</value>
- [JsonPropertyName("token_type")]
- public string TokenType { get; set; }
+ /// <summary>
+ /// String containing the type for the Access Token.
+ /// </summary>
+ /// <value>String containing the type for the Access Token.</value>
+ [JsonPropertyName("token_type")]
+ public string TokenType { get; set; }
- /// <summary>
- /// Token expiry time in seconds.
- /// </summary>
- /// <value>Token expiry time in seconds.</value>
- [JsonPropertyName("expires_in")]
- public string ExpiresIn { get; set; }
+ /// <summary>
+ /// Token expiry time in seconds.
+ /// </summary>
+ /// <value>Token expiry time in seconds.</value>
+ [JsonPropertyName("expires_in")]
+ public string ExpiresIn { get; set; }
- /// <summary>
- /// Extra time added to expiry time. Currently disabled.
- /// </summary>
- /// <value>Extra time added to expiry time. Currently disabled.</value>
- [JsonPropertyName("ext_expires_in")]
- public string ExtExpiresIn { get; set; }
+ /// <summary>
+ /// Extra time added to expiry time. Currently disabled.
+ /// </summary>
+ /// <value>Extra time added to expiry time. Currently disabled.</value>
+ [JsonPropertyName("ext_expires_in")]
+ public string ExtExpiresIn { get; set; }
- /// <summary>
- /// Token expiry time in epoch time format.
- /// </summary>
- /// <value>Token expiry time in epoch time format.</value>
- [JsonPropertyName("expires_on")]
- public string ExpiresOn { get; set; }
+ /// <summary>
+ /// Token expiry time in epoch time format.
+ /// </summary>
+ /// <value>Token expiry time in epoch time format.</value>
+ [JsonPropertyName("expires_on")]
+ public string ExpiresOn { get; set; }
- /// <summary>
- /// Token creation time in epoch time format.
- /// </summary>
- /// <value>Token creation time in epoch time format.</value>
- [JsonPropertyName("not_before")]
- public string NotBefore { get; set; }
+ /// <summary>
+ /// Token creation time in epoch time format.
+ /// </summary>
+ /// <value>Token creation time in epoch time format.</value>
+ [JsonPropertyName("not_before")]
+ public string NotBefore { get; set; }
- /// <summary>
- /// A common resource object. Not used in token validation
- /// </summary>
- /// <value>A common resource object. Not used in token validation</value>
- [JsonPropertyName("resource")]
- public string Resource { get; set; }
+ /// <summary>
+ /// A common resource object. Not used in token validation
+ /// </summary>
+ /// <value>A common resource object. Not used in token validation</value>
+ [JsonPropertyName("resource")]
+ public string Resource { get; set; }
- /// <summary>
- /// Gets or Sets AccessToken
- /// </summary>
- [JsonPropertyName("access_token")]
- public string AccessToken { get; set; }
- }
+ /// <summary>
+ /// Gets or Sets AccessToken
+ /// </summary>
+ [JsonPropertyName("access_token")]
+ public string AccessToken { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsErrorResponse.cs b/src/IOL.VippsEcommerce/Models/Api/VippsErrorResponse.cs
index 6471913..62753b8 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsErrorResponse.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsErrorResponse.cs
@@ -1,39 +1,38 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+/// <summary>
+/// VippsErrorResponse
+/// </summary>
+public class VippsErrorResponse
{
/// <summary>
- /// VippsErrorResponse
+ /// The error group. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-groups
/// </summary>
- public class VippsErrorResponse
- {
- /// <summary>
- /// The error group. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-groups
- /// </summary>
- /// <value>The error group. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-groups</value>
- [JsonPropertyName("errorGroup")]
- public EErrorGroupEnum ErrorGroup { get; }
+ /// <value>The error group. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-groups</value>
+ [JsonPropertyName("errorGroup")]
+ public EErrorGroupEnum ErrorGroup { get; }
- /// <summary>
- /// The error code. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-codes
- /// </summary>
- /// <value>The error code. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-codes</value>
- [JsonPropertyName("errorCode")]
- public string ErrorCode { get; }
+ /// <summary>
+ /// The error code. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-codes
+ /// </summary>
+ /// <value>The error code. See: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#error-codes</value>
+ [JsonPropertyName("errorCode")]
+ public string ErrorCode { get; }
- /// <summary>
- /// A description of what went wrong. See https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#errors
- /// </summary>
- /// <value>A description of what went wrong. See https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#errors</value>
- [JsonPropertyName("errorMessage")]
- public string ErrorMessage { get; }
+ /// <summary>
+ /// A description of what went wrong. See https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#errors
+ /// </summary>
+ /// <value>A description of what went wrong. See https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#errors</value>
+ [JsonPropertyName("errorMessage")]
+ public string ErrorMessage { get; }
- /// <summary>
- /// A unique id for this error, useful for searching in logs
- /// </summary>
- /// <value>A unique id for this error, useful for searching in logs</value>
- [JsonPropertyName("contextId")]
- public string ContextId { get; }
- }
+ /// <summary>
+ /// A unique id for this error, useful for searching in logs
+ /// </summary>
+ /// <value>A unique id for this error, useful for searching in logs</value>
+ [JsonPropertyName("contextId")]
+ public string ContextId { get; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsForceApproveRequest.cs b/src/IOL.VippsEcommerce/Models/Api/VippsForceApproveRequest.cs
index 6a539c2..2437427 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsForceApproveRequest.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsForceApproveRequest.cs
@@ -1,21 +1,20 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsForceApproveRequest
{
- public class VippsForceApproveRequest
- {
- /// <summary>
- /// Target customer phone number. 8 digits.
- /// </summary>
- /// <value>Target customer phone number. 8 digits.</value>
- [JsonPropertyName("customerPhoneNumber")]
- public string CustomerPhoneNumber { get; set; }
+ /// <summary>
+ /// Target customer phone number. 8 digits.
+ /// </summary>
+ /// <value>Target customer phone number. 8 digits.</value>
+ [JsonPropertyName("customerPhoneNumber")]
+ public string CustomerPhoneNumber { get; set; }
- /// <summary>
- /// The token value recieved in the &#x60;url&#x60; property in the Initiate response
- /// </summary>
- /// <value>The token value recieved in the &#x60;url&#x60; property in the Initiate response</value>
- [JsonPropertyName("token")]
- public string Token { get; set; }
- }
+ /// <summary>
+ /// The token value recieved in the &#x60;url&#x60; property in the Initiate response
+ /// </summary>
+ /// <value>The token value recieved in the &#x60;url&#x60; property in the Initiate response</value>
+ [JsonPropertyName("token")]
+ public string Token { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsGetPaymentDetailsResponse.cs b/src/IOL.VippsEcommerce/Models/Api/VippsGetPaymentDetailsResponse.cs
index 844ac88..fe2849c 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsGetPaymentDetailsResponse.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsGetPaymentDetailsResponse.cs
@@ -1,125 +1,124 @@
using System;
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsGetPaymentDetailsResponse
{
- public class VippsGetPaymentDetailsResponse
- {
- [JsonPropertyName("orderId")]
- public string OrderId { get; set; }
+ [JsonPropertyName("orderId")]
+ public string OrderId { get; set; }
- [JsonPropertyName("shippingDetails")]
- public ShippingDetails ShippingDetails { get; set; }
+ [JsonPropertyName("shippingDetails")]
+ public ShippingDetails ShippingDetails { get; set; }
- [JsonPropertyName("transactionLogHistory")]
- public TransactionLogHistory[] TransactionLogHistory { get; set; }
+ [JsonPropertyName("transactionLogHistory")]
+ public TransactionLogHistory[] TransactionLogHistory { get; set; }
- [JsonPropertyName("transactionSummary")]
- public TransactionSummary TransactionSummary { get; set; }
+ [JsonPropertyName("transactionSummary")]
+ public TransactionSummary TransactionSummary { get; set; }
- [JsonPropertyName("userDetails")]
- public UserDetails UserDetails { get; set; }
- }
+ [JsonPropertyName("userDetails")]
+ public UserDetails UserDetails { get; set; }
+}
- public class ShippingDetails
- {
- [JsonPropertyName("address")]
- public Address Address { get; set; }
+public class ShippingDetails
+{
+ [JsonPropertyName("address")]
+ public Address Address { get; set; }
- [JsonPropertyName("shippingCost")]
- public long ShippingCost { get; set; }
+ [JsonPropertyName("shippingCost")]
+ public long ShippingCost { get; set; }
- [JsonPropertyName("shippingMethod")]
- public string ShippingMethod { get; set; }
+ [JsonPropertyName("shippingMethod")]
+ public string ShippingMethod { get; set; }
- [JsonPropertyName("shippingMethodId")]
- public string ShippingMethodId { get; set; }
- }
+ [JsonPropertyName("shippingMethodId")]
+ public string ShippingMethodId { get; set; }
+}
- public class Address
- {
- [JsonPropertyName("addressLine1")]
- public string AddressLine1 { get; set; }
+public class Address
+{
+ [JsonPropertyName("addressLine1")]
+ public string AddressLine1 { get; set; }
- [JsonPropertyName("addressLine2")]
- public string AddressLine2 { get; set; }
+ [JsonPropertyName("addressLine2")]
+ public string AddressLine2 { get; set; }
- [JsonPropertyName("city")]
- public string City { get; set; }
+ [JsonPropertyName("city")]
+ public string City { get; set; }
- [JsonPropertyName("country")]
- public string Country { get; set; }
+ [JsonPropertyName("country")]
+ public string Country { get; set; }
- [JsonPropertyName("postCode")]
- public string PostCode { get; set; }
- }
+ [JsonPropertyName("postCode")]
+ public string PostCode { get; set; }
+}
- public class TransactionLogHistory
- {
- [JsonPropertyName("amount")]
- public long Amount { get; set; }
+public class TransactionLogHistory
+{
+ [JsonPropertyName("amount")]
+ public long Amount { get; set; }
- [JsonPropertyName("operation")]
- public string Operation { get; set; }
+ [JsonPropertyName("operation")]
+ public string Operation { get; set; }
- [JsonPropertyName("operationSuccess")]
- public bool OperationSuccess { get; set; }
+ [JsonPropertyName("operationSuccess")]
+ public bool OperationSuccess { get; set; }
- [JsonPropertyName("requestId")]
- public string RequestId { get; set; }
+ [JsonPropertyName("requestId")]
+ public string RequestId { get; set; }
- [JsonPropertyName("timeStamp")]
- public DateTime TimeStamp { get; set; }
+ [JsonPropertyName("timeStamp")]
+ public DateTime TimeStamp { get; set; }
- [JsonPropertyName("transactionId")]
- public string TransactionId { get; set; }
+ [JsonPropertyName("transactionId")]
+ public string TransactionId { get; set; }
- [JsonPropertyName("transactionText")]
- public string TransactionText { get; set; }
- }
+ [JsonPropertyName("transactionText")]
+ public string TransactionText { get; set; }
+}
- public class TransactionSummary
- {
- [JsonPropertyName("capturedAmount")]
- public long CapturedAmount { get; set; }
+public class TransactionSummary
+{
+ [JsonPropertyName("capturedAmount")]
+ public long CapturedAmount { get; set; }
- [JsonPropertyName("refundedAmount")]
- public long RefundedAmount { get; set; }
+ [JsonPropertyName("refundedAmount")]
+ public long RefundedAmount { get; set; }
- [JsonPropertyName("remainingAmountToCapture")]
- public long RemainingAmountToCapture { get; set; }
+ [JsonPropertyName("remainingAmountToCapture")]
+ public long RemainingAmountToCapture { get; set; }
- [JsonPropertyName("remainingAmountToRefund")]
- public long RemainingAmountToRefund { get; set; }
+ [JsonPropertyName("remainingAmountToRefund")]
+ public long RemainingAmountToRefund { get; set; }
- [JsonPropertyName("bankIdentificationNumber")]
- public long BankIdentificationNumber { get; set; }
- }
+ [JsonPropertyName("bankIdentificationNumber")]
+ public long BankIdentificationNumber { get; set; }
+}
- public class UserDetails
- {
- [JsonPropertyName("bankIdVerified")]
- public string BankIdVerified { get; set; }
+public class UserDetails
+{
+ [JsonPropertyName("bankIdVerified")]
+ public string BankIdVerified { get; set; }
- [JsonPropertyName("dateOfBirth")]
- public string DateOfBirth { get; set; }
+ [JsonPropertyName("dateOfBirth")]
+ public string DateOfBirth { get; set; }
- [JsonPropertyName("email")]
- public string Email { get; set; }
+ [JsonPropertyName("email")]
+ public string Email { get; set; }
- [JsonPropertyName("firstName")]
- public string FirstName { get; set; }
+ [JsonPropertyName("firstName")]
+ public string FirstName { get; set; }
- [JsonPropertyName("lastName")]
- public string LastName { get; set; }
+ [JsonPropertyName("lastName")]
+ public string LastName { get; set; }
- [JsonPropertyName("mobileNumber")]
- public long MobileNumber { get; set; }
+ [JsonPropertyName("mobileNumber")]
+ public long MobileNumber { get; set; }
- [JsonPropertyName("ssn")]
- public string Ssn { get; set; }
+ [JsonPropertyName("ssn")]
+ public string Ssn { get; set; }
- [JsonPropertyName("userId")]
- public string UserId { get; set; }
- }
+ [JsonPropertyName("userId")]
+ public string UserId { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentRequest.cs b/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentRequest.cs
index 2e8a040..1763e4d 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentRequest.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentRequest.cs
@@ -1,27 +1,26 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsInitiatePaymentRequest
{
- public class VippsInitiatePaymentRequest
- {
- /// <summary>
- /// Gets or Sets CustomerInfo
- /// </summary>
- [JsonPropertyName("customerInfo")]
- public TCustomerInfo CustomerInfo { get; set; }
+ /// <summary>
+ /// Gets or Sets CustomerInfo
+ /// </summary>
+ [JsonPropertyName("customerInfo")]
+ public TCustomerInfo CustomerInfo { get; set; }
- /// <summary>
- /// Gets or Sets MerchantInfo
- /// </summary>
- ///
- [JsonPropertyName("merchantInfo")]
- public TMerchantInfo MerchantInfo { get; set; }
+ /// <summary>
+ /// Gets or Sets MerchantInfo
+ /// </summary>
+ ///
+ [JsonPropertyName("merchantInfo")]
+ public TMerchantInfo MerchantInfo { get; set; }
- /// <summary>
- /// Gets or Sets Transaction
- /// </summary>
- [JsonPropertyName("transaction")]
- public TTransactionInfoInitiate Transaction { get; set; }
+ /// <summary>
+ /// Gets or Sets Transaction
+ /// </summary>
+ [JsonPropertyName("transaction")]
+ public TTransactionInfoInitiate Transaction { get; set; }
- }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentResponse.cs b/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentResponse.cs
index 471133a..93f7f3f 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentResponse.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsInitiatePaymentResponse.cs
@@ -1,21 +1,20 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsInitiatePaymentResponse
{
- public class VippsInitiatePaymentResponse
- {
- /// <summary>
- /// Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.
- /// </summary>
- /// <value>Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.</value>
- [JsonPropertyName("orderId")]
- public string OrderId { get; set; }
+ /// <summary>
+ /// Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.
+ /// </summary>
+ /// <value>Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.</value>
+ [JsonPropertyName("orderId")]
+ public string OrderId { get; set; }
- /// <summary>
- /// URL to redirect the user to Vipps landing page or a deeplink URL to open Vipps app, if &#x60;isApp&#x60; was set as true. The landing page will also redirect a user to the app if the user is using a mobile browser. This link will timeout after 5 minutes. This example is a shortened deeplink URL. The URL received fromn Vipps should not be changed, and the format may change without notice.
- /// </summary>
- /// <value>URL to redirect the user to Vipps landing page or a deeplink URL to open Vipps app, if &#x60;isApp&#x60; was set as true. The landing page will also redirect a user to the app if the user is using a mobile browser. This link will timeout after 5 minutes. This example is a shortened deeplink URL. The URL received fromn Vipps should not be changed, and the format may change without notice.</value>
- [JsonPropertyName("url")]
- public string Url { get; set; }
- }
+ /// <summary>
+ /// URL to redirect the user to Vipps landing page or a deeplink URL to open Vipps app, if &#x60;isApp&#x60; was set as true. The landing page will also redirect a user to the app if the user is using a mobile browser. This link will timeout after 5 minutes. This example is a shortened deeplink URL. The URL received fromn Vipps should not be changed, and the format may change without notice.
+ /// </summary>
+ /// <value>URL to redirect the user to Vipps landing page or a deeplink URL to open Vipps app, if &#x60;isApp&#x60; was set as true. The landing page will also redirect a user to the app if the user is using a mobile browser. This link will timeout after 5 minutes. This example is a shortened deeplink URL. The URL received fromn Vipps should not be changed, and the format may change without notice.</value>
+ [JsonPropertyName("url")]
+ public string Url { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionRequest.cs b/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionRequest.cs
index f336bce..303bd67 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionRequest.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionRequest.cs
@@ -1,19 +1,18 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsPaymentActionRequest
{
- public class VippsPaymentActionRequest
- {
- /// <summary>
- /// Gets or Sets MerchantInfo
- /// </summary>
- [JsonPropertyName("merchantInfo")]
- public TMerchantInfoPayment MerchantInfo { get; set; }
+ /// <summary>
+ /// Gets or Sets MerchantInfo
+ /// </summary>
+ [JsonPropertyName("merchantInfo")]
+ public TMerchantInfoPayment MerchantInfo { get; set; }
- /// <summary>
- /// Gets or Sets Transaction
- /// </summary>
- [JsonPropertyName("transaction")]
- public TTransaction Transaction { get; set; }
- }
+ /// <summary>
+ /// Gets or Sets Transaction
+ /// </summary>
+ [JsonPropertyName("transaction")]
+ public TTransaction Transaction { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionResponse.cs b/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionResponse.cs
index 90b4389..7f4f6f7 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionResponse.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsPaymentActionResponse.cs
@@ -1,34 +1,33 @@
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsPaymentActionResponse
{
- public class VippsPaymentActionResponse
- {
- /// <summary>
- /// Text which describes what instrument was used to complete the payment. Not included until a user has chosen and approved in the app.
- /// </summary>
- /// <value>Text which describes what instrument was used to complete the payment. Not included until a user has chosen and approved in the app.</value>
- [JsonPropertyName("paymentInstrument")]
- public string PaymentInstrument { get; set; }
+ /// <summary>
+ /// Text which describes what instrument was used to complete the payment. Not included until a user has chosen and approved in the app.
+ /// </summary>
+ /// <value>Text which describes what instrument was used to complete the payment. Not included until a user has chosen and approved in the app.</value>
+ [JsonPropertyName("paymentInstrument")]
+ public string PaymentInstrument { get; set; }
- /// <summary>
- /// Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.
- /// </summary>
- /// <value>Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.</value>
- [JsonPropertyName("orderId")]
- public string OrderId { get; set; }
+ /// <summary>
+ /// Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.
+ /// </summary>
+ /// <value>Id which uniquely identifies a payment. Maximum length is 50 alphanumeric characters: a-z, A-Z, 0-9 and &#x27;-&#x27;.</value>
+ [JsonPropertyName("orderId")]
+ public string OrderId { get; set; }
- /// <summary>
- /// Gets or Sets TransactionInfo
- /// </summary>
- [JsonPropertyName("transactionInfo")]
- public TTransactionInfo TransactionInfo { get; set; }
+ /// <summary>
+ /// Gets or Sets TransactionInfo
+ /// </summary>
+ [JsonPropertyName("transactionInfo")]
+ public TTransactionInfo TransactionInfo { get; set; }
- /// <summary>
- /// Gets or Sets TransactionSummary
- /// </summary>
- [JsonPropertyName("transactionSummary")]
- public TTransactionSummary TransactionSummary { get; set; }
+ /// <summary>
+ /// Gets or Sets TransactionSummary
+ /// </summary>
+ [JsonPropertyName("transactionSummary")]
+ public TTransactionSummary TransactionSummary { get; set; }
- }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsPaymentInitiationCallbackResponse.cs b/src/IOL.VippsEcommerce/Models/Api/VippsPaymentInitiationCallbackResponse.cs
index 3b02536..749dd66 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsPaymentInitiationCallbackResponse.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsPaymentInitiationCallbackResponse.cs
@@ -1,119 +1,118 @@
using System;
using System.Text.Json.Serialization;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+public class VippsPaymentInitiationCallbackResponse
{
- public class VippsPaymentInitiationCallbackResponse
- {
- [JsonPropertyName("merchantSerialNumber")]
- public string MerchantSerialNumber { get; set; }
+ [JsonPropertyName("merchantSerialNumber")]
+ public string MerchantSerialNumber { get; set; }
- [JsonPropertyName("orderId")]
- public string OrderId { get; set; }
+ [JsonPropertyName("orderId")]
+ public string OrderId { get; set; }
- // [JsonPropertyName("shippingDetails")]
- // public TShippingDetails? ShippingDetails { get; set; }
+ // [JsonPropertyName("shippingDetails")]
+ // public TShippingDetails? ShippingDetails { get; set; }
- [JsonPropertyName("transactionInfo")]
- public TTransactionInfo TransactionInfo { get; set; }
+ [JsonPropertyName("transactionInfo")]
+ public TTransactionInfo TransactionInfo { get; set; }
- // [JsonPropertyName("userDetails")]
- // public UserDetails? UserDetails { get; set; }
- //
- // [JsonPropertyName("errorInfo")]
- // public TErrorInfo? ErrorInfo { get; set; }
+ // [JsonPropertyName("userDetails")]
+ // public UserDetails? UserDetails { get; set; }
+ //
+ // [JsonPropertyName("errorInfo")]
+ // public TErrorInfo? ErrorInfo { get; set; }
- public class TErrorInfo
- {
- [JsonPropertyName("errorGroup")]
- public string ErrorGroup { get; set; }
+ public class TErrorInfo
+ {
+ [JsonPropertyName("errorGroup")]
+ public string ErrorGroup { get; set; }
- [JsonPropertyName("errorCode")]
- public string ErrorCode { get; set; }
+ [JsonPropertyName("errorCode")]
+ public string ErrorCode { get; set; }
- [JsonPropertyName("errorMessage")]
- public string ErrorMessage { get; set; }
+ [JsonPropertyName("errorMessage")]
+ public string ErrorMessage { get; set; }
- [JsonPropertyName("contextId")]
- public Guid ContextId { get; set; }
- }
+ [JsonPropertyName("contextId")]
+ public Guid ContextId { get; set; }
+ }
- public class TShippingDetails
- {
- [JsonPropertyName("address")]
- public TAddress Address { get; set; }
+ public class TShippingDetails
+ {
+ [JsonPropertyName("address")]
+ public TAddress Address { get; set; }
- [JsonPropertyName("shippingCost")]
- public int ShippingCost { get; set; }
+ [JsonPropertyName("shippingCost")]
+ public int ShippingCost { get; set; }
- [JsonPropertyName("shippingMethod")]
- public string ShippingMethod { get; set; }
+ [JsonPropertyName("shippingMethod")]
+ public string ShippingMethod { get; set; }
- [JsonPropertyName("shippingMethodId")]
- public string ShippingMethodId { get; set; }
- }
+ [JsonPropertyName("shippingMethodId")]
+ public string ShippingMethodId { get; set; }
+ }
- public class TAddress
- {
- [JsonPropertyName("addressLine1")]
- public string AddressLine1 { get; set; }
+ public class TAddress
+ {
+ [JsonPropertyName("addressLine1")]
+ public string AddressLine1 { get; set; }
- [JsonPropertyName("addressLine2")]
- public string AddressLine2 { get; set; }
+ [JsonPropertyName("addressLine2")]
+ public string AddressLine2 { get; set; }
- [JsonPropertyName("city")]
- public string City { get; set; }
+ [JsonPropertyName("city")]
+ public string City { get; set; }
- [JsonPropertyName("country")]
- public string Country { get; set; }
+ [JsonPropertyName("country")]
+ public string Country { get; set; }
- [JsonPropertyName("zipCode")]
- public string ZipCode { get; set; }
- }
+ [JsonPropertyName("zipCode")]
+ public string ZipCode { get; set; }
+ }
- public class TTransactionInfo
- {
- [JsonPropertyName("amount")]
- public int Amount { get; set; }
+ public class TTransactionInfo
+ {
+ [JsonPropertyName("amount")]
+ public int Amount { get; set; }
- [JsonPropertyName("status")]
- public string Status { get; set; }
+ [JsonPropertyName("status")]
+ public string Status { get; set; }
- public ETransactionStatus StatusEnum() => Enum.Parse<ETransactionStatus>(Status);
+ public ETransactionStatus StatusEnum() => Enum.Parse<ETransactionStatus>(Status);
- [JsonPropertyName("timeStamp")]
- public DateTime TimeStamp { get; set; }
+ [JsonPropertyName("timeStamp")]
+ public DateTime TimeStamp { get; set; }
- [JsonPropertyName("transactionId")]
- public string TransactionId { get; set; }
- }
+ [JsonPropertyName("transactionId")]
+ public string TransactionId { get; set; }
+ }
- public class TUserDetails
- {
- [JsonPropertyName("bankIdVerified")]
- public string BankIdVerified { get; set; }
+ public class TUserDetails
+ {
+ [JsonPropertyName("bankIdVerified")]
+ public string BankIdVerified { get; set; }
- [JsonPropertyName("dateOfBirth")]
- public string DateOfBirth { get; set; }
+ [JsonPropertyName("dateOfBirth")]
+ public string DateOfBirth { get; set; }
- [JsonPropertyName("email")]
- public string Email { get; set; }
+ [JsonPropertyName("email")]
+ public string Email { get; set; }
- [JsonPropertyName("firstName")]
- public string FirstName { get; set; }
+ [JsonPropertyName("firstName")]
+ public string FirstName { get; set; }
- [JsonPropertyName("lastName")]
- public string LastName { get; set; }
+ [JsonPropertyName("lastName")]
+ public string LastName { get; set; }
- [JsonPropertyName("mobileNumber")]
- public string MobileNumber { get; set; }
+ [JsonPropertyName("mobileNumber")]
+ public string MobileNumber { get; set; }
- [JsonPropertyName("ssn")]
- public string Ssn { get; set; }
+ [JsonPropertyName("ssn")]
+ public string Ssn { get; set; }
- [JsonPropertyName("userId")]
- public string UserId { get; set; }
- }
- }
+ [JsonPropertyName("userId")]
+ public string UserId { get; set; }
+ }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/Api/VippsRequestException.cs b/src/IOL.VippsEcommerce/Models/Api/VippsRequestException.cs
index f456131..4caab3a 100644
--- a/src/IOL.VippsEcommerce/Models/Api/VippsRequestException.cs
+++ b/src/IOL.VippsEcommerce/Models/Api/VippsRequestException.cs
@@ -1,19 +1,18 @@
#nullable enable
using System;
-namespace IOL.VippsEcommerce.Models.Api
+namespace IOL.VippsEcommerce.Models.Api;
+
+[Serializable]
+public class VippsRequestException : Exception
{
- [Serializable]
- public class VippsRequestException : Exception
- {
- public VippsRequestException() { }
+ public VippsRequestException() { }
- public VippsRequestException(string message)
+ public VippsRequestException(string message)
: base(message) { }
- public VippsRequestException(string message, Exception inner)
+ public VippsRequestException(string message, Exception inner)
: base(message, inner) { }
- public VippsErrorResponse? ErrorResponse { get; set; }
- }
+ public VippsErrorResponse? ErrorResponse { get; set; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs b/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs
index 88ecf61..6afa999 100644
--- a/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs
+++ b/src/IOL.VippsEcommerce/Models/VippsConfiguration.cs
@@ -1,128 +1,127 @@
using System;
-namespace IOL.VippsEcommerce.Models
+namespace IOL.VippsEcommerce.Models;
+
+/// <summary>
+/// Configuration fields for the vipps api and integration.
+/// </summary>
+public class VippsConfiguration
{
/// <summary>
- /// Configuration fields for the vipps api and integration.
+ /// Url for the vipps api. This property is required.
+ /// <example>https://apitest.vipps.no</example>
+ /// <example>https://api.vipps.no</example>
+ /// <para>Corresponding environment variable name: VIPPS_API_URL</para>
/// </summary>
- public class VippsConfiguration
- {
- /// <summary>
- /// Url for the vipps api. This property is required.
- /// <example>https://apitest.vipps.no</example>
- /// <example>https://api.vipps.no</example>
- /// <para>Corresponding environment variable name: VIPPS_API_URL</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.API_URL)]
- public string ApiUrl { get; set; }
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.API_URL)]
+ public string ApiUrl { get; set; }
- /// <summary>
- /// Client ID for the merchant (the "username"). This property is required.
- /// <para>Corresponding environment variable name: VIPPS_CLIENT_ID</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.CLIENT_ID)]
- public string ClientId { get; set; }
+ /// <summary>
+ /// Client ID for the merchant (the "username"). This property is required.
+ /// <para>Corresponding environment variable name: VIPPS_CLIENT_ID</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.CLIENT_ID)]
+ public string ClientId { get; set; }
- /// <summary>
- /// Client Secret for the merchant (the "password"). This property is required.
- /// <para>Corresponding environment variable name: VIPPS_CLIENT_SECRET</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.CLIENT_SECRET)]
- public string ClientSecret { get; set; }
+ /// <summary>
+ /// Client Secret for the merchant (the "password"). This property is required.
+ /// <para>Corresponding environment variable name: VIPPS_CLIENT_SECRET</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.CLIENT_SECRET)]
+ public string ClientSecret { get; set; }
- /// <summary>
- /// Primary subscription key for the API product.
- /// <para>The primary subscription key take precedence over the secondary subscription key.</para>
- /// <para>Either primary subscription key or secondary subscription key is required.</para>
- /// <para>Corresponding environment variable name: VIPPS_SUBSCRIPTION_KEY_PRIMARY</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.SUBSCRIPTION_KEY_PRIMARY)]
- public string PrimarySubscriptionKey { get; set; }
+ /// <summary>
+ /// Primary subscription key for the API product.
+ /// <para>The primary subscription key take precedence over the secondary subscription key.</para>
+ /// <para>Either primary subscription key or secondary subscription key is required.</para>
+ /// <para>Corresponding environment variable name: VIPPS_SUBSCRIPTION_KEY_PRIMARY</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.SUBSCRIPTION_KEY_PRIMARY)]
+ public string PrimarySubscriptionKey { get; set; }
- /// <summary>
- /// Secondary subscription key for the API product.
- /// <para>The primary subscription key take precedence over the secondary subscription key.</para>
- /// <para>Either primary subscription key or secondary subscription key is required.</para>
- /// <para>Corresponding environment variable name: VIPPS_SUBSCRIPTION_KEY_SECONDARY</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.SUBSCRIPTION_KEY_SECONDARY)]
- public string SecondarySubscriptionKey { get; set; }
+ /// <summary>
+ /// Secondary subscription key for the API product.
+ /// <para>The primary subscription key take precedence over the secondary subscription key.</para>
+ /// <para>Either primary subscription key or secondary subscription key is required.</para>
+ /// <para>Corresponding environment variable name: VIPPS_SUBSCRIPTION_KEY_SECONDARY</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.SUBSCRIPTION_KEY_SECONDARY)]
+ public string SecondarySubscriptionKey { get; set; }
- /// <summary>
- /// The Merchant Serial Number (MSN) is a unique id for the sale unit that this payment is made for.
- /// <para>Corresponding environment variable name: VIPPS_MSN</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.MSN)]
- public string MerchantSerialNumber { get; set; }
+ /// <summary>
+ /// The Merchant Serial Number (MSN) is a unique id for the sale unit that this payment is made for.
+ /// <para>Corresponding environment variable name: VIPPS_MSN</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.MSN)]
+ public string MerchantSerialNumber { get; set; }
- /// <summary>
- /// The name of the ecommerce solution. One word in lowercase letters is good.
- /// <para>Corresponding environment variable name: VIPPS_SYSTEM_NAME</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_NAME)]
- public string SystemName { get; set; }
+ /// <summary>
+ /// The name of the ecommerce solution. One word in lowercase letters is good.
+ /// <para>Corresponding environment variable name: VIPPS_SYSTEM_NAME</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_NAME)]
+ public string SystemName { get; set; }
- /// <summary>
- /// The version number of the ecommerce solution.
- /// <para>Corresponding environment variable name: VIPPS_SYSTEM_VERSION</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_VERSION)]
- public string SystemVersion { get; set; }
+ /// <summary>
+ /// The version number of the ecommerce solution.
+ /// <para>Corresponding environment variable name: VIPPS_SYSTEM_VERSION</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_VERSION)]
+ public string SystemVersion { get; set; }
- /// <summary>
- /// The name of the ecommerce plugin (if applicable). One word in lowercase letters is good.
- /// <para>Corresponding environment variable name: VIPPS_SYSTEM_PLUGIN_NAME</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_PLUGIN_NAME)]
- public string SystemPluginName { get; set; }
+ /// <summary>
+ /// The name of the ecommerce plugin (if applicable). One word in lowercase letters is good.
+ /// <para>Corresponding environment variable name: VIPPS_SYSTEM_PLUGIN_NAME</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_PLUGIN_NAME)]
+ public string SystemPluginName { get; set; }
- /// <summary>
- /// The version number of the ecommerce plugin (if applicable).
- /// <para>Corresponding environment variable name: VIPPS_SYSTEM_PLUGIN_VERSION</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_PLUGIN_VERSION)]
- public string SystemPluginVersion { get; set; }
+ /// <summary>
+ /// The version number of the ecommerce plugin (if applicable).
+ /// <para>Corresponding environment variable name: VIPPS_SYSTEM_PLUGIN_VERSION</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.SYSTEM_PLUGIN_VERSION)]
+ public string SystemPluginVersion { get; set; }
- /// <summary>
- /// Optional path to a writable directory wherein a credential cache file can be placed.
- /// <para>Corresponding environment variable name: VIPPS_CACHE_PATH</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.CACHE_PATH)]
- public string CacheDirectoryPath { get; set; }
+ /// <summary>
+ /// Optional path to a writable directory wherein a credential cache file can be placed.
+ /// <para>Corresponding environment variable name: VIPPS_CACHE_PATH</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.CACHE_PATH)]
+ public string CacheDirectoryPath { get; set; }
- /// <summary>
- /// Optional key for AES encryption of the credential cache file.
- /// <para>Corresponding environment variable name: VIPPS_CACHE_KEY</para>
- /// </summary>
- [VippsConfigurationKeyName(VippsConfigurationKeyNames.CACHE_KEY)]
- public string CacheEncryptionKey { get; set; }
+ /// <summary>
+ /// Optional key for AES encryption of the credential cache file.
+ /// <para>Corresponding environment variable name: VIPPS_CACHE_KEY</para>
+ /// </summary>
+ [VippsConfigurationKeyName(VippsConfigurationKeyNames.CACHE_KEY)]
+ public string CacheEncryptionKey { get; set; }
- /// <summary>
- /// Ensure that the configuration can be used to issue requests to the vipps api.
- /// <exception cref="ArgumentNullException">Throws if a required value is null or whitespace.</exception>
- /// </summary>
- public void Verify() {
- if (ApiUrl.IsNullOrWhiteSpace()) {
- throw new ArgumentNullException(nameof(ApiUrl),
- "VippsEcommerceService: ApiUrl is not provided in configuration.");
- }
+ /// <summary>
+ /// Ensure that the configuration can be used to issue requests to the vipps api.
+ /// <exception cref="ArgumentNullException">Throws if a required value is null or whitespace.</exception>
+ /// </summary>
+ public void Verify() {
+ if (ApiUrl.IsNullOrWhiteSpace()) {
+ throw new ArgumentNullException(nameof(ApiUrl),
+ "VippsEcommerceService: ApiUrl is not provided in configuration.");
+ }
- if (ClientId.IsNullOrWhiteSpace()) {
- throw new ArgumentNullException(nameof(ClientId),
- "VippsEcommerceService: ClientId is not provided in configuration.");
- }
+ if (ClientId.IsNullOrWhiteSpace()) {
+ throw new ArgumentNullException(nameof(ClientId),
+ "VippsEcommerceService: ClientId is not provided in configuration.");
+ }
- if (ClientSecret.IsNullOrWhiteSpace()) {
- throw new ArgumentNullException(nameof(ClientSecret),
- "VippsEcommerceService: ClientSecret is not provided in configuration.");
- }
+ if (ClientSecret.IsNullOrWhiteSpace()) {
+ throw new ArgumentNullException(nameof(ClientSecret),
+ "VippsEcommerceService: ClientSecret is not provided in configuration.");
+ }
- if (PrimarySubscriptionKey.IsNullOrWhiteSpace()
- && SecondarySubscriptionKey.IsNullOrWhiteSpace()) {
- throw new ArgumentNullException(nameof(PrimarySubscriptionKey)
- + nameof(SecondarySubscriptionKey),
- "VippsEcommerceService: Neither PrimarySubscriptionKey nor SecondarySubscriptionKey was provided in configuration.");
- }
+ if (PrimarySubscriptionKey.IsNullOrWhiteSpace()
+ && SecondarySubscriptionKey.IsNullOrWhiteSpace()) {
+ throw new ArgumentNullException(nameof(PrimarySubscriptionKey)
+ + nameof(SecondarySubscriptionKey),
+ "VippsEcommerceService: Neither PrimarySubscriptionKey nor SecondarySubscriptionKey was provided in configuration.");
}
}
-}
+} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyName.cs b/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyName.cs
index d429b1e..d56f908 100644
--- a/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyName.cs
+++ b/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyName.cs
@@ -1,18 +1,17 @@
using System;
-namespace IOL.VippsEcommerce.Models
-{
- [AttributeUsage(AttributeTargets.Property)]
- internal sealed class VippsConfigurationKeyName : Attribute
- {
- /// <summary>
- /// Specifies a name for this configuration value.
- /// </summary>
- /// <param name="name">Name of the configuration value.</param>
- public VippsConfigurationKeyName(string name) {
- Name = name;
- }
+namespace IOL.VippsEcommerce.Models;
- public string Name { get; }
+[AttributeUsage(AttributeTargets.Property)]
+internal sealed class VippsConfigurationKeyName : Attribute
+{
+ /// <summary>
+ /// Specifies a name for this configuration value.
+ /// </summary>
+ /// <param name="name">Name of the configuration value.</param>
+ public VippsConfigurationKeyName(string name) {
+ Name = name;
}
+
+ public string Name { get; }
} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyNames.cs b/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyNames.cs
index c966762..020b803 100644
--- a/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyNames.cs
+++ b/src/IOL.VippsEcommerce/Models/VippsConfigurationKeyNames.cs
@@ -1,18 +1,17 @@
-namespace IOL.VippsEcommerce.Models
+namespace IOL.VippsEcommerce.Models;
+
+public static class VippsConfigurationKeyNames
{
- public static class VippsConfigurationKeyNames
- {
- public const string API_URL = "VIPPS_API_URL";
- public const string CLIENT_ID = "VIPPS_CLIENT_ID";
- public const string CLIENT_SECRET = "VIPPS_CLIENT_SECRET";
- public const string SUBSCRIPTION_KEY_PRIMARY = "VIPPS_SUBSCRIPTION_KEY_PRIMARY";
- public const string SUBSCRIPTION_KEY_SECONDARY = "VIPPS_SUBSCRIPTION_KEY_SECONDARY";
- public const string MSN = "VIPPS_MSN";
- public const string SYSTEM_NAME = "VIPPS_SYSTEM_NAME";
- public const string SYSTEM_VERSION = "VIPPS_SYSTEM_VERSION";
- public const string SYSTEM_PLUGIN_NAME = "VIPPS_SYSTEM_PLUGIN_NAME";
- public const string SYSTEM_PLUGIN_VERSION = "VIPPS_SYSTEM_PLUGIN_VERSION";
- public const string CACHE_PATH = "VIPPS_CACHE_PATH";
- public const string CACHE_KEY = "VIPPS_CACHE_KEY";
- }
-}
+ public const string API_URL = "VIPPS_API_URL";
+ public const string CLIENT_ID = "VIPPS_CLIENT_ID";
+ public const string CLIENT_SECRET = "VIPPS_CLIENT_SECRET";
+ public const string SUBSCRIPTION_KEY_PRIMARY = "VIPPS_SUBSCRIPTION_KEY_PRIMARY";
+ public const string SUBSCRIPTION_KEY_SECONDARY = "VIPPS_SUBSCRIPTION_KEY_SECONDARY";
+ public const string MSN = "VIPPS_MSN";
+ public const string SYSTEM_NAME = "VIPPS_SYSTEM_NAME";
+ public const string SYSTEM_VERSION = "VIPPS_SYSTEM_VERSION";
+ public const string SYSTEM_PLUGIN_NAME = "VIPPS_SYSTEM_PLUGIN_NAME";
+ public const string SYSTEM_PLUGIN_VERSION = "VIPPS_SYSTEM_PLUGIN_VERSION";
+ public const string CACHE_PATH = "VIPPS_CACHE_PATH";
+ public const string CACHE_KEY = "VIPPS_CACHE_KEY";
+} \ No newline at end of file
diff --git a/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs b/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs
index e6a4fcd..41af6a5 100644
--- a/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs
+++ b/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs
@@ -2,32 +2,31 @@ using System;
using IOL.VippsEcommerce.Models;
using Microsoft.Extensions.DependencyInjection;
-namespace IOL.VippsEcommerce
-{
- public static class ServiceCollectionExtensions
- {
- /// <summary>
- /// Configures and adds the VippsEcommerceService to your DI.
- /// </summary>
- /// <param name="services">Servicecollection to add VippsEcommerceService to.</param>
- /// <param name="configuration"></param>
- /// <returns></returns>
- public static IServiceCollection AddVippsEcommerceService(
- this IServiceCollection services,
- Action<VippsConfiguration> configuration
- ) {
- if (services == null) {
- throw new ArgumentNullException(nameof(services));
- }
+namespace IOL.VippsEcommerce;
- if (configuration == null) {
- throw new ArgumentNullException(nameof(configuration));
- }
+public static class ServiceCollectionExtensions
+{
+ /// <summary>
+ /// Configures and adds the VippsEcommerceService to your DI.
+ /// </summary>
+ /// <param name="services">Servicecollection to add VippsEcommerceService to.</param>
+ /// <param name="configuration"></param>
+ /// <returns></returns>
+ public static IServiceCollection AddVippsEcommerceService(
+ this IServiceCollection services,
+ Action<VippsConfiguration> configuration
+ ) {
+ if (services == null) {
+ throw new ArgumentNullException(nameof(services));
+ }
- services.Configure(configuration);
- services.AddHttpClient<IVippsEcommerceService, VippsEcommerceService>();
- services.AddScoped<IVippsEcommerceService, VippsEcommerceService>();
- return services;
+ if (configuration == null) {
+ throw new ArgumentNullException(nameof(configuration));
}
+
+ services.Configure(configuration);
+ services.AddHttpClient<IVippsEcommerceService, VippsEcommerceService>();
+ services.AddScoped<IVippsEcommerceService, VippsEcommerceService>();
+ return services;
}
}
diff --git a/src/IOL.VippsEcommerce/VippsEcommerceService.cs b/src/IOL.VippsEcommerce/VippsEcommerceService.cs
index 84bbf79..64802ca 100644
--- a/src/IOL.VippsEcommerce/VippsEcommerceService.cs
+++ b/src/IOL.VippsEcommerce/VippsEcommerceService.cs
@@ -11,562 +11,561 @@ using IOL.VippsEcommerce.Models.Api;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-namespace IOL.VippsEcommerce
+namespace IOL.VippsEcommerce;
+
+/// <summary>
+/// The main class for interacting with the vipps api.
+/// </summary>
+public class VippsEcommerceService : IVippsEcommerceService
{
- /// <summary>
- /// The main class for interacting with the vipps api.
- /// </summary>
- public class VippsEcommerceService : IVippsEcommerceService
- {
- private readonly HttpClient _client;
- private readonly ILogger<VippsEcommerceService> _logger;
- private readonly string _vippsClientId;
- private readonly string _vippsClientSecret;
- private readonly string _vippsMsn;
- private readonly string _cacheEncryptionKey;
- private readonly string _cacheDirectoryPath;
+ private readonly HttpClient _client;
+ private readonly ILogger<VippsEcommerceService> _logger;
+ private readonly string _vippsClientId;
+ private readonly string _vippsClientSecret;
+ private readonly string _vippsMsn;
+ private readonly string _cacheEncryptionKey;
+ private readonly string _cacheDirectoryPath;
- private readonly JsonSerializerOptions _requestJsonSerializerOptions = new() {
- IgnoreNullValues = true
- };
+ private readonly JsonSerializerOptions _requestJsonSerializerOptions = new() {
+ IgnoreNullValues = true
+ };
- private const string VIPPS_CACHE_FILE_NAME = "vipps_ecommerce_credentials.json";
- private string CacheFilePath => Path.Combine(_cacheDirectoryPath, VIPPS_CACHE_FILE_NAME);
+ private const string VIPPS_CACHE_FILE_NAME = "vipps_ecommerce_credentials.json";
+ private string CacheFilePath => Path.Combine(_cacheDirectoryPath, VIPPS_CACHE_FILE_NAME);
- public VippsConfiguration Configuration { get; }
+ public VippsConfiguration Configuration { get; }
- public VippsEcommerceService(
- HttpClient client,
- ILogger<VippsEcommerceService> logger,
- IOptions<VippsConfiguration> options
- ) {
- Configuration = options.Value;
- Configuration.Verify();
- var vippsApiUrl = Configuration.ApiUrl;
- client.BaseAddress = new Uri(vippsApiUrl);
- _client = client;
- _logger = logger;
- _vippsClientId = Configuration.ClientId;
- _vippsClientSecret = Configuration.ClientSecret;
- client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key",
- Configuration.PrimarySubscriptionKey
- ?? Configuration.SecondarySubscriptionKey);
+ public VippsEcommerceService(
+ HttpClient client,
+ ILogger<VippsEcommerceService> logger,
+ IOptions<VippsConfiguration> options
+ ) {
+ Configuration = options.Value;
+ Configuration.Verify();
+ var vippsApiUrl = Configuration.ApiUrl;
+ client.BaseAddress = new Uri(vippsApiUrl);
+ _client = client;
+ _logger = logger;
+ _vippsClientId = Configuration.ClientId;
+ _vippsClientSecret = Configuration.ClientSecret;
+ client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key",
+ Configuration.PrimarySubscriptionKey
+ ?? Configuration.SecondarySubscriptionKey);
- var msn = Configuration.MerchantSerialNumber;
- if (msn.IsPresent()) {
- client.DefaultRequestHeaders.Add("Merchant-Serial-Number", msn);
- _vippsMsn = msn;
- }
+ var msn = Configuration.MerchantSerialNumber;
+ if (msn.IsPresent()) {
+ client.DefaultRequestHeaders.Add("Merchant-Serial-Number", msn);
+ _vippsMsn = msn;
+ }
- var systemName = Configuration.SystemName;
- if (systemName.IsPresent()) {
- client.DefaultRequestHeaders.Add("Vipps-System-Name", systemName);
- }
+ var systemName = Configuration.SystemName;
+ if (systemName.IsPresent()) {
+ client.DefaultRequestHeaders.Add("Vipps-System-Name", systemName);
+ }
- var systemVersion = Configuration.SystemVersion;
- if (systemVersion.IsPresent()) {
- client.DefaultRequestHeaders.Add("Vipps-System-Version", systemVersion);
- }
+ var systemVersion = Configuration.SystemVersion;
+ if (systemVersion.IsPresent()) {
+ client.DefaultRequestHeaders.Add("Vipps-System-Version", systemVersion);
+ }
- var systemPluginName = Configuration.SystemPluginName;
- if (systemPluginName.IsPresent()) {
- client.DefaultRequestHeaders.Add("Vipps-System-Plugin-Name", systemPluginName);
- }
+ var systemPluginName = Configuration.SystemPluginName;
+ if (systemPluginName.IsPresent()) {
+ client.DefaultRequestHeaders.Add("Vipps-System-Plugin-Name", systemPluginName);
+ }
- var systemPluginVersion = Configuration.SystemPluginVersion;
- if (systemPluginVersion.IsPresent()) {
- client.DefaultRequestHeaders.Add("Vipps-System-Plugin-Version", systemPluginVersion);
- }
+ var systemPluginVersion = Configuration.SystemPluginVersion;
+ if (systemPluginVersion.IsPresent()) {
+ client.DefaultRequestHeaders.Add("Vipps-System-Plugin-Version", systemPluginVersion);
+ }
- _cacheEncryptionKey = Configuration.CacheEncryptionKey;
- _cacheDirectoryPath = Configuration.CacheDirectoryPath;
- if (_cacheDirectoryPath.IsPresent()) {
- if (!_cacheDirectoryPath.IsDirectoryWritable()) {
- _logger.LogError("Could not write to cache file directory ("
- + _cacheDirectoryPath
- + "). Disabling caching.");
- _cacheDirectoryPath = default;
- _cacheEncryptionKey = default;
- }
+ _cacheEncryptionKey = Configuration.CacheEncryptionKey;
+ _cacheDirectoryPath = Configuration.CacheDirectoryPath;
+ if (_cacheDirectoryPath.IsPresent()) {
+ if (!_cacheDirectoryPath.IsDirectoryWritable()) {
+ _logger.LogError("Could not write to cache file directory ("
+ + _cacheDirectoryPath
+ + "). Disabling caching.");
+ _cacheDirectoryPath = default;
+ _cacheEncryptionKey = default;
}
-
- _logger.LogInformation(nameof(VippsEcommerceService)
- + " was successfully initialised with api url: "
- + vippsApiUrl);
}
- /// <summary>
- /// The access token endpoint is used to get the JWT (JSON Web Token) that must be passed in every API request in the Authorization header.
- /// The access token is a base64-encoded string value that must be aquired first before making any Vipps api calls.
- /// The access token is valid for 1 hour in the test environment and 24 hours in the production environment.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- private async Task<VippsAuthorizationTokenResponse> GetAuthorizationTokenAsync(
- bool forceRefresh = false,
- CancellationToken ct = default
- ) {
- if (!forceRefresh && _cacheDirectoryPath.IsPresent() && File.Exists(CacheFilePath)) {
- var fileContents = await File.ReadAllTextAsync(CacheFilePath, ct);
+ _logger.LogInformation(nameof(VippsEcommerceService)
+ + " was successfully initialised with api url: "
+ + vippsApiUrl);
+ }
- if (fileContents.IsPresent()) {
- VippsAuthorizationTokenResponse credentials = default;
- try {
- credentials = JsonSerializer.Deserialize<VippsAuthorizationTokenResponse>(fileContents);
- } catch (Exception e) {
- if (e is JsonException && _cacheEncryptionKey.IsPresent()) { // most likely encrypted
- try {
- var decryptedContents = fileContents.DecryptWithAes(_cacheEncryptionKey);
- credentials =
- JsonSerializer.Deserialize<VippsAuthorizationTokenResponse>(decryptedContents);
- } catch {
- // ignored
- }
+ /// <summary>
+ /// The access token endpoint is used to get the JWT (JSON Web Token) that must be passed in every API request in the Authorization header.
+ /// The access token is a base64-encoded string value that must be aquired first before making any Vipps api calls.
+ /// The access token is valid for 1 hour in the test environment and 24 hours in the production environment.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ private async Task<VippsAuthorizationTokenResponse> GetAuthorizationTokenAsync(
+ bool forceRefresh = false,
+ CancellationToken ct = default
+ ) {
+ if (!forceRefresh && _cacheDirectoryPath.IsPresent() && File.Exists(CacheFilePath)) {
+ var fileContents = await File.ReadAllTextAsync(CacheFilePath, ct);
+
+ if (fileContents.IsPresent()) {
+ VippsAuthorizationTokenResponse credentials = default;
+ try {
+ credentials = JsonSerializer.Deserialize<VippsAuthorizationTokenResponse>(fileContents);
+ } catch (Exception e) {
+ if (e is JsonException && _cacheEncryptionKey.IsPresent()) { // most likely encrypted
+ try {
+ var decryptedContents = fileContents.DecryptWithAes(_cacheEncryptionKey);
+ credentials =
+ JsonSerializer.Deserialize<VippsAuthorizationTokenResponse>(decryptedContents);
+ } catch {
+ // ignored
}
}
+ }
- if (credentials != default) {
- var currentEpoch = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
- if (long.TryParse(credentials.ExpiresOn, out var expires)
- && credentials.AccessToken.IsPresent()) {
- if (expires - 600 > currentEpoch) {
- _logger.LogDebug(nameof(VippsEcommerceService) + ": Got tokens from cache");
- return credentials;
- }
+ if (credentials != default) {
+ var currentEpoch = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
+ if (long.TryParse(credentials.ExpiresOn, out var expires)
+ && credentials.AccessToken.IsPresent()) {
+ if (expires - 600 > currentEpoch) {
+ _logger.LogDebug(nameof(VippsEcommerceService) + ": Got tokens from cache");
+ return credentials;
}
}
}
}
+ }
- var requestMessage = new HttpRequestMessage {
- Headers = {
- {
- "client_id", _vippsClientId
- }, {
- "client_secret", _vippsClientSecret
- },
- },
- RequestUri = new Uri(_client.BaseAddress + "accesstoken/get"),
- Method = HttpMethod.Post
- };
- var response = await _client.SendAsync(requestMessage, ct);
-
- try {
- response.EnsureSuccessStatusCode();
- var credentials = await response.Content.ReadAsStringAsync(ct);
-
- if (_cacheDirectoryPath.IsPresent()) {
- await File.WriteAllTextAsync(CacheFilePath,
- _cacheEncryptionKey.IsPresent()
- ? credentials.EncryptWithAes(_cacheEncryptionKey)
- : credentials,
- ct);
- }
+ var requestMessage = new HttpRequestMessage {
+ Headers = {
+ {
+ "client_id", _vippsClientId
+ }, {
+ "client_secret", _vippsClientSecret
+ },
+ },
+ RequestUri = new Uri(_client.BaseAddress + "accesstoken/get"),
+ Method = HttpMethod.Post
+ };
+ var response = await _client.SendAsync(requestMessage, ct);
- _logger.LogDebug(nameof(VippsEcommerceService) + ": Got tokens from " + requestMessage.RequestUri);
- return JsonSerializer.Deserialize<VippsAuthorizationTokenResponse>(credentials);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(GetAuthorizationTokenAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ try {
+ response.EnsureSuccessStatusCode();
+ var credentials = await response.Content.ReadAsStringAsync(ct);
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(GetAuthorizationTokenAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ if (_cacheDirectoryPath.IsPresent()) {
+ await File.WriteAllTextAsync(CacheFilePath,
+ _cacheEncryptionKey.IsPresent()
+ ? credentials.EncryptWithAes(_cacheEncryptionKey)
+ : credentials,
+ ct);
+ }
+ _logger.LogDebug(nameof(VippsEcommerceService) + ": Got tokens from " + requestMessage.RequestUri);
+ return JsonSerializer.Deserialize<VippsAuthorizationTokenResponse>(credentials);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(GetAuthorizationTokenAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
-
- /// <summary>
- /// This API call allows the merchants to initiate payments.
- /// The merchantSerialNumber (MSN) specifies which sales unit the payments is for.
- /// Payments are uniquely identified with the merchantSerialNumber and orderId together.
- /// The merchant-provided orderId must be unique per sales channel.
- /// Once the transaction is successfully initiated in Vipps, you will receive a response with a fallBack URL which will direct the customer to the Vipps landing page.
- /// The landing page detects if the request comes from a mobile or laptop/desktop device, and if on a mobile device automatically switches to the Vipps app if it is intalled.
- /// The merchant may also pass the 'isApp: true' parameter that will make Vipps respond with a app-switch deeplink that will take the customer directly to the Vipps app.
- /// URLs passed to Vipps must validate with the Apache Commons UrlValidator.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<VippsInitiatePaymentResponse> InitiatePaymentAsync(
- VippsInitiatePaymentRequest payload,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(GetAuthorizationTokenAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
- var response = await _client.PostAsJsonAsync("ecomm/v2/payments",
- payload,
- _requestJsonSerializerOptions,
- ct);
+ throw exception;
+ }
+ }
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return await response.Content
- .ReadFromJsonAsync<VippsInitiatePaymentResponse>(cancellationToken: ct);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(InitiatePaymentAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(InitiatePaymentAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ /// <summary>
+ /// This API call allows the merchants to initiate payments.
+ /// The merchantSerialNumber (MSN) specifies which sales unit the payments is for.
+ /// Payments are uniquely identified with the merchantSerialNumber and orderId together.
+ /// The merchant-provided orderId must be unique per sales channel.
+ /// Once the transaction is successfully initiated in Vipps, you will receive a response with a fallBack URL which will direct the customer to the Vipps landing page.
+ /// The landing page detects if the request comes from a mobile or laptop/desktop device, and if on a mobile device automatically switches to the Vipps app if it is intalled.
+ /// The merchant may also pass the 'isApp: true' parameter that will make Vipps respond with a app-switch deeplink that will take the customer directly to the Vipps app.
+ /// URLs passed to Vipps must validate with the Apache Commons UrlValidator.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<VippsInitiatePaymentResponse> InitiatePaymentAsync(
+ VippsInitiatePaymentRequest payload,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
+ var response = await _client.PostAsJsonAsync("ecomm/v2/payments",
+ payload,
+ _requestJsonSerializerOptions,
+ ct);
+
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return await response.Content
+ .ReadFromJsonAsync<VippsInitiatePaymentResponse>(cancellationToken: ct);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(InitiatePaymentAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
- /// <summary>
- /// This API call allows merchant to capture the reserved amount.
- /// Amount to capture cannot be higher than reserved.
- /// The API also allows capturing partial amount of the reserved amount.
- /// Partial capture can be called as many times as required so long there is reserved amount to capture.
- /// Transaction text is not optional and is used as a proof of delivery (tracking code, consignment number etc.).
- /// In a case of direct capture, both fund reservation and capture are executed in a single operation.
- /// It is important to check the response, and the capture is only successful when the response is HTTP 200 OK.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<VippsPaymentActionResponse> CapturePaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(InitiatePaymentAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
+ throw exception;
+ }
+ }
- if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
- payload.MerchantInfo = new TMerchantInfoPayment {
- MerchantSerialNumber = _vippsMsn
- };
- }
+ /// <summary>
+ /// This API call allows merchant to capture the reserved amount.
+ /// Amount to capture cannot be higher than reserved.
+ /// The API also allows capturing partial amount of the reserved amount.
+ /// Partial capture can be called as many times as required so long there is reserved amount to capture.
+ /// Transaction text is not optional and is used as a proof of delivery (tracking code, consignment number etc.).
+ /// In a case of direct capture, both fund reservation and capture are executed in a single operation.
+ /// It is important to check the response, and the capture is only successful when the response is HTTP 200 OK.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<VippsPaymentActionResponse> CapturePaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
- var response = await _client.PostAsJsonAsync("ecomm/v2/payments/" + orderId + "/capture",
- payload,
- _requestJsonSerializerOptions,
- ct);
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(CapturePaymentAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
+ payload.MerchantInfo = new TMerchantInfoPayment {
+ MerchantSerialNumber = _vippsMsn
+ };
+ }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(CapturePaymentAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ var response = await _client.PostAsJsonAsync("ecomm/v2/payments/" + orderId + "/capture",
+ payload,
+ _requestJsonSerializerOptions,
+ ct);
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(CapturePaymentAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
-
- /// <summary>
- /// The API call allows merchant to cancel the reserved or initiated transaction.
- /// The API will not allow partial cancellation which has the consequence that partially captured transactions cannot be cancelled.
- /// Please note that in a case of communication errors during initiate payment service call between Vipps and PSP/Acquirer/Issuer; even in a case that customer has confirmed a payment, the payment will be cancelled by Vipps.
- /// Note this means you can not cancel a captured payment.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<VippsPaymentActionResponse> CancelPaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(CapturePaymentAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
- if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
- payload.MerchantInfo = new TMerchantInfoPayment {
- MerchantSerialNumber = _vippsMsn
- };
- }
+ throw exception;
+ }
+ }
- var response = await _client.PutAsJsonAsync("ecomm/v2/payments/" + orderId + "/cancel",
- payload,
- _requestJsonSerializerOptions,
- ct);
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(CancelPaymentAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ /// <summary>
+ /// The API call allows merchant to cancel the reserved or initiated transaction.
+ /// The API will not allow partial cancellation which has the consequence that partially captured transactions cannot be cancelled.
+ /// Please note that in a case of communication errors during initiate payment service call between Vipps and PSP/Acquirer/Issuer; even in a case that customer has confirmed a payment, the payment will be cancelled by Vipps.
+ /// Note this means you can not cancel a captured payment.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<VippsPaymentActionResponse> CancelPaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(CancelPaymentAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
+ payload.MerchantInfo = new TMerchantInfoPayment {
+ MerchantSerialNumber = _vippsMsn
+ };
+ }
+
+ var response = await _client.PutAsJsonAsync("ecomm/v2/payments/" + orderId + "/cancel",
+ payload,
+ _requestJsonSerializerOptions,
+ ct);
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(CancelPaymentAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
- /// <summary>
- /// The API call allows merchant to refresh the authorizations of the payment.
- /// A reservation's lifetime is defined by the scheme. Typically 7 days for Visa, and 30 days for Mastercard.
- /// This is currently not live in production and will be added shortly.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<VippsPaymentActionResponse> AuthorizePaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(CancelPaymentAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
- if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
- payload.MerchantInfo = new TMerchantInfoPayment {
- MerchantSerialNumber = _vippsMsn
- };
- }
+ throw exception;
+ }
+ }
- var response = await _client.PutAsJsonAsync("ecomm/v2/payments/" + orderId + "/authorize",
- payload,
- _requestJsonSerializerOptions,
- ct);
+ /// <summary>
+ /// The API call allows merchant to refresh the authorizations of the payment.
+ /// A reservation's lifetime is defined by the scheme. Typically 7 days for Visa, and 30 days for Mastercard.
+ /// This is currently not live in production and will be added shortly.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<VippsPaymentActionResponse> AuthorizePaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(AuthorizePaymentAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
+ payload.MerchantInfo = new TMerchantInfoPayment {
+ MerchantSerialNumber = _vippsMsn
+ };
+ }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(AuthorizePaymentAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ var response = await _client.PutAsJsonAsync("ecomm/v2/payments/" + orderId + "/authorize",
+ payload,
+ _requestJsonSerializerOptions,
+ ct);
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(AuthorizePaymentAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
- /// <summary>
- /// The API allows a merchant to do a refund of already captured transaction.
- /// There is an option to do a partial refund of the captured amount.
- /// Refunded amount cannot be larger than captured.
- /// Timeframe for issuing a refund for a payment is 365 days from the date payment has been captured.
- /// If the refund payment service call is called after the refund timeframe, service call will respond with an error.
- /// Refunded funds will be transferred from the merchant account to the customer credit card that was used in payment flow.
- /// Pay attention that in order to perform refund, there must be enough funds at merchant settlements account.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<VippsPaymentActionResponse> RefundPaymentAsync(
- string orderId,
- VippsPaymentActionRequest payload,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(AuthorizePaymentAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
- if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
- payload.MerchantInfo = new TMerchantInfoPayment {
- MerchantSerialNumber = _vippsMsn
- };
- }
+ throw exception;
+ }
+ }
- var response = await _client.PostAsJsonAsync("ecomm/v2/payments/" + orderId + "/refund",
- payload,
- _requestJsonSerializerOptions,
- ct);
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(RefundPaymentAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ /// <summary>
+ /// The API allows a merchant to do a refund of already captured transaction.
+ /// There is an option to do a partial refund of the captured amount.
+ /// Refunded amount cannot be larger than captured.
+ /// Timeframe for issuing a refund for a payment is 365 days from the date payment has been captured.
+ /// If the refund payment service call is called after the refund timeframe, service call will respond with an error.
+ /// Refunded funds will be transferred from the merchant account to the customer credit card that was used in payment flow.
+ /// Pay attention that in order to perform refund, there must be enough funds at merchant settlements account.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<VippsPaymentActionResponse> RefundPaymentAsync(
+ string orderId,
+ VippsPaymentActionRequest payload,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(RefundPaymentAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ if (payload.MerchantInfo?.MerchantSerialNumber.IsNullOrWhiteSpace() ?? false) {
+ payload.MerchantInfo = new TMerchantInfoPayment {
+ MerchantSerialNumber = _vippsMsn
+ };
+ }
+ var response = await _client.PostAsJsonAsync("ecomm/v2/payments/" + orderId + "/refund",
+ payload,
+ _requestJsonSerializerOptions,
+ ct);
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return await response.Content.ReadFromJsonAsync<VippsPaymentActionResponse>(cancellationToken: ct);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(RefundPaymentAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
-
- /// <summary>
- /// This endpoint allows developers to approve a payment through the Vipps eCom API without the use of the Vipps app.
- /// This is useful for automated testing.
- /// Express checkout is not supported for this endpoint.
- /// The endpoint is only available in our Test environment.
- /// Attempted use of the endpoint in production is not allowed, and will fail.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<bool> ForceApprovePaymentAsync(
- string orderId,
- VippsForceApproveRequest payload,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(RefundPaymentAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
+ throw exception;
+ }
+ }
- var response =
- await _client.PostAsJsonAsync("ecomm/v2/integration-test/payments/" + orderId + "/approve",
- payload,
- _requestJsonSerializerOptions,
- ct);
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return true;
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(ForceApprovePaymentAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ /// <summary>
+ /// This endpoint allows developers to approve a payment through the Vipps eCom API without the use of the Vipps app.
+ /// This is useful for automated testing.
+ /// Express checkout is not supported for this endpoint.
+ /// The endpoint is only available in our Test environment.
+ /// Attempted use of the endpoint in production is not allowed, and will fail.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<bool> ForceApprovePaymentAsync(
+ string orderId,
+ VippsForceApproveRequest payload,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(ForceApprovePaymentAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ var response =
+ await _client.PostAsJsonAsync("ecomm/v2/integration-test/payments/" + orderId + "/approve",
+ payload,
+ _requestJsonSerializerOptions,
+ ct);
+
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return true;
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(ForceApprovePaymentAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
- }
- /// <summary>
- /// This API call allows merchant to get the details of a payment transaction.
- /// Service call returns detailed transaction history of given payment where events are sorted from newest to oldest for when the transaction occurred.
- /// </summary>
- /// <returns></returns>
- /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
- public async Task<VippsGetPaymentDetailsResponse> GetPaymentDetailsAsync(
- string orderId,
- CancellationToken ct = default
- ) {
- if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
- var credentials = await GetAuthorizationTokenAsync(false, ct);
- _client.DefaultRequestHeaders.Authorization =
- new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(ForceApprovePaymentAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
}
- var response = await _client.GetAsync("ecomm/v2/payments/" + orderId + "/details", ct);
+ throw exception;
+ }
+ }
- try {
- response.EnsureSuccessStatusCode();
- _logger.LogDebug(nameof(VippsEcommerceService)
- + ": Successfully issued a request to "
- + response.RequestMessage?.RequestUri);
- return await
- response.Content.ReadFromJsonAsync<VippsGetPaymentDetailsResponse>(cancellationToken: ct);
- } catch (Exception e) {
- var exception = new VippsRequestException(nameof(GetPaymentDetailsAsync) + " failed.", e);
- if (e is not HttpRequestException) {
- throw exception;
- }
+ /// <summary>
+ /// This API call allows merchant to get the details of a payment transaction.
+ /// Service call returns detailed transaction history of given payment where events are sorted from newest to oldest for when the transaction occurred.
+ /// </summary>
+ /// <returns></returns>
+ /// <exception cref="HttpRequestException">Throws if the api returns unsuccessfully</exception>
+ public async Task<VippsGetPaymentDetailsResponse> GetPaymentDetailsAsync(
+ string orderId,
+ CancellationToken ct = default
+ ) {
+ if (_client.DefaultRequestHeaders.Authorization?.Parameter.IsNullOrWhiteSpace() ?? true) {
+ var credentials = await GetAuthorizationTokenAsync(false, ct);
+ _client.DefaultRequestHeaders.Authorization =
+ new AuthenticationHeaderValue("Bearer", credentials.AccessToken);
+ }
- try {
- exception.ErrorResponse =
- await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
- _logger.LogError(nameof(GetPaymentDetailsAsync)
- + " Api error response: "
- + JsonSerializer.Serialize(response.Content));
- } catch {
- // ignored
- }
+ var response = await _client.GetAsync("ecomm/v2/payments/" + orderId + "/details", ct);
+ try {
+ response.EnsureSuccessStatusCode();
+ _logger.LogDebug(nameof(VippsEcommerceService)
+ + ": Successfully issued a request to "
+ + response.RequestMessage?.RequestUri);
+ return await
+ response.Content.ReadFromJsonAsync<VippsGetPaymentDetailsResponse>(cancellationToken: ct);
+ } catch (Exception e) {
+ var exception = new VippsRequestException(nameof(GetPaymentDetailsAsync) + " failed.", e);
+ if (e is not HttpRequestException) {
throw exception;
}
+
+ try {
+ exception.ErrorResponse =
+ await response.Content.ReadFromJsonAsync<VippsErrorResponse>(cancellationToken: ct);
+ _logger.LogError(nameof(GetPaymentDetailsAsync)
+ + " Api error response: "
+ + JsonSerializer.Serialize(response.Content));
+ } catch {
+ // ignored
+ }
+
+ throw exception;
}
}
}