-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sara Vasquez <[email protected]> Co-authored-by: Debra Do <[email protected]>
- Loading branch information
1 parent
a80e296
commit a62595d
Showing
25 changed files
with
1,355 additions
and
29 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
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,148 @@ | ||
#pragma warning disable 1591 | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Braintree | ||
{ | ||
public class MetaCheckoutCard : PaymentMethod | ||
{ | ||
public virtual string Bin { get; protected set; } | ||
public virtual string CardholderName { get; protected set; } | ||
public virtual CreditCardCardType CardType { get; protected set; } | ||
public virtual CreditCardCommercial Commercial { get; protected set; } | ||
public virtual string ContainerId { get; protected set; } | ||
public virtual DateTime? CreatedAt { get; protected set; } | ||
public virtual string CustomerId { get; protected set; } | ||
public virtual CreditCardCustomerLocation CustomerLocation { get; protected set; } | ||
public virtual CreditCardDebit Debit { get; protected set; } | ||
public virtual CreditCardDurbinRegulated DurbinRegulated { get; protected set; } | ||
public virtual string ExpirationMonth { get; protected set; } | ||
public virtual string ExpirationYear { get; protected set; } | ||
public virtual CreditCardHealthcare Healthcare { get; protected set; } | ||
public virtual string ImageUrl { get; protected set; } | ||
public virtual bool? IsDefault { get; protected set; } | ||
public virtual bool? IsExpired { get; protected set; } | ||
public virtual string LastFour { get; protected set; } | ||
public virtual CreditCardPayroll Payroll { get; protected set; } | ||
public virtual CreditCardPrepaid Prepaid { get; protected set; } | ||
public virtual string Token { get; protected set; } | ||
public virtual string UniqueNumberIdentifier { get; protected set; } | ||
public virtual DateTime? UpdatedAt { get; protected set; } | ||
public virtual CreditCardVerification Verification { get; protected set; } | ||
|
||
private string _CountryOfIssuance; | ||
|
||
public virtual string CountryOfIssuance | ||
{ | ||
get | ||
{ | ||
if (_CountryOfIssuance == "") | ||
{ | ||
return CreditCard.CountryOfIssuanceUnknown; | ||
} | ||
else | ||
{ | ||
return _CountryOfIssuance; | ||
} | ||
} | ||
} | ||
|
||
private string _IssuingBank; | ||
|
||
public virtual string IssuingBank | ||
{ | ||
get | ||
{ | ||
if (_IssuingBank == "") | ||
{ | ||
return CreditCard.IssuingBankUnknown; | ||
} | ||
else | ||
{ | ||
return _IssuingBank; | ||
} | ||
} | ||
} | ||
|
||
private string _ProductId; | ||
|
||
public virtual string ProductId | ||
{ | ||
get | ||
{ | ||
if (_ProductId == "") | ||
{ | ||
return CreditCard.ProductIdUnknown; | ||
} | ||
else | ||
{ | ||
return _ProductId; | ||
} | ||
} | ||
} | ||
|
||
public virtual string ExpirationDate | ||
{ | ||
get => ExpirationMonth + "/" + ExpirationYear; | ||
protected set | ||
{ | ||
if (string.IsNullOrEmpty(value)) return; | ||
ExpirationMonth = value.Split('/')[0]; | ||
ExpirationYear = value.Split('/')[1]; | ||
} | ||
} | ||
|
||
public string MaskedNumber => $"{Bin}******{LastFour}"; | ||
|
||
protected internal MetaCheckoutCard(NodeWrapper node, IBraintreeGateway gateway) | ||
{ | ||
if (node == null) return; | ||
|
||
Bin = node.GetString("bin"); | ||
CardholderName = node.GetString("cardholder-name"); | ||
CardType = node.GetEnum("card-type", CreditCardCardType.UNRECOGNIZED); | ||
Commercial = node.GetEnum("commercial", CreditCardCommercial.UNKNOWN); | ||
ContainerId = node.GetString("container-id"); | ||
CustomerId = node.GetString("customer-id"); | ||
CustomerLocation = node.GetEnum("customer-location", CreditCardCustomerLocation.UNRECOGNIZED); | ||
CreatedAt = node.GetDateTime("created-at"); | ||
Debit = node.GetEnum("debit", CreditCardDebit.UNKNOWN); | ||
DurbinRegulated = node.GetEnum("durbin-regulated", CreditCardDurbinRegulated.UNKNOWN); | ||
ExpirationMonth = node.GetString("expiration-month"); | ||
ExpirationYear = node.GetString("expiration-year"); | ||
IsDefault = node.GetBoolean("default"); | ||
IsExpired = node.GetBoolean("expired"); | ||
LastFour = node.GetString("last-4"); | ||
Token = node.GetString("token"); | ||
UpdatedAt = node.GetDateTime("updated-at"); | ||
Prepaid = node.GetEnum("prepaid", CreditCardPrepaid.UNKNOWN); | ||
Payroll = node.GetEnum("payroll", CreditCardPayroll.UNKNOWN); | ||
Healthcare = node.GetEnum("healthcare", CreditCardHealthcare.UNKNOWN); | ||
UniqueNumberIdentifier = node.GetString("unique-number-identifier"); | ||
_CountryOfIssuance = node.GetString("country-of-issuance"); | ||
_IssuingBank = node.GetString("issuing-bank"); | ||
_ProductId = node.GetString("product-id"); | ||
ImageUrl = node.GetString("image-url"); | ||
|
||
var verificationNodes = node.GetList("verifications/verification"); | ||
Verification = FindLatestVerification(verificationNodes, gateway); | ||
} | ||
|
||
private CreditCardVerification FindLatestVerification(List<NodeWrapper> verificationNodes, IBraintreeGateway gateway) { | ||
if(verificationNodes.Count > 0) | ||
{ | ||
verificationNodes.Sort(delegate(NodeWrapper first, NodeWrapper second) { | ||
DateTime time1 = (DateTime)first.GetDateTime("created-at"); | ||
DateTime time2 = (DateTime)second.GetDateTime("created-at"); | ||
|
||
return DateTime.Compare(time2, time1); | ||
}); | ||
|
||
return new CreditCardVerification(verificationNodes[0], gateway); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
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,121 @@ | ||
using System; | ||
|
||
namespace Braintree | ||
{ | ||
public class MetaCheckoutCardDetails | ||
{ | ||
public virtual string Bin { get; protected set; } | ||
public virtual string CardholderName { get; protected set; } | ||
public virtual CreditCardCardType CardType { get; protected set; } | ||
public virtual CreditCardCommercial Commercial { get; protected set; } | ||
public virtual string ContainerId { get; protected set; } | ||
public virtual DateTime? CreatedAt { get; protected set; } | ||
public virtual CreditCardCustomerLocation CustomerLocation { get; protected set; } | ||
public virtual CreditCardDebit Debit { get; protected set; } | ||
public virtual CreditCardDurbinRegulated DurbinRegulated { get; protected set; } | ||
public virtual string ExpirationMonth { get; protected set; } | ||
public virtual string ExpirationYear { get; protected set; } | ||
public virtual CreditCardHealthcare Healthcare { get; protected set; } | ||
public virtual string ImageUrl { get; protected set; } | ||
public virtual bool? IsExpired { get; protected set; } | ||
public virtual string LastFour { get; protected set; } | ||
public virtual CreditCardPayroll Payroll { get; protected set; } | ||
public virtual CreditCardPrepaid Prepaid { get; protected set; } | ||
public virtual string Token { get; protected set; } | ||
public virtual string UniqueNumberIdentifier { get; protected set; } | ||
public virtual DateTime? UpdatedAt { get; protected set; } | ||
|
||
private string _CountryOfIssuance; | ||
|
||
public virtual string CountryOfIssuance | ||
{ | ||
get | ||
{ | ||
if (_CountryOfIssuance == "") | ||
{ | ||
return CreditCard.CountryOfIssuanceUnknown; | ||
} | ||
else | ||
{ | ||
return _CountryOfIssuance; | ||
} | ||
} | ||
} | ||
|
||
private string _IssuingBank; | ||
|
||
public virtual string IssuingBank | ||
{ | ||
get | ||
{ | ||
if (_IssuingBank == "") | ||
{ | ||
return CreditCard.IssuingBankUnknown; | ||
} | ||
else | ||
{ | ||
return _IssuingBank; | ||
} | ||
} | ||
} | ||
|
||
private string _ProductId; | ||
|
||
public virtual string ProductId | ||
{ | ||
get | ||
{ | ||
if (_ProductId == "") | ||
{ | ||
return CreditCard.ProductIdUnknown; | ||
} | ||
else | ||
{ | ||
return _ProductId; | ||
} | ||
} | ||
} | ||
|
||
public virtual string ExpirationDate | ||
{ | ||
get => ExpirationMonth + "/" + ExpirationYear; | ||
protected set | ||
{ | ||
if (string.IsNullOrEmpty(value)) return; | ||
ExpirationMonth = value.Split('/')[0]; | ||
ExpirationYear = value.Split('/')[1]; | ||
} | ||
} | ||
|
||
public string MaskedNumber => $"{Bin}******{LastFour}"; | ||
|
||
protected internal MetaCheckoutCardDetails(NodeWrapper node) | ||
{ | ||
if (node == null) return; | ||
|
||
Bin = node.GetString("bin"); | ||
ContainerId = node.GetString("container-id"); | ||
CardholderName = node.GetString("cardholder-name"); | ||
CardType = node.GetEnum("card-type", CreditCardCardType.UNRECOGNIZED); | ||
ExpirationMonth = node.GetString("expiration-month"); | ||
ExpirationYear = node.GetString("expiration-year"); | ||
IsExpired = node.GetBoolean("expired"); | ||
CustomerLocation = node.GetEnum("customer-location", CreditCardCustomerLocation.UNRECOGNIZED); | ||
LastFour = node.GetString("last-4"); | ||
UniqueNumberIdentifier = node.GetString("unique-number-identifier"); | ||
Token = node.GetString("token"); | ||
CreatedAt = node.GetDateTime("created-at"); | ||
UpdatedAt = node.GetDateTime("updated-at"); | ||
Prepaid = node.GetEnum("prepaid", CreditCardPrepaid.UNKNOWN); | ||
Payroll = node.GetEnum("payroll", CreditCardPayroll.UNKNOWN); | ||
DurbinRegulated = node.GetEnum("durbin-regulated", CreditCardDurbinRegulated.UNKNOWN); | ||
Debit = node.GetEnum("debit", CreditCardDebit.UNKNOWN); | ||
Commercial = node.GetEnum("commercial", CreditCardCommercial.UNKNOWN); | ||
Healthcare = node.GetEnum("healthcare", CreditCardHealthcare.UNKNOWN); | ||
_CountryOfIssuance = node.GetString("country-of-issuance"); | ||
_IssuingBank = node.GetString("issuing-bank"); | ||
_ProductId = node.GetString("product-id"); | ||
ImageUrl = node.GetString("image-url"); | ||
} | ||
} | ||
} |
Oops, something went wrong.