-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
897 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Runtime.Serialization; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
namespace PCPServerSDKDotNet.Models | ||
{ | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum ApplePaymentTokenVersion | ||
{ | ||
[EnumMember(Value = "EC_V1")] | ||
EcV1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
namespace PCPServerSDKDotNet.Models | ||
{ | ||
[JsonConverter(typeof(StringEnumConverter))] | ||
public enum NetworkEnum | ||
{ | ||
[JsonProperty("MASTERCARD")] | ||
Mastercard, | ||
|
||
[JsonProperty("VISA")] | ||
Visa, | ||
|
||
[JsonProperty("AMEX")] | ||
Amex, | ||
|
||
[JsonProperty("GIROCARD")] | ||
Girocard, | ||
|
||
[JsonProperty("DISCOVER")] | ||
Discover, | ||
|
||
[JsonProperty("JCB")] | ||
Jcb | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PCPServerSDKDotNet.Models.ApplePay | ||
{ | ||
/// <summary> | ||
/// The result of authorizing a payment request that contains payment information. | ||
/// Data in PaymentToken is encrypted. Billing and shipping contact data are not encrypted. | ||
/// </summary> | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public class ApplePayPayment | ||
{ | ||
[JsonPropertyName("token")] | ||
[JsonInclude] | ||
public ApplePayPaymentToken Token { get; set; } | ||
|
||
[JsonPropertyName("billingContact")] | ||
[JsonInclude] | ||
public ApplePayPaymentContact BillingContact { get; set; } | ||
|
||
[JsonPropertyName("shippingContact")] | ||
[JsonInclude] | ||
public ApplePayPaymentContact ShippingContact { get; set; } | ||
|
||
public ApplePayPayment() { } | ||
|
||
public ApplePayPayment(ApplePayPaymentToken token, ApplePayPaymentContact billingContact, ApplePayPaymentContact shippingContact) | ||
{ | ||
Token = token; | ||
BillingContact = billingContact; | ||
ShippingContact = shippingContact; | ||
} | ||
|
||
public ApplePayPayment WithToken(ApplePayPaymentToken token) | ||
{ | ||
Token = token; | ||
return this; | ||
} | ||
|
||
public ApplePayPayment WithBillingContact(ApplePayPaymentContact billingContact) | ||
{ | ||
BillingContact = billingContact; | ||
return this; | ||
} | ||
|
||
public ApplePayPayment WithShippingContact(ApplePayPaymentContact shippingContact) | ||
{ | ||
ShippingContact = shippingContact; | ||
return this; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
Check warning on line 51 in lib/PCPServerSDKDotNet/Models/applepay/ApplePayPayment.cs GitHub Actions / test
|
||
{ | ||
return obj is ApplePayPayment payment && | ||
EqualityComparer<ApplePayPaymentToken>.Default.Equals(Token, payment.Token) && | ||
EqualityComparer<ApplePayPaymentContact>.Default.Equals(BillingContact, payment.BillingContact) && | ||
EqualityComparer<ApplePayPaymentContact>.Default.Equals(ShippingContact, payment.ShippingContact); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return HashCode.Combine(Token, BillingContact, ShippingContact); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
var sb = new System.Text.StringBuilder(); | ||
sb.Append("class Payment {\n"); | ||
sb.Append(" token: ").Append(ToIndentedString(Token)).Append("\n"); | ||
sb.Append(" billingContact: ").Append(ToIndentedString(BillingContact)).Append("\n"); | ||
sb.Append(" shippingContact: ").Append(ToIndentedString(ShippingContact)).Append("\n"); | ||
sb.Append("}"); | ||
return sb.ToString(); | ||
} | ||
|
||
private string ToIndentedString(object obj) | ||
{ | ||
if (obj == null) | ||
{ | ||
return "null"; | ||
} | ||
return obj.ToString().Replace("\n", "\n "); | ||
} | ||
} | ||
} |
208 changes: 208 additions & 0 deletions
208
lib/PCPServerSDKDotNet/Models/applepay/ApplePayPaymentContact.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PCPServerSDKDotNet.Models.ApplePay | ||
{ | ||
/// <summary> | ||
/// The result of authorizing a payment request that contains payment information. | ||
/// Data in PaymentToken is encrypted. Billing and shipping contact data are not encrypted. | ||
/// </summary> | ||
public class ApplePayPaymentContact : IEquatable<ApplePayPaymentContact> | ||
{ | ||
[JsonProperty("phoneNumber")] | ||
public string PhoneNumber { get; set; } | ||
|
||
[JsonProperty("emailAddress")] | ||
public string EmailAddress { get; set; } | ||
|
||
[JsonProperty("givenName")] | ||
public string GivenName { get; set; } | ||
|
||
[JsonProperty("familyName")] | ||
public string FamilyName { get; set; } | ||
|
||
[JsonProperty("phoneticGivenName")] | ||
public string PhoneticGivenName { get; set; } | ||
|
||
[JsonProperty("phoneticFamilyName")] | ||
public string PhoneticFamilyName { get; set; } | ||
|
||
[JsonProperty("addressLines")] | ||
public List<string> AddressLines { get; set; } | ||
|
||
[JsonProperty("locality")] | ||
public string Locality { get; set; } | ||
|
||
[JsonProperty("postalCode")] | ||
public string PostalCode { get; set; } | ||
|
||
[JsonProperty("administrativeArea")] | ||
public string AdministrativeArea { get; set; } | ||
|
||
[JsonProperty("subAdministrativeArea")] | ||
public string SubAdministrativeArea { get; set; } | ||
|
||
[JsonProperty("country")] | ||
public string Country { get; set; } | ||
|
||
[JsonProperty("countryCode")] | ||
public string CountryCode { get; set; } | ||
|
||
public ApplePayPaymentContact() { } | ||
|
||
public ApplePayPaymentContact(string phoneNumber, string emailAddress, string givenName, string familyName, | ||
string phoneticGivenName, string phoneticFamilyName, List<string> addressLines, | ||
string locality, string postalCode, string administrativeArea, | ||
string subAdministrativeArea, string country, string countryCode) | ||
{ | ||
PhoneNumber = phoneNumber; | ||
EmailAddress = emailAddress; | ||
GivenName = givenName; | ||
FamilyName = familyName; | ||
PhoneticGivenName = phoneticGivenName; | ||
PhoneticFamilyName = phoneticFamilyName; | ||
AddressLines = addressLines; | ||
Locality = locality; | ||
PostalCode = postalCode; | ||
AdministrativeArea = administrativeArea; | ||
SubAdministrativeArea = subAdministrativeArea; | ||
Country = country; | ||
CountryCode = countryCode; | ||
} | ||
|
||
public ApplePayPaymentContact WithPhoneNumber(string phoneNumber) | ||
{ | ||
PhoneNumber = phoneNumber; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithEmailAddress(string emailAddress) | ||
{ | ||
EmailAddress = emailAddress; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithGivenName(string givenName) | ||
{ | ||
GivenName = givenName; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithFamilyName(string familyName) | ||
{ | ||
FamilyName = familyName; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithPhoneticGivenName(string phoneticGivenName) | ||
{ | ||
PhoneticGivenName = phoneticGivenName; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithPhoneticFamilyName(string phoneticFamilyName) | ||
{ | ||
PhoneticFamilyName = phoneticFamilyName; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithAddressLines(List<string> addressLines) | ||
{ | ||
AddressLines = addressLines; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithLocality(string locality) | ||
{ | ||
Locality = locality; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithPostalCode(string postalCode) | ||
{ | ||
PostalCode = postalCode; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithAdministrativeArea(string administrativeArea) | ||
{ | ||
AdministrativeArea = administrativeArea; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithSubAdministrativeArea(string subAdministrativeArea) | ||
{ | ||
SubAdministrativeArea = subAdministrativeArea; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithCountry(string country) | ||
{ | ||
Country = country; | ||
return this; | ||
} | ||
|
||
public ApplePayPaymentContact WithCountryCode(string countryCode) | ||
{ | ||
CountryCode = countryCode; | ||
return this; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
Check warning on line 150 in lib/PCPServerSDKDotNet/Models/applepay/ApplePayPaymentContact.cs GitHub Actions / test
|
||
{ | ||
return Equals(obj as ApplePayPaymentContact); | ||
} | ||
|
||
public bool Equals(ApplePayPaymentContact other) | ||
Check warning on line 155 in lib/PCPServerSDKDotNet/Models/applepay/ApplePayPaymentContact.cs GitHub Actions / test
Check warning on line 155 in lib/PCPServerSDKDotNet/Models/applepay/ApplePayPaymentContact.cs GitHub Actions / test
|
||
{ | ||
return other != null && | ||
PhoneNumber == other.PhoneNumber && | ||
EmailAddress == other.EmailAddress && | ||
GivenName == other.GivenName && | ||
FamilyName == other.FamilyName && | ||
PhoneticGivenName == other.PhoneticGivenName && | ||
PhoneticFamilyName == other.PhoneticFamilyName && | ||
EqualityComparer<List<string>>.Default.Equals(AddressLines, other.AddressLines) && | ||
Locality == other.Locality && | ||
PostalCode == other.PostalCode && | ||
AdministrativeArea == other.AdministrativeArea && | ||
SubAdministrativeArea == other.SubAdministrativeArea && | ||
Country == other.Country && | ||
CountryCode == other.CountryCode; | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
int hash = HashCode.Combine(PhoneNumber, EmailAddress, GivenName, FamilyName, PhoneticGivenName, PhoneticFamilyName, AddressLines, Locality); | ||
hash = HashCode.Combine(hash, PostalCode, AdministrativeArea, SubAdministrativeArea, Country, CountryCode); | ||
return hash; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"class ApplePayPaymentContact {{\n" + | ||
$" phoneNumber: {ToIndentedString(PhoneNumber)},\n" + | ||
$" emailAddress: {ToIndentedString(EmailAddress)},\n" + | ||
$" givenName: {ToIndentedString(GivenName)},\n" + | ||
$" familyName: {ToIndentedString(FamilyName)},\n" + | ||
$" phoneticGivenName: {ToIndentedString(PhoneticGivenName)},\n" + | ||
$" phoneticFamilyName: {ToIndentedString(PhoneticFamilyName)},\n" + | ||
$" addressLines: {ToIndentedString(AddressLines)},\n" + | ||
$" locality: {ToIndentedString(Locality)},\n" + | ||
$" postalCode: {ToIndentedString(PostalCode)},\n" + | ||
$" administrativeArea: {ToIndentedString(AdministrativeArea)},\n" + | ||
$" subAdministrativeArea: {ToIndentedString(SubAdministrativeArea)},\n" + | ||
$" country: {ToIndentedString(Country)},\n" + | ||
$" countryCode: {ToIndentedString(CountryCode)}\n" + | ||
$"}}"; | ||
} | ||
|
||
private string ToIndentedString(object o) | ||
{ | ||
if (o == null) | ||
{ | ||
return "null"; | ||
} | ||
return o.ToString().Replace("\n", "\n "); | ||
} | ||
} | ||
} |
Oops, something went wrong.