public async Task PostProcessPayment(ProcessPaymentRequest processPaymentRequest) { HttpContext httpContext = processPaymentRequest.HttpContext; try { if (processPaymentRequest.PaymentStatus == PaymentStatus.Paid) { return; } int selectedCurrencyId = processPaymentRequest.SelectedCurrencyId; PaystackSupportedCurrency supportedCurrency = await _supportedCurrencyService.GetSupportedCurrencyById(selectedCurrencyId); if (supportedCurrency == null || supportedCurrency.Id <= 0) { throw new ArgumentNullException("Plugins.SmartStore.Paystack.SupportedCurrencyNullArgument"); } PaystackSetting paystackSettings = await _settingService.GetSetting <PaystackSetting>(); if (paystackSettings == null) { throw new ArgumentNullException("Plugins.SmartStore.Paystack.PaystackSettingsNullArgument"); } PaystackTransaction transactionResponse = await _gatewayLuncher.MakePayment(processPaymentRequest, paystackSettings, supportedCurrency, httpContext); if (transactionResponse != null && transactionResponse.status && !string.IsNullOrWhiteSpace(transactionResponse.Data.authorization_url)) { await _gatewayLuncher.LogTransaction(transactionResponse); await _gatewayLuncher.LunchPaymentPage(httpContext, transactionResponse.Data.authorization_url); } else { string errorMessage = transactionResponse != null ? transactionResponse.message : string.Format("Plugins.SmartStore.Paystack.EmptyGatewayResponseMessage"); httpContext.Session.SetString(_gatewayLuncher.ErrorMessage, errorMessage); } } catch (Exception ex) { httpContext.Session.SetString(_gatewayLuncher.ErrorMessage, ex.Message); } }
public void DeleteSupportedCurrency(PaystackSupportedCurrency supportedCurrency) { Guard.NotNull(supportedCurrency, nameof(supportedCurrency)); //_supportedCurrencyRepository.Delete(supportedCurrency); }
public async Task Add(PaystackSupportedCurrency supportedCurrency) { Guard.NotNull(supportedCurrency, nameof(supportedCurrency)); await _supportedCurrencyRepository.AddAsync(supportedCurrency); }
public async Task <PaystackTransaction> MakePayment(ProcessPaymentRequest processPaymentRequest, PaystackSetting paystackSetting, PaystackSupportedCurrency supportedCurrency, HttpContext httpContext) { try { RegistrationId = processPaymentRequest.Registration.Id; string reference = processPaymentRequest.TransactionReference; string apiEndPoint = paystackSetting.InitializeTransactionEndPoint; string callbackUrl = GetRedirectUrl(httpContext.Request, "Completed", "Registration", "Student", RegistrationId); OrderTotal = Math.Truncate(processPaymentRequest.AmountPayable * supportedCurrency.LeastValueUnitMultiplier); RestRequest request = new RestRequest(apiEndPoint, Method.POST); request.AddHeader(paystackSetting.APIAcceptHeaderKey, paystackSetting.APIAcceptHeaderValue); request.AddHeader(paystackSetting.APIAuthorizationHeaderKey, paystackSetting.APIAuthorizationHeaderValue + " " + paystackSetting.Key); request.AddParameter(paystackSetting.APIReferenceParameterKey, reference); request.AddParameter(paystackSetting.APIAmountParameterKey, OrderTotal); request.AddParameter(paystackSetting.APICallbackUrlParameterKey, callbackUrl); request.AddParameter(paystackSetting.APIEmailParameterKey, httpContext.User.Identity.Name); return(await Post(paystackSetting, request)); } catch (Exception) { throw; } }