From 7a53a88331812a9631e01d56f9e0171c909763dd Mon Sep 17 00:00:00 2001 From: Sina Soltani Date: Tue, 30 Jun 2020 16:03:54 +0200 Subject: [PATCH 1/3] Fixing the second ConfigureOptions method bug. --- src/Parbad/Options/ParbadOptionsExtensions.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Parbad/Options/ParbadOptionsExtensions.cs b/src/Parbad/Options/ParbadOptionsExtensions.cs index fc2075d9..9047b13e 100644 --- a/src/Parbad/Options/ParbadOptionsExtensions.cs +++ b/src/Parbad/Options/ParbadOptionsExtensions.cs @@ -23,12 +23,7 @@ public static IParbadBuilder ConfigureOptions(this IParbadBuilder builder, Actio builder.Services.Configure(setupOptions); - builder.Services.AddTransient>(provider => - { - var messages = provider.GetRequiredService>().Value.Messages; - - return new OptionsWrapper(messages); - }); + RegisterMessagesOptions(builder); return builder; } @@ -45,6 +40,8 @@ public static IParbadBuilder ConfigureOptions(this IParbadBuilder builder, IConf builder.Services.Configure(configuration); + RegisterMessagesOptions(builder); + return builder; } @@ -69,5 +66,15 @@ public static IParbadBuilder ConfigureMessages(this IParbadBuilder builder, ICon return builder; } + + private static void RegisterMessagesOptions(IParbadBuilder builder) + { + builder.Services.AddTransient>(provider => + { + var messages = provider.GetRequiredService>().Value.Messages; + + return new OptionsWrapper(messages); + }); + } } } From 96adc20d788034484209745422ef4258f552fd85 Mon Sep 17 00:00:00 2001 From: Sina Soltani Date: Tue, 30 Jun 2020 16:04:26 +0200 Subject: [PATCH 2/3] Update package version. --- src/Parbad/Parbad.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parbad/Parbad.csproj b/src/Parbad/Parbad.csproj index ae4d851c..3b994cdd 100644 --- a/src/Parbad/Parbad.csproj +++ b/src/Parbad/Parbad.csproj @@ -3,7 +3,7 @@ netstandard2.0;netcoreapp3.0 latest - 3.5.0 + 3.5.1 Parbad Sina Soltani Parbad is a free, open-source, integrated and extensible library which connects your web applications to online payment gateways. Gateways can be added or developed by you. The Virtual Gateway also simulates the online payment process, which helps the application development. From 7826ea4d7c3687f714a300abbce700b5b3e8e301 Mon Sep 17 00:00:00 2001 From: Sina Soltani Date: Tue, 30 Jun 2020 16:10:21 +0200 Subject: [PATCH 3/3] Updating the samples. --- .../Controllers/PaymentController.cs | 7 +++---- samples/Parbad.Sample.Mvc/Controllers/PaymentController.cs | 7 +++---- samples/Parbad.Sample.WebForm/PayRequest.aspx.cs | 5 ++--- samples/Parbad.Sample.WebForm/Verify.aspx.cs | 1 + 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/samples/Parbad.Sample.AspNetCore/Controllers/PaymentController.cs b/samples/Parbad.Sample.AspNetCore/Controllers/PaymentController.cs index 8eb5e4d4..810064ec 100644 --- a/samples/Parbad.Sample.AspNetCore/Controllers/PaymentController.cs +++ b/samples/Parbad.Sample.AspNetCore/Controllers/PaymentController.cs @@ -42,14 +42,13 @@ public async Task Pay(PayViewModel viewModel) } }); + // Save the result.TrackingNumber in your database. + if (result.IsSucceed) { return result.GatewayTransporter.TransportToGateway(); } - // Note: This is just for development and testing. - // Don't show the actual result object to clients in production environment. - // Instead, show only the important information such as IsSucceed, Tracking Number and Transaction Code. return View("PayRequestError", result); } @@ -67,7 +66,7 @@ public async Task Verify() return Content("The payment is already processed before."); } - // An example of checking the invoice in your website. + // This is an example of cancelling an invoice when you think that the payment process must be stopped. if (!Is_There_Still_Product_In_Shop(invoice.TrackingNumber)) { var cancelResult = await _onlinePayment.CancelAsync(invoice, cancellationReason: "Sorry, We have no more products to sell."); diff --git a/samples/Parbad.Sample.Mvc/Controllers/PaymentController.cs b/samples/Parbad.Sample.Mvc/Controllers/PaymentController.cs index b170e9c8..984c34bb 100644 --- a/samples/Parbad.Sample.Mvc/Controllers/PaymentController.cs +++ b/samples/Parbad.Sample.Mvc/Controllers/PaymentController.cs @@ -47,14 +47,13 @@ public async Task Pay(RequestViewModel viewModel) } }); + // Save the result.TrackingNumber in your database. + if (result.IsSucceed) { return result.GatewayTransporter.TransportToGateway(); } - // Note: This is just for development and testing. - // Don't show the actual result object to clients in production environment. - // Instead, show only the important information such as IsSucceed, Tracking Number and Transaction Code. return View("PayRequestError", result); } @@ -72,7 +71,7 @@ public async Task Verify() return Content("The payment is already processed before."); } - // An example of checking the invoice in your website. + // This is an example of cancelling an invoice when you think that the payment process must be stopped. if (!Is_There_Still_Product_In_Shop(invoice.TrackingNumber)) { var cancelResult = await _onlinePayment.CancelAsync(invoice, cancellationReason: "Sorry, We have no more products to sell."); diff --git a/samples/Parbad.Sample.WebForm/PayRequest.aspx.cs b/samples/Parbad.Sample.WebForm/PayRequest.aspx.cs index ba5df626..c4554301 100644 --- a/samples/Parbad.Sample.WebForm/PayRequest.aspx.cs +++ b/samples/Parbad.Sample.WebForm/PayRequest.aspx.cs @@ -38,6 +38,8 @@ protected async void BtnPay_Click(object sender, EventArgs e) } }); + // Save the result.TrackingNumber in your database. + if (result.IsSucceed) { await result.GatewayTransporter.TransportAsync(); @@ -46,9 +48,6 @@ protected async void BtnPay_Click(object sender, EventArgs e) { ResultPanel.Visible = true; - // Note: This is just for development and testing. - // Don't show the actual result object to clients in production environment. - // Instead, show only the important information such as IsSucceed, Tracking Number and Transaction Code. LblTrackingNumber.Text = result.TrackingNumber.ToString(); LblAmount.Text = result.Amount.ToString(); LblGateway.Text = result.GatewayName; diff --git a/samples/Parbad.Sample.WebForm/Verify.aspx.cs b/samples/Parbad.Sample.WebForm/Verify.aspx.cs index 296e7a2a..9fd0e908 100644 --- a/samples/Parbad.Sample.WebForm/Verify.aspx.cs +++ b/samples/Parbad.Sample.WebForm/Verify.aspx.cs @@ -12,6 +12,7 @@ protected async void Page_Load(object sender, EventArgs e) var invoice = await StaticOnlinePayment.Instance.FetchAsync(); + // This is an example of cancelling an invoice when you think that the payment process must be stopped. if (Is_There_Still_Product_In_Shop(invoice.TrackingNumber)) { var verifyResult = await StaticOnlinePayment.Instance.VerifyAsync(invoice);