I implemented stripe payment gateway, its working on my local system, but not working on production server which is a CentOs7 based on Linux server.
My code is given: [HttpPost]
public async Task<IActionResult> PaymentUsingStripe(string stripeToken, string stripeEmail, double price, int companyid)
{
try
{
var config = await _dbContext.SuperAdminConfiguration.Select(x => new { x.StripeSecret }).FirstOrDefaultAsync();
if (config != null)
StripeConfiguration.ApiKey = config.StripeSecret;
var company = await _dbContext.Companies.Include(c => c.CompanyConfiguration).Where(x => x.IsDeleted == false && x.CompanyId == companyid).FirstOrDefaultAsync();
if (company == null)
{
return NotFound();
}
var myCharge = new Stripe.ChargeCreateOptions();
myCharge.Amount = (long)price;
myCharge.Currency = "USD";
myCharge.ReceiptEmail = stripeEmail;
myCharge.Description = company.Name;
myCharge.Source = stripeToken;
myCharge.Capture = true;
var chargeService = new Stripe.ChargeService();
Charge stripeCharge = chargeService.Create(myCharge);
if (stripeCharge.Status != "failed")
{
// further my application logic
Stack traced:
Web.Areas.SuperAdminPortal.Controllers.IdentificationController[0]
at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslStream.ThrowIfExceptional()
at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__65_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
I tried dotnet cert commands , created dotnet certifactes, re-newed the SSL on nginx but not working... also run it on HTTP and HTTPs but throwing exception.
NET Core 3.1 is end-of-life for over a year now : https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-1#long-term-support
Being so old, it didn't relaibly support TLSv1.2, which is a requirement for making API calls to Stripe. Their recommendation was to update to NET Core 4.5
I'd suggest updating to a supported/modern/secure platform, especially for code where you're going to handling customer data.
https://stripe.com/blog/completing-tls-upgrade
https://archive.is/If4Jq