Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-drewery committed Dec 18, 2023
1 parent 3632476 commit 0ca9245
Show file tree
Hide file tree
Showing 26 changed files with 486 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
.idea/
24 changes: 24 additions & 0 deletions Blazor.PayPal/Address.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
33 changes: 33 additions & 0 deletions Blazor.PayPal/AmountWithBreakdown.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
12 changes: 12 additions & 0 deletions Blazor.PayPal/AmountWithCurrencyCode.cs
Original file line number Diff line number Diff line change
@@ -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
}
12 changes: 12 additions & 0 deletions Blazor.PayPal/AmountWithCurrencyCodeOptional.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
13 changes: 13 additions & 0 deletions Blazor.PayPal/Blazor.PayPal.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.0" />
</ItemGroup>

</Project>
21 changes: 21 additions & 0 deletions Blazor.PayPal/CreateOrderRequestBody.cs
Original file line number Diff line number Diff line change
@@ -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<PurchaseUnit>? PurchaseUnits { get; set; }

[JsonPropertyName("payer")]
public Payer? Payer { get; set; }

[JsonPropertyName("application_context")]
public OrderApplicationContext? ApplicationContext { get; set; }

[JsonPropertyName("payment_source")]
public Dictionary<string, object>? PaymentSource { get; set; }
}
21 changes: 21 additions & 0 deletions Blazor.PayPal/CreditFinancingOffer.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
15 changes: 15 additions & 0 deletions Blazor.PayPal/InstallmentDetails.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
15 changes: 15 additions & 0 deletions Blazor.PayPal/LinkDescription.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
21 changes: 21 additions & 0 deletions Blazor.PayPal/OrderApplicationContext.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
33 changes: 33 additions & 0 deletions Blazor.PayPal/OrderResponseBody.cs
Original file line number Diff line number Diff line change
@@ -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<PurchaseUnit>? PurchaseUnits { get; set; }

[JsonPropertyName("processing_instruction")]
public string? ProcessingInstruction { get; set; }

[JsonPropertyName("payment_source")]
public Dictionary<string, object>? PaymentSource { get; set; }

[JsonPropertyName("expiration_time")]
public string? ExpirationTime { get; set; }

[JsonPropertyName("credit_financing_offer")]
public CreditFinancingOffer? CreditFinancingOffer { get; set; }
}
15 changes: 15 additions & 0 deletions Blazor.PayPal/OrderResponseBodyMinimal.cs
Original file line number Diff line number Diff line change
@@ -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<LinkDescription>? Links { get; set; }
}
12 changes: 12 additions & 0 deletions Blazor.PayPal/Payee.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
66 changes: 66 additions & 0 deletions Blazor.PayPal/Payer.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
12 changes: 12 additions & 0 deletions Blazor.PayPal/PaymentInstruction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;

namespace Blazor.PayPal;

public class PaymentInstruction
{
[JsonPropertyName("platform_fees")]
public List<PlatformFee>? PlatformFees { get; set; }

[JsonPropertyName("disbursement_mode")]
public string? DisbursementMode { get; set; } // Could also be an enum
}
12 changes: 12 additions & 0 deletions Blazor.PayPal/PaymentMethod.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
12 changes: 12 additions & 0 deletions Blazor.PayPal/PlatformFee.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
Loading

0 comments on commit 0ca9245

Please sign in to comment.