private async Task CreateDataAsync(UserId newUserId, TestDatabaseContext testDatabase, bool createOrigin)
        {
            var random = new Random();
            var user   = UserTests.UniqueEntity(random);

            user.Id = newUserId.Value;

            UserPaymentOrigin origin = null;

            if (createOrigin)
            {
                origin = new UserPaymentOrigin(
                    UserId.Value,
                    user,
                    PaymentOriginType,
                    PaymentOriginKeyType,
                    CountryCode,
                    CreditCardPrefix,
                    IpAddress,
                    TaxamoTransactionKey,
                    PaymentStatus);
            }

            using (var databaseContext = testDatabase.CreateContext())
            {
                databaseContext.Users.Add(user);
                if (createOrigin)
                {
                    databaseContext.UserPaymentOrigins.Add(origin);
                }

                await databaseContext.SaveChangesAsync();
            }
        }
        private async Task CreateDataAsync(UserId newUserId, TestDatabaseContext testDatabase, bool createOrigin)
        {
            var random = new Random();
            var user   = UserTests.UniqueEntity(random);

            user.Id = newUserId.Value;

            UserPaymentOrigin origin = null;

            if (createOrigin)
            {
                origin = new UserPaymentOrigin(
                    UserId.Value,
                    user,
                    "anotherStripeCustomerId",
                    PaymentOriginKeyType.Stripe,
                    "USA",
                    "999999",
                    "9.9.9.999",
                    "anotherKey",
                    PaymentStatus);
            }

            using (var databaseContext = testDatabase.CreateContext())
            {
                databaseContext.Users.Add(user);
                if (createOrigin)
                {
                    databaseContext.UserPaymentOrigins.Add(origin);
                }

                await databaseContext.SaveChangesAsync();
            }
        }
        public async Task ExecuteAsync(
            UserId userId,
            string paymentOriginKey,
            PaymentOriginKeyType paymentOriginKeyType,
            ValidCountryCode billingCountryCode,
            ValidCreditCardPrefix creditCardPrefix,
            ValidIpAddress ipAddress)
        {
            userId.AssertNotNull("userId");

            // The credit card has changed so the original transaction key can no longer be used for tax purposes
            // as it is based on the original card prefix.
            var origin = new UserPaymentOrigin(
                userId.Value,
                null,
                paymentOriginKey,
                paymentOriginKeyType,
                billingCountryCode == null ? null : billingCountryCode.Value,
                creditCardPrefix == null ? null : creditCardPrefix.Value,
                ipAddress == null ? null : ipAddress.Value,
                null,
                default(PaymentStatus));

            using (var connection = this.connectionFactory.CreateConnection())
            {
                await connection.UpsertAsync(
                    origin,
                    UserPaymentOrigin.Fields.PaymentOriginKey
                    | UserPaymentOrigin.Fields.PaymentOriginKeyType
                    | UserPaymentOrigin.Fields.CountryCode
                    | UserPaymentOrigin.Fields.CreditCardPrefix
                    | UserPaymentOrigin.Fields.IpAddress
                    | UserPaymentOrigin.Fields.OriginalTaxamoTransactionKey);
            }
        }
Exemple #4
0
        public async Task ExecuteAsync(UserId userId)
        {
            userId.AssertNotNull("userId");

            var origin = new UserPaymentOrigin(
                userId.Value,
                null,
                null,
                PaymentOriginKeyType.None,
                null,
                null,
                null,
                null,
                default(PaymentStatus));

            using (var connection = this.connectionFactory.CreateConnection())
            {
                await connection.UpsertAsync(
                    origin,
                    UserPaymentOrigin.Fields.PaymentOriginKey | UserPaymentOrigin.Fields.PaymentOriginKeyType);
            }
        }
Exemple #5
0
        public async Task ExecuteAsync(
            UserId userId,
            string originalTaxamoTransactionKey)
        {
            userId.AssertNotNull("userId");
            originalTaxamoTransactionKey.AssertNotNull("originalTaxamoTransactionKey");

            var origin = new UserPaymentOrigin(
                userId.Value,
                null,
                null,
                default(PaymentOriginKeyType),
                null,
                null,
                null,
                originalTaxamoTransactionKey,
                default(PaymentStatus));

            using (var connection = this.connectionFactory.CreateConnection())
            {
                await connection.UpsertAsync(origin, UserPaymentOrigin.Fields.OriginalTaxamoTransactionKey);
            }
        }