IGatewayPaymentProfile GetOrCreateCustomerPaymentProfile(IGatewayProfile gatewayProfile, IPaymentData data) { IGatewayPaymentProfile result = null; if (gatewayProfile.PaymentProfiles != null && gatewayProfile.PaymentProfiles.Count > 0) { var lastFour = data.CardData.CardNumber.Substring(data.CardData.CardNumber.Length - 4); var paymentProfileMatch = gatewayProfile.PaymentProfiles.SingleOrDefault(n => n.PaymentCardData.MaskedCardNumber.Contains(lastFour)); if (paymentProfileMatch != null) result = paymentProfileMatch; } if (result == null) { result = GetOrCreateCustomerPaymentProfile(data, long.Parse(gatewayProfile.Id)); } return result; }
public static IGatewayProfile GetGatewayProfile(IGatewayProfile profile) { IProfileCreditCardGateway target = _Container.GetNewProfileCreditCardGateway(); return target.GetCustomerProfile(profile.Id); }