public async Task<ActionResult> Create(SubscriptionRequestModel subscriptionRequestModel) { if (this.ModelState.IsValid) { SubscriptionRequest subscriptionRequest = new SubscriptionRequest(); subscriptionRequest.Amount = subscriptionRequestModel.Amount; subscriptionRequest.Description = subscriptionRequestModel.Description; subscriptionRequest.Interval = "14 days"; await this._mollieClient.CreateSubscriptionAsync(subscriptionRequestModel.CustomerId, subscriptionRequest); return this.RedirectToAction("Index", new { customerId = subscriptionRequestModel.CustomerId }); } return this.View(subscriptionRequestModel); }
public void CanCreateSubscription() { // Given string customerId = this.GetFirstCustomerWithValidMandate(); SubscriptionRequest subscriptionRequest = new SubscriptionRequest(); subscriptionRequest.Amount = 100; subscriptionRequest.Times = 5; subscriptionRequest.Interval = "1 month"; subscriptionRequest.Description = $"Subscription {DateTime.Now}"; // Subscriptions must have a unique name subscriptionRequest.WebhookUrl = "http://www.google.nl"; subscriptionRequest.StartDate = DateTime.Now.AddDays(1); // When SubscriptionResponse subscriptionResponse = this._mollieClient.CreateSubscriptionAsync(customerId, subscriptionRequest).Result; // Then Assert.AreEqual(subscriptionRequest.Amount, subscriptionResponse.Amount); Assert.AreEqual(subscriptionRequest.Times, subscriptionResponse.Times); Assert.AreEqual(subscriptionRequest.Interval, subscriptionResponse.Interval); Assert.AreEqual(subscriptionRequest.Description, subscriptionResponse.Description); Assert.AreEqual(subscriptionRequest.WebhookUrl, subscriptionResponse.Links.WebhookUrl); Assert.AreEqual(subscriptionRequest.StartDate.Value.Date, subscriptionResponse.StartDate); }