diff --git a/PaymillWrapper/Properties/AssemblyInfo.cs b/PaymillWrapper/Properties/AssemblyInfo.cs index 81f189c..7348616 100644 --- a/PaymillWrapper/Properties/AssemblyInfo.cs +++ b/PaymillWrapper/Properties/AssemblyInfo.cs @@ -34,5 +34,5 @@ // Puede especificar todos los valores o establecer como predeterminados los números de compilación y de revisión // mediante el carácter '*', como se muestra a continuación: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.1.2")] -[assembly: AssemblyFileVersion("0.3.1.2")] +[assembly: AssemblyVersion("0.3.2.0")] +[assembly: AssemblyFileVersion("0.3.2.0")] diff --git a/PaymillWrapper/Service/AbstractService.cs b/PaymillWrapper/Service/AbstractService.cs index 73a5890..fd21257 100644 --- a/PaymillWrapper/Service/AbstractService.cs +++ b/PaymillWrapper/Service/AbstractService.cs @@ -256,6 +256,7 @@ private static Task<String> readReponseMessage(HttpResponseMessage response) { throw new PaymillException(exc.Message); } + // For .Net 4.0 use the code bellow /* return Task.Run(() => { return String.Empty; diff --git a/PaymillWrapper/Service/SubscriptionService.cs b/PaymillWrapper/Service/SubscriptionService.cs index 4b9a9a1..91deea9 100644 --- a/PaymillWrapper/Service/SubscriptionService.cs +++ b/PaymillWrapper/Service/SubscriptionService.cs @@ -56,10 +56,10 @@ public SubscriptionService(HttpClient client, string apiUrl) /// <param name="the subscription"></param> // <returns>the subscription.</returns> - public async Task<Subscription> CreateAsync(PaymillWrapper.Models.Subscription.Creator creator, String mandateReference = null) + public async Task<Subscription> CreateAsync(PaymillWrapper.Models.Subscription.Creator creator) { return await CreateAsync(creator.Payment, creator.Client, creator.Offer, creator.Amount, creator.Currency, creator.Interval, - creator.StartAt, creator.Name, creator.PeriodOfValidity, mandateReference); + creator.StartAt, creator.Name, creator.PeriodOfValidity, null); } /// <summary> /// This function creates a <see cref="Subscription" /> between a <see cref="Client" /> and an <see cref="Offer" />. A <see cref="Client" /> can have several @@ -90,7 +90,7 @@ public async Task<Subscription> CreateAsync(PaymillWrapper.Models.Subscription.C /// <returns>the subscription.</returns> /// public async Task<Subscription> CreateAsync(Payment payment, Client client, Offer offer, int? amount, String currency, Interval.PeriodWithChargeDay interval, DateTime? startAt, - String name, Interval.Period periodOfValidity, String mandateReference = null) + String name, Interval.Period periodOfValidity, String mandateReference) { if (offer == null && (amount == null || currency == null || interval == null)) @@ -170,9 +170,9 @@ public async Task<Subscription> CreateAsync(Payment payment, Client client, Offe /// <returns>the subscription</returns> /// public async Task<Subscription> CreateAsync(String paymentId, String clientId, String offerId, int? amount, String currency, Interval.PeriodWithChargeDay interval, - DateTime? startAt, String name, Interval.Period periodOfValidity, String mandateReference = null) + DateTime? startAt, String name, Interval.Period periodOfValidity) { - return await CreateAsync(new Payment(paymentId), new Client(clientId), new Offer(offerId), amount, currency, interval, startAt, name, periodOfValidity, mandateReference); + return await CreateAsync(new Payment(paymentId), new Client(clientId), new Offer(offerId), amount, currency, interval, startAt, name, periodOfValidity, null); } /// <summary> diff --git a/PaymillWrapper/Service/TransactionService.cs b/PaymillWrapper/Service/TransactionService.cs index 8b98846..6bb3291 100644 --- a/PaymillWrapper/Service/TransactionService.cs +++ b/PaymillWrapper/Service/TransactionService.cs @@ -22,9 +22,9 @@ public TransactionService(HttpClient client, string apiUrl) /// <param name="amount"> Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithTokenAsync(String token, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithTokenAsync(String token, int amount, String currency) { - return await CreateWithTokenAndFeeAsync(token, amount, currency, null, null, mandateReference); + return await CreateWithTokenAndFeeAsync(token, amount, currency, null, null, null); } /// <summary> @@ -35,9 +35,9 @@ public async Task<Transaction> CreateWithTokenAsync(String token, int amount, St /// <param name="currency"> ISO 4217 formatted currency code.</param> /// <param name="description">A short description for the transaction.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithTokenAsync(String token, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithTokenAsync(String token, int amount, String currency, String description) { - return await CreateWithTokenAndFeeAsync(token, amount, currency, description, null, mandateReference); + return await CreateWithTokenAndFeeAsync(token, amount, currency, description, null, null); } /// <summary> @@ -48,9 +48,9 @@ public async Task<Transaction> CreateWithTokenAsync(String token, int amount, St /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="fee">A Fee</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithTokenAndFeeAsync(String token, int amount, String currency, Fee fee, String mandateReference = null) + public async Task<Transaction> CreateWithTokenAndFeeAsync(String token, int amount, String currency, Fee fee) { - return await CreateWithTokenAndFeeAsync(token, amount, currency, null, fee, mandateReference); + return await CreateWithTokenAndFeeAsync(token, amount, currency, null, fee, null); } /// <summary> @@ -63,7 +63,7 @@ public async Task<Transaction> CreateWithTokenAndFeeAsync(String token, int amou /// <param name="fee">A Fee</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> public async Task<Transaction> CreateWithTokenAndFeeAsync(String token, int amount, - String currency, String description, Fee fee, String mandateReference = null) + String currency, String description, Fee fee, String mandateReference) { ValidationUtils.ValidatesToken(token); ValidationUtils.ValidatesAmount(amount); @@ -92,9 +92,9 @@ public async Task<Transaction> CreateWithTokenAndFeeAsync(String token, int amou /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAsync(Payment payment, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAsync(Payment payment, int amount, String currency) { - return await CreateWithPaymentAsync(payment, amount, currency, null, mandateReference); + return await CreateWithPaymentAsync(payment, amount, currency, null, null); } /// <summary> @@ -104,9 +104,9 @@ public async Task<Transaction> CreateWithPaymentAsync(Payment payment, int amoun /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAsync(String paymentId, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAsync(String paymentId, int amount, String currency) { - return await CreateWithPaymentAsync(new Payment(paymentId), amount, currency, null, mandateReference); + return await CreateWithPaymentAsync(new Payment(paymentId), amount, currency, null, null); } /// <summary> @@ -117,7 +117,7 @@ public async Task<Transaction> CreateWithPaymentAsync(String paymentId, int amou /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAsync(Payment payment, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAsync(Payment payment, int amount, String currency, String description, String mandateReference) { ValidationUtils.ValidatesPayment(payment); ValidationUtils.ValidatesAmount(amount); @@ -142,9 +142,9 @@ public async Task<Transaction> CreateWithPaymentAsync(Payment payment, int amoun /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAsync(String paymentId, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAsync(String paymentId, int amount, String currency, String description) { - return await CreateWithPaymentAsync(new Payment(paymentId), amount, currency, description, mandateReference); + return await CreateWithPaymentAsync(new Payment(paymentId), amount, currency, description, null); } /// <summary> @@ -155,9 +155,9 @@ public async Task<Transaction> CreateWithPaymentAsync(String paymentId, int amou /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAndClientAsync(Payment payment, Client client, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAndClientAsync(Payment payment, Client client, int amount, String currency) { - return await CreateWithPaymentAndClientAsync(payment, client, amount, currency, null, mandateReference); + return await CreateWithPaymentAndClientAsync(payment, client, amount, currency, null, null); } /// <summary> @@ -168,9 +168,9 @@ public async Task<Transaction> CreateWithPaymentAndClientAsync(Payment payment, /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAndClientAsync(String paymentId, String clientId, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAndClientAsync(String paymentId, String clientId, int amount, String currency) { - return await CreateWithPaymentAndClientAsync(paymentId, clientId, amount, currency, null, mandateReference); + return await CreateWithPaymentAndClientAsync(paymentId, clientId, amount, currency, null); } /// <summary> @@ -182,7 +182,7 @@ public async Task<Transaction> CreateWithPaymentAndClientAsync(String paymentId, /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAndClientAsync(Payment payment, Client client, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAndClientAsync(Payment payment, Client client, int amount, String currency, String description, String mandateReference) { ValidationUtils.ValidatesPayment(payment); ValidationUtils.ValidatesClient(client); @@ -212,9 +212,9 @@ public async Task<Transaction> CreateWithPaymentAndClientAsync(Payment payment, /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPaymentAndClientAsync(String paymentId, String clientId, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithPaymentAndClientAsync(String paymentId, String clientId, int amount, String currency, String description) { - return await CreateWithPaymentAndClientAsync(new Payment(paymentId), new Client(clientId), amount, currency, mandateReference); + return await CreateWithPaymentAndClientAsync(new Payment(paymentId), new Client(clientId), amount, currency); } /// <summary> @@ -224,9 +224,9 @@ public async Task<Transaction> CreateWithPaymentAndClientAsync(String paymentId, /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPreauthorizationAsync(Preauthorization preauthorization, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithPreauthorizationAsync(Preauthorization preauthorization, int amount, String currency) { - return await CreateWithPreauthorizationAsync(preauthorization.Id, amount, currency, null, mandateReference); + return await CreateWithPreauthorizationAsync(preauthorization.Id, amount, currency, null, null); } /// <summary> @@ -236,9 +236,9 @@ public async Task<Transaction> CreateWithPreauthorizationAsync(Preauthorization /// <param name="amount">Amount (in cents) which will be charged.</param> /// <param name="currency">ISO 4217 formatted currency code.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPreauthorizationAsync(String preauthorizationId, int amount, String currency, String mandateReference = null) + public async Task<Transaction> CreateWithPreauthorizationAsync(String preauthorizationId, int amount, String currency) { - return await CreateWithPreauthorizationAsync(preauthorizationId, amount, currency, null, mandateReference); + return await CreateWithPreauthorizationAsync(preauthorizationId, amount, currency, null, null); } /// <summary> @@ -249,9 +249,9 @@ public async Task<Transaction> CreateWithPreauthorizationAsync(String preauthori /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPreauthorizationAsync(Preauthorization preauthorization, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithPreauthorizationAsync(Preauthorization preauthorization, int amount, String currency, String description) { - return await CreateWithPreauthorizationAsync(preauthorization.Id, amount, currency, description, mandateReference); + return await CreateWithPreauthorizationAsync(preauthorization.Id, amount, currency, description, null); } /// <summary> @@ -262,7 +262,7 @@ public async Task<Transaction> CreateWithPreauthorizationAsync(Preauthorization /// <param name="currency">ISO 4217 formatted currency code.</param> /// <param name="description">The description.</param> /// <returns>Transaction object indicating whether a the call was successful or not.</returns> - public async Task<Transaction> CreateWithPreauthorizationAsync(String preauthorizationId, int amount, String currency, String description, String mandateReference = null) + public async Task<Transaction> CreateWithPreauthorizationAsync(String preauthorizationId, int amount, String currency, String description, String mandateReference) { ValidationUtils.ValidatesId(preauthorizationId); ValidationUtils.ValidatesAmount(amount); diff --git a/README.md b/README.md index 3bd0d96..f6dfc89 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,10 @@ Because all methods of Wrapper for the PAYMILL API is asynchronous. To catch rea ## Changelog +### 3.2.0 ++ Added Mandate Reference to Transaction and Subscription ++ Made the Payment Property Updatable in Subscription + ### 3.1.2 + Implemented StringToBaseModelConverter to support custom serialization. diff --git a/UnitTest/Net/TestSubscriptions.cs b/UnitTest/Net/TestSubscriptions.cs index 4a8ef1c..35de182 100644 --- a/UnitTest/Net/TestSubscriptions.cs +++ b/UnitTest/Net/TestSubscriptions.cs @@ -50,7 +50,7 @@ public void TestCreateWithPaymentAndOfferAndMandateReference() { Payment payment = _paymill.PaymentService.CreateWithTokenAsync(testToken).Result; Offer offer = _paymill.OfferService.CreateAsync(2223, "EUR", Interval.period(1, Interval.TypeUnit.WEEK), "Offer No Trial").Result; - Subscription subscription = _paymill.SubscriptionService.CreateAsync(Subscription.Create(payment, offer), "DE1234TEST").Result; + Subscription subscription = _paymill.SubscriptionService.CreateAsync(Subscription.Create(payment, offer)).Result; Assert.IsNotNull(subscription); Assert.IsNotNull(subscription.Client); Assert.AreEqual(subscription.Payment.Id, payment.Id); @@ -102,7 +102,7 @@ public void TestCreateWithoutOfferAndAmount_ShouldFail() { Client client = _paymill.ClientService.CreateWithEmailAsync("zendest@example.com").Result; Payment payment = _paymill.PaymentService.CreateWithTokenAndClientAsync(testToken, client).Result; - _paymill.SubscriptionService.CreateAsync(payment, client, null, null, null, null, null, null, null).Wait(); + _paymill.SubscriptionService.CreateAsync(payment, client, null, null, null, null, null, null, null, "DE1234TEST").Wait(); } [TestMethod] public void TestCreateWithPaymentAndClient_WithOfferWithoutTrial_shouldReturnSubscriptionWithNullTrialStartAndNullTrialEnd() diff --git a/UnitTest/Net/TestTransactions.cs b/UnitTest/Net/TestTransactions.cs index 4e6410c..cf9d957 100644 --- a/UnitTest/Net/TestTransactions.cs +++ b/UnitTest/Net/TestTransactions.cs @@ -49,7 +49,7 @@ public void CreateTransactionWithPayment() public void CreateTransactionWithPaymentAndMandateReference() { Payment payment = _paymill.PaymentService.CreateWithTokenAsync(testToken).Result; - Transaction transaction = _paymill.TransactionService.CreateWithPaymentAsync(payment, 3500, "USD", "DE1234TEST").Result; + Transaction transaction = _paymill.TransactionService.CreateWithPaymentAsync(payment, 3500, "USD", "Bar boo", "DE1234TEST").Result; Assert.IsFalse(String.IsNullOrEmpty(transaction.Id)); Assert.IsFalse(transaction.Currency == "EUR"); Assert.IsTrue(transaction.Currency == "USD"); @@ -73,7 +73,7 @@ public void CreateTransactionWithPaymentId() public void CreateTransactionWithPaymentIdAndMandateReference() { Payment payment = _paymill.PaymentService.CreateWithTokenAsync(testToken).Result; - Transaction transaction = _paymill.TransactionService.CreateWithPaymentAsync(payment.Id, 4500, "USD", "Bar boo", "DE1234TEST").Result; + Transaction transaction = _paymill.TransactionService.CreateWithPaymentAsync(payment.Id, 4500, "USD", "Bar boo").Result; Assert.IsFalse(String.IsNullOrEmpty(transaction.Id)); Assert.IsFalse(transaction.Currency == "EUR"); Assert.IsTrue(transaction.Currency == "USD"); @@ -115,7 +115,7 @@ public void CreateTransactionWithPaymentAndClientAndDescrition() { Client client = _paymill.ClientService.CreateAsync().Result; Payment payment = _paymill.PaymentService.CreateWithTokenAndClientAsync(testToken, client).Result; - Transaction transaction = _paymill.TransactionService.CreateWithPaymentAndClientAsync(payment, client, 4200, "EUR", "Bar bar").Result; + Transaction transaction = _paymill.TransactionService.CreateWithPaymentAndClientAsync(payment, client, 4200, "EUR", "Bar bar", null).Result; Assert.IsFalse(String.IsNullOrEmpty(transaction.Id)); Assert.IsTrue(transaction.Currency == "EUR"); Assert.IsTrue(transaction.Amount == 4200); @@ -185,7 +185,7 @@ public void GetTransactionsById() public void UpdateTransaction() { Payment payment = _paymill.PaymentService.CreateWithTokenAsync(testToken).Result; - Transaction transaction = _paymill.TransactionService.CreateWithPaymentAsync(payment, 3500, "EUR", "Test API C#").Result; + Transaction transaction = _paymill.TransactionService.CreateWithPaymentAsync(payment, 3500, "EUR", "Test API C#", null).Result; transaction.Client = _paymill.ClientService.CreateWithEmailAndDescriptionAsync("lovely-client@example.com", "Test API").Result; Assert.IsTrue(transaction.Id != String.Empty, "Create Transaction Fail"); diff --git a/examples/WebApplication/WebApplication/Default.aspx.cs b/examples/WebApplication/WebApplication/Default.aspx.cs index dfff95d..b51eff7 100644 --- a/examples/WebApplication/WebApplication/Default.aspx.cs +++ b/examples/WebApplication/WebApplication/Default.aspx.cs @@ -26,7 +26,7 @@ protected void btnSubmit_Click(object sender, EventArgs e) PaymillContext paymill = new PaymillContext("YOUR PRIVATE KEY"); String token = hToken.Value; Payment payment = paymill.PaymentService.CreateWithTokenAsync(token).Result; - int amount = int.Parse(tbAmount.Text); + int amount = int.Parse(tbAmount.Text)*100; Transaction transaction = paymill.TransactionService.CreateWithPaymentAsync(payment, amount, tbCurrency.Text, "Test API c#").Result; /// Yout Transaction Is Complete }