From df73db83c77d20dd0da2aa729d6ef3e4ca40d117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Bobi=C4=8Di=C4=87?= Date: Mon, 30 Sep 2024 13:51:02 +0200 Subject: [PATCH 1/2] Fix Recurring Order Model --- .../Recurring/CheckoutRecurring.cs | 4 +- .../CheckoutApi/Recurring/RecurringOrder.cs | 149 ++++++++++++++++++ 2 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 src/Svea.WebPay.SDK/CheckoutApi/Recurring/RecurringOrder.cs diff --git a/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs b/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs index ede4824..1d7b5b8 100644 --- a/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs +++ b/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs @@ -12,10 +12,10 @@ public CheckoutRecurring(SveaHttpClient sveaHttpClient) _sveaHttpClient = sveaHttpClient; } - public async Task CreateRecurringOrderAsync(CreateRecurringOrderModel createRecurringOrder, string recurringToken, bool configureAwait = false) + public async Task CreateRecurringOrderAsync(CreateRecurringOrderModel createRecurringOrder, string recurringToken, bool configureAwait = false) { var url = new Uri($"/api/tokens/{recurringToken}/orders", UriKind.Relative); - var data = await _sveaHttpClient.HttpPost(url, createRecurringOrder, configureAwait); + var data = await _sveaHttpClient.HttpPost(url, createRecurringOrder, configureAwait); return data; } diff --git a/src/Svea.WebPay.SDK/CheckoutApi/Recurring/RecurringOrder.cs b/src/Svea.WebPay.SDK/CheckoutApi/Recurring/RecurringOrder.cs new file mode 100644 index 0000000..441c5af --- /dev/null +++ b/src/Svea.WebPay.SDK/CheckoutApi/Recurring/RecurringOrder.cs @@ -0,0 +1,149 @@ +using System.Text.Json.Serialization; + +namespace Svea.WebPay.SDK.CheckoutApi.Recurring +{ + public class RecurringOrder + { + /// + /// Specific merchant URIs + /// + /// Required. + [JsonInclude] + public RecurringMerchantSettings MerchantSettings { get; set; } + + /// + /// Order rows. + /// + [JsonInclude] + public Cart Cart { get; set; } + + /// + /// Identified customer of the order. + /// + [JsonInclude] + public Customer Customer { get; set; } + + /// + /// Shipping address of identified customer. + /// + [JsonInclude] + public Address ShippingAddress { get; set; } + + /// + /// Billing address of identified customer. + /// + [JsonInclude] + public Address BillingAddress { get; set; } + + + /// + /// The current locale of the checkout, i.e.sv-SE etc. + /// + /// Required. + [JsonInclude] + public string Locale { get; set; } + + /// + /// The current currency as defined by ISO 4217, i.e. SEK, NOK etc. + /// + /// Required. + [JsonInclude] + public string Currency { get; set; } + + /// + /// Defined by two-letter ISO 3166-1 alpha-2, i.e. SE, DE, FI etc. + /// + [JsonInclude] + public string CountryCode { get; set; } + + /// + /// A list containing the preset values, if any. + /// + [JsonInclude] + public Presetvalue[] PresetValues { get; set; } + + [JsonInclude] + public string ClientOrderNumber { get; set; } + + [JsonInclude] + public long OrderId { get; set; } + + [JsonInclude] + public string EmailAddress { get; set; } + + /// + /// The customer’s phone number + /// + [JsonInclude] + public string PhoneNumber { get; set; } + + /// + /// The final payment method for the order. Will only have a value when the order is finalized, otherwise unknown. + /// + [JsonInclude] + public PaymentType? PaymentType { get; set; } + + /// + /// The current state of the order + /// + [JsonInclude] + public CheckoutOrderStatus Status { get; set; } + + /// + /// B2B Customer reference + /// + [JsonInclude] + public object CustomerReference { get; set; } + + /// + /// True = Svea will buy this invoice. False = Svea will not buy this invoice. null = Selected payment method is not Invoice. + /// + [JsonInclude] + public bool? SveaWillBuyOrder { get; set; } + + [JsonInclude] + public IdentityFlags IdentityFlags { get; set; } + + /// + /// Metadata visible to the store + /// + /// Optional. Cleaned up from Checkout database after 45 days. + [JsonInclude] + public object MerchantData { get; set; } + + /// + /// The final payment method for the order. Will only have a value when the order is finalized, otherwise null. + /// + [JsonInclude] + public PaymentInfo Payment { get; set; } + + /// + /// A company’s ID in the PEPPOL network, which allows the company to receive PEPPOL invoices. A PEPPOL ID can be entered when placing a B2B order using the payment method invoice. + /// + [JsonInclude] + public string PeppolId { get; set; } + + [JsonInclude] + public GetOrderShippingInformation ShippingInformation { get; set; } + + /// + /// Indicates if the order is recurring order and will create a recurring token when order is finalized. Only applicable if merchant has recurring orders enabled. + /// + [JsonInclude] + public bool? Recurring { get; set; } + + + /// + /// Recurring token to be used for subsequent recurring orders. Only available when order is finalized. Only applicable if merchant has recurring orders enabled. + /// + [JsonInclude] + public string RecurringToken { get; set; } + + /// + /// Order validations such as minimum age requirement. + /// Apply it in order to have order validation such as minimum age. + /// + [JsonInclude] + public OrderValidation Validation { get; set; } + } +} From afe664e1073937d3e1d583b78b30eaafe96a65b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Bobi=C4=8Di=C4=87?= Date: Mon, 30 Sep 2024 14:17:57 +0200 Subject: [PATCH 2/2] Recurring order model change for GetRecurringOrder --- .../CheckoutApi/Recurring/CheckoutRecurring.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs b/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs index 1d7b5b8..da87469 100644 --- a/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs +++ b/src/Svea.WebPay.SDK/CheckoutApi/Recurring/CheckoutRecurring.cs @@ -25,10 +25,10 @@ public async Task GetRecurringTokenAsync(string recurringToken, var data = await _sveaHttpClient.HttpGet(url, configureAwait); return data; } - public async Task GetRecurringOrderAsync(string recurringToken, long orderId, bool configureAwait = false) + public async Task GetRecurringOrderAsync(string recurringToken, long orderId, bool configureAwait = false) { var url = new Uri($"/api/tokens/{recurringToken}/orders/{orderId}", UriKind.Relative); - var data = await _sveaHttpClient.HttpGet(url, configureAwait); + var data = await _sveaHttpClient.HttpGet(url, configureAwait); return data; } public async Task ChangePaymentMethodAsync(ChangepaymentMethodModel changePaymentMethodModel, string recurringToken, bool configureAwait = false)