From 0ca924578269d6c7d1cc48a169b26df986fec016 Mon Sep 17 00:00:00 2001 From: Adam Drewery <8437373+adam-drewery@users.noreply.github.com> Date: Mon, 18 Dec 2023 18:26:10 +0100 Subject: [PATCH] Add files --- .gitignore | 1 + Blazor.PayPal/Address.cs | 24 +++++++ Blazor.PayPal/AmountWithBreakdown.cs | 33 ++++++++++ Blazor.PayPal/AmountWithCurrencyCode.cs | 12 ++++ .../AmountWithCurrencyCodeOptional.cs | 12 ++++ Blazor.PayPal/Blazor.PayPal.csproj | 13 ++++ Blazor.PayPal/CreateOrderRequestBody.cs | 21 ++++++ Blazor.PayPal/CreditFinancingOffer.cs | 21 ++++++ Blazor.PayPal/InstallmentDetails.cs | 15 +++++ Blazor.PayPal/LinkDescription.cs | 15 +++++ Blazor.PayPal/OrderApplicationContext.cs | 21 ++++++ Blazor.PayPal/OrderResponseBody.cs | 33 ++++++++++ Blazor.PayPal/OrderResponseBodyMinimal.cs | 15 +++++ Blazor.PayPal/Payee.cs | 12 ++++ Blazor.PayPal/Payer.cs | 66 +++++++++++++++++++ Blazor.PayPal/PaymentInstruction.cs | 12 ++++ Blazor.PayPal/PaymentMethod.cs | 12 ++++ Blazor.PayPal/PlatformFee.cs | 12 ++++ Blazor.PayPal/PurchaseItem.cs | 27 ++++++++ Blazor.PayPal/PurchaseUnit.cs | 15 +++++ Blazor.PayPal/ShippingInfoBase.cs | 30 +++++++++ Blazor.PayPal/ShippingInfoOption.cs | 23 +++++++ Blazor.PayPal/ShippingInfoWithOptions.cs | 9 +++ Blazor.PayPal/ShippingInfoWithType.cs | 11 ++++ Blazor.PayPal/UpdateOrderOperation.cs | 15 +++++ Blazor.PayPal/UpdateOrderRequestBody.cs | 6 ++ 26 files changed, 486 insertions(+) create mode 100644 Blazor.PayPal/Address.cs create mode 100644 Blazor.PayPal/AmountWithBreakdown.cs create mode 100644 Blazor.PayPal/AmountWithCurrencyCode.cs create mode 100644 Blazor.PayPal/AmountWithCurrencyCodeOptional.cs create mode 100644 Blazor.PayPal/Blazor.PayPal.csproj create mode 100644 Blazor.PayPal/CreateOrderRequestBody.cs create mode 100644 Blazor.PayPal/CreditFinancingOffer.cs create mode 100644 Blazor.PayPal/InstallmentDetails.cs create mode 100644 Blazor.PayPal/LinkDescription.cs create mode 100644 Blazor.PayPal/OrderApplicationContext.cs create mode 100644 Blazor.PayPal/OrderResponseBody.cs create mode 100644 Blazor.PayPal/OrderResponseBodyMinimal.cs create mode 100644 Blazor.PayPal/Payee.cs create mode 100644 Blazor.PayPal/Payer.cs create mode 100644 Blazor.PayPal/PaymentInstruction.cs create mode 100644 Blazor.PayPal/PaymentMethod.cs create mode 100644 Blazor.PayPal/PlatformFee.cs create mode 100644 Blazor.PayPal/PurchaseItem.cs create mode 100644 Blazor.PayPal/PurchaseUnit.cs create mode 100644 Blazor.PayPal/ShippingInfoBase.cs create mode 100644 Blazor.PayPal/ShippingInfoOption.cs create mode 100644 Blazor.PayPal/ShippingInfoWithOptions.cs create mode 100644 Blazor.PayPal/ShippingInfoWithType.cs create mode 100644 Blazor.PayPal/UpdateOrderOperation.cs create mode 100644 Blazor.PayPal/UpdateOrderRequestBody.cs diff --git a/.gitignore b/.gitignore index 8a30d25..a255f99 100644 --- a/.gitignore +++ b/.gitignore @@ -396,3 +396,4 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml +.idea/ diff --git a/Blazor.PayPal/Address.cs b/Blazor.PayPal/Address.cs new file mode 100644 index 0000000..3c24f09 --- /dev/null +++ b/Blazor.PayPal/Address.cs @@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class Address +{ + [JsonPropertyName("address_line_1")] + public string? AddressLine1 { get; set; } + + [JsonPropertyName("address_line_2")] + public string? AddressLine2 { get; set; } + + [JsonPropertyName("admin_area_1")] + public string? AdminArea1 { get; set; } + + [JsonPropertyName("admin_area_2")] + public string? AdminArea2 { get; set; } + + [JsonPropertyName("postal_code")] + public string? PostalCode { get; set; } + + [JsonPropertyName("country_code")] + public string? CountryCode { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/AmountWithBreakdown.cs b/Blazor.PayPal/AmountWithBreakdown.cs new file mode 100644 index 0000000..0db7067 --- /dev/null +++ b/Blazor.PayPal/AmountWithBreakdown.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class AmountWithBreakdown : AmountWithCurrencyCodeOptional +{ + public class Breakdown + { + [JsonPropertyName("item_total")] + public AmountWithCurrencyCode? ItemTotal { get; set; } + + [JsonPropertyName("shipping")] + public AmountWithCurrencyCode? Shipping { get; set; } + + [JsonPropertyName("handling")] + public AmountWithCurrencyCode? Handling { get; set; } + + [JsonPropertyName("tax_total")] + public AmountWithCurrencyCode? TaxTotal { get; set; } + + [JsonPropertyName("insurance")] + public AmountWithCurrencyCode? Insurance { get; set; } + + [JsonPropertyName("shipping_discount")] + public AmountWithCurrencyCode? ShippingDiscount { get; set; } + + [JsonPropertyName("discount")] + public AmountWithCurrencyCode? Discount { get; set; } + } + + [JsonPropertyName("breakdown")] + public Breakdown? BreakdownInfo { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/AmountWithCurrencyCode.cs b/Blazor.PayPal/AmountWithCurrencyCode.cs new file mode 100644 index 0000000..57c1358 --- /dev/null +++ b/Blazor.PayPal/AmountWithCurrencyCode.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class AmountWithCurrencyCode +{ + [JsonPropertyName("currency_code")] + public string? CurrencyCode { get; set; } + + [JsonPropertyName("value")] + public string? Value { get; set; } // Assuming value is a string representing a number, else adjust the type accordingly +} \ No newline at end of file diff --git a/Blazor.PayPal/AmountWithCurrencyCodeOptional.cs b/Blazor.PayPal/AmountWithCurrencyCodeOptional.cs new file mode 100644 index 0000000..15c238b --- /dev/null +++ b/Blazor.PayPal/AmountWithCurrencyCodeOptional.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class AmountWithCurrencyCodeOptional +{ + [JsonPropertyName("currency_code")] + public string? CurrencyCode { get; set; } + + [JsonPropertyName("value")] + public string? Value { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/Blazor.PayPal.csproj b/Blazor.PayPal/Blazor.PayPal.csproj new file mode 100644 index 0000000..aeced11 --- /dev/null +++ b/Blazor.PayPal/Blazor.PayPal.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + \ No newline at end of file diff --git a/Blazor.PayPal/CreateOrderRequestBody.cs b/Blazor.PayPal/CreateOrderRequestBody.cs new file mode 100644 index 0000000..0c75e71 --- /dev/null +++ b/Blazor.PayPal/CreateOrderRequestBody.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class CreateOrderRequestBody +{ + [JsonPropertyName("intent")] + public string? Intent { get; set; } + + [JsonPropertyName("purchase_units")] + public List? PurchaseUnits { get; set; } + + [JsonPropertyName("payer")] + public Payer? Payer { get; set; } + + [JsonPropertyName("application_context")] + public OrderApplicationContext? ApplicationContext { get; set; } + + [JsonPropertyName("payment_source")] + public Dictionary? PaymentSource { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/CreditFinancingOffer.cs b/Blazor.PayPal/CreditFinancingOffer.cs new file mode 100644 index 0000000..ddca3a9 --- /dev/null +++ b/Blazor.PayPal/CreditFinancingOffer.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class CreditFinancingOffer +{ + [JsonPropertyName("issuer")] + public string? Issuer { get; set; } + + [JsonPropertyName("total_payment")] + public AmountWithCurrencyCodeOptional? TotalPayment { get; set; } + + [JsonPropertyName("total_interest")] + public AmountWithCurrencyCodeOptional? TotalInterest { get; set; } + + [JsonPropertyName("installment_details")] + public InstallmentDetails? InstallmentDetails { get; set; } + + [JsonPropertyName("term")] + public int Term { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/InstallmentDetails.cs b/Blazor.PayPal/InstallmentDetails.cs new file mode 100644 index 0000000..fb85148 --- /dev/null +++ b/Blazor.PayPal/InstallmentDetails.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class InstallmentDetails +{ + [JsonPropertyName("period")] + public string? Period { get; set; } + + [JsonPropertyName("interval_duration")] + public string? IntervalDuration { get; set; } + + [JsonPropertyName("payment_due")] + public AmountWithCurrencyCodeOptional? PaymentDue { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/LinkDescription.cs b/Blazor.PayPal/LinkDescription.cs new file mode 100644 index 0000000..2bb5151 --- /dev/null +++ b/Blazor.PayPal/LinkDescription.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class LinkDescription +{ + [JsonPropertyName("href")] + public string? Href { get; set; } + + [JsonPropertyName("rel")] + public string? Rel { get; set; } + + [JsonPropertyName("method")] + public string? Method { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/OrderApplicationContext.cs b/Blazor.PayPal/OrderApplicationContext.cs new file mode 100644 index 0000000..0a3ad1d --- /dev/null +++ b/Blazor.PayPal/OrderApplicationContext.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class OrderApplicationContext +{ + [JsonPropertyName("brand_name")] + public string? BrandName { get; set; } + + [JsonPropertyName("locale")] + public string? Locale { get; set; } + + [JsonPropertyName("shipping_preference")] + public string? ShippingPreference { get; set; } + + [JsonPropertyName("user_action")] + public string? UserAction { get; set; } + + [JsonPropertyName("payment_method")] + public PaymentMethod? PaymentMethod { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/OrderResponseBody.cs b/Blazor.PayPal/OrderResponseBody.cs new file mode 100644 index 0000000..299b591 --- /dev/null +++ b/Blazor.PayPal/OrderResponseBody.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class OrderResponseBody : OrderResponseBodyMinimal +{ + [JsonPropertyName("create_time")] + public string? CreateTime { get; set; } + + [JsonPropertyName("update_time")] + public string? UpdateTime { get; set; } + + [JsonPropertyName("intent")] + public string? Intent { get; set; } + + [JsonPropertyName("payer")] + public Payer? Payer { get; set; } + + [JsonPropertyName("purchase_units")] + public List? PurchaseUnits { get; set; } + + [JsonPropertyName("processing_instruction")] + public string? ProcessingInstruction { get; set; } + + [JsonPropertyName("payment_source")] + public Dictionary? PaymentSource { get; set; } + + [JsonPropertyName("expiration_time")] + public string? ExpirationTime { get; set; } + + [JsonPropertyName("credit_financing_offer")] + public CreditFinancingOffer? CreditFinancingOffer { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/OrderResponseBodyMinimal.cs b/Blazor.PayPal/OrderResponseBodyMinimal.cs new file mode 100644 index 0000000..8ac423b --- /dev/null +++ b/Blazor.PayPal/OrderResponseBodyMinimal.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class OrderResponseBodyMinimal +{ + [JsonPropertyName("id")] + public string? Id { get; set; } + + [JsonPropertyName("status")] + public string? Status { get; set; } + + [JsonPropertyName("links")] + public List? Links { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/Payee.cs b/Blazor.PayPal/Payee.cs new file mode 100644 index 0000000..ba0659e --- /dev/null +++ b/Blazor.PayPal/Payee.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class Payee +{ + [JsonPropertyName("merchant_id")] + public string? MerchantId { get; set; } + + [JsonPropertyName("email_address")] + public string? EmailAddress { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/Payer.cs b/Blazor.PayPal/Payer.cs new file mode 100644 index 0000000..221fe09 --- /dev/null +++ b/Blazor.PayPal/Payer.cs @@ -0,0 +1,66 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class Payer +{ + public class Name + { + [JsonPropertyName("given_name")] + [MaxLength(140)] + public string? GivenName { get; set; } + + [JsonPropertyName("surname")] + [MaxLength(140)] + public string? Surname { get; set; } + } + + public class Phone + { + [JsonPropertyName("phone_type")] + public string? PhoneType { get; set; } + + [JsonPropertyName("phone_number")] + public PhoneNumberType? PhoneNumber { get; set; } + } + + public class PhoneNumberType + { + [JsonPropertyName("national_number")] + public string? NationalNumber { get; set; } + } + + public class TaxInfo + { + [JsonPropertyName("tax_id")] + public string? TaxId { get; set; } + + [JsonPropertyName("tax_id_type")] + public string? TaxIdType { get; set; } + } + + [JsonPropertyName("name")] + public Name? NameInfo { get; set; } + + [JsonPropertyName("email_address")] + public string? EmailAddress { get; set; } + + [JsonPropertyName("payer_id")] + public string? PayerId { get; set; } + + [JsonPropertyName("phone")] + public Phone? PhoneInfo { get; set; } + + [JsonPropertyName("birth_date")] + public string? BirthDate { get; set; } + + [JsonPropertyName("tax_info")] + public TaxInfo? TaxInformation { get; set; } + + [JsonPropertyName("address")] + public Address? Address { get; set; } + + [JsonPropertyName("tenant")] + public string? Tenant { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/PaymentInstruction.cs b/Blazor.PayPal/PaymentInstruction.cs new file mode 100644 index 0000000..1404459 --- /dev/null +++ b/Blazor.PayPal/PaymentInstruction.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class PaymentInstruction +{ + [JsonPropertyName("platform_fees")] + public List? PlatformFees { get; set; } + + [JsonPropertyName("disbursement_mode")] + public string? DisbursementMode { get; set; } // Could also be an enum +} \ No newline at end of file diff --git a/Blazor.PayPal/PaymentMethod.cs b/Blazor.PayPal/PaymentMethod.cs new file mode 100644 index 0000000..d45aee1 --- /dev/null +++ b/Blazor.PayPal/PaymentMethod.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class PaymentMethod +{ + [JsonPropertyName("payer_selected")] + public string? PayerSelected { get; set; } + + [JsonPropertyName("payee_preferred")] + public string? PayeePreferred { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/PlatformFee.cs b/Blazor.PayPal/PlatformFee.cs new file mode 100644 index 0000000..a6f0428 --- /dev/null +++ b/Blazor.PayPal/PlatformFee.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class PlatformFee +{ + [JsonPropertyName("amount")] + public AmountWithCurrencyCodeOptional? Amount { get; set; } + + [JsonPropertyName("payee")] + public Payee? PayeeInfo { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/PurchaseItem.cs b/Blazor.PayPal/PurchaseItem.cs new file mode 100644 index 0000000..4c3d042 --- /dev/null +++ b/Blazor.PayPal/PurchaseItem.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class PurchaseItem +{ + [JsonPropertyName("name")] + public string? Name { get; set; } + + [JsonPropertyName("quantity")] + public string? Quantity { get; set; } + + [JsonPropertyName("unit_amount")] + public AmountWithCurrencyCodeOptional? UnitAmount { get; set; } + + [JsonPropertyName("tax")] + public AmountWithCurrencyCodeOptional? Tax { get; set; } + + [JsonPropertyName("description")] + public string? Description { get; set; } + + [JsonPropertyName("sku")] + public string? Sku { get; set; } + + [JsonPropertyName("category")] + public string? Category { get; set; } // Could also be an enum +} \ No newline at end of file diff --git a/Blazor.PayPal/PurchaseUnit.cs b/Blazor.PayPal/PurchaseUnit.cs new file mode 100644 index 0000000..d2054d9 --- /dev/null +++ b/Blazor.PayPal/PurchaseUnit.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class PurchaseUnit +{ + [JsonPropertyName("items")] + public List? Items { get; set; } + + [JsonPropertyName("reference_id")] + public string? ReferenceId { get; set; } + + [JsonPropertyName("amount")] + public AmountWithBreakdown? Amount { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/ShippingInfoBase.cs b/Blazor.PayPal/ShippingInfoBase.cs new file mode 100644 index 0000000..2023bfe --- /dev/null +++ b/Blazor.PayPal/ShippingInfoBase.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public abstract class ShippingInfoBase +{ + public class Name + { + [JsonPropertyName("full_name")] + public string? FullName { get; set; } + } + + public class PhoneNumber + { + [JsonPropertyName("national_number")] + public string? NationalNumber { get; set; } + } + + [JsonPropertyName("name")] + public Name? NameInfo { get; set; } + + [JsonPropertyName("email_address")] + public string? EmailAddress { get; set; } + + [JsonPropertyName("phone_number")] + public PhoneNumber? PhoneNumberInfo { get; set; } + + [JsonPropertyName("address")] + public Address? AddressInfo { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/ShippingInfoOption.cs b/Blazor.PayPal/ShippingInfoOption.cs new file mode 100644 index 0000000..5adda71 --- /dev/null +++ b/Blazor.PayPal/ShippingInfoOption.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class ShippingInfoOption +{ + [JsonPropertyName("id")] + [MaxLength(127)] + public string? Id { get; set; } + + [JsonPropertyName("label")] + public string? Label { get; set; } + + [JsonPropertyName("type")] + public string? Type { get; set; } + + [JsonPropertyName("amount")] + public AmountWithCurrencyCode? Amount { get; set; } + + [JsonPropertyName("selected")] + public bool Selected { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/ShippingInfoWithOptions.cs b/Blazor.PayPal/ShippingInfoWithOptions.cs new file mode 100644 index 0000000..236192f --- /dev/null +++ b/Blazor.PayPal/ShippingInfoWithOptions.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class ShippingInfoWithOptions : ShippingInfoBase +{ + [JsonPropertyName("options")] + public List? Options { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/ShippingInfoWithType.cs b/Blazor.PayPal/ShippingInfoWithType.cs new file mode 100644 index 0000000..1c9791d --- /dev/null +++ b/Blazor.PayPal/ShippingInfoWithType.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class ShippingInfoWithType : ShippingInfoBase +{ + [JsonPropertyName("type")] + public string? Type { get; set; } // Could also be an enum + + // No options for this type +} \ No newline at end of file diff --git a/Blazor.PayPal/UpdateOrderOperation.cs b/Blazor.PayPal/UpdateOrderOperation.cs new file mode 100644 index 0000000..b925135 --- /dev/null +++ b/Blazor.PayPal/UpdateOrderOperation.cs @@ -0,0 +1,15 @@ +using System.Text.Json.Serialization; + +namespace Blazor.PayPal; + +public class UpdateOrderOperation +{ + [JsonPropertyName("op")] + public string? Op { get; set; } + + [JsonPropertyName("path")] + public string? Path { get; set; } + + [JsonPropertyName("value")] + public Dictionary? Value { get; set; } +} \ No newline at end of file diff --git a/Blazor.PayPal/UpdateOrderRequestBody.cs b/Blazor.PayPal/UpdateOrderRequestBody.cs new file mode 100644 index 0000000..79d803c --- /dev/null +++ b/Blazor.PayPal/UpdateOrderRequestBody.cs @@ -0,0 +1,6 @@ +namespace Blazor.PayPal; + +public class UpdateOrderRequestBody : List +{ + // Inherits from a list of UpdateOrderOperation +} \ No newline at end of file