static async Task MainAsync(string [] args) { CmdOptions options = new CmdOptions(); bool didParseOptions = CommandLine.Parser.Default.ParseArguments(args, options); if (!didParseOptions) { Console.WriteLine("Error: failed to parse command line options"); return; } IPaymentProviderBackend apiProvider = PaymentProviderBackendFactory.GetProvider(options.Provider, new ConsoleLoggerAdapter()); PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = options.MerchantId, SharedSecret = options.SecretKey }; ConsoleApiCaller apiCaller = new ConsoleApiCaller(apiProvider, providerConfig); switch (options.CommandName) { case "checkAuth": await apiCaller.DoCheckAuth(options.RecordId /* , options.SubAccount */); break; default: Console.WriteLine($"Error: command \"{options.CommandName}\" not supporter"); break; } }
// [TestMethod] public async Task <ActionResult> UpdateCardHolder() { RealExPaymentProvider realexInstance = new RealExPaymentProvider(new TraceWriterLogAdapter()); PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = "WorkwizTest", SharedSecret = "ShouldBeRejected" }; CardholderDetails cardHolder = new CardholderDetails() { Address1 = "Workwiz Office", City = "London", Company = "Workwiz", Email = "*****@*****.**", FirstName = "UnitTest", PayerRef = "1234x5", // Country = new Tuple<string, string>("1", "UK"), Comments = new List <string>() }; await realexInstance.UpdateCardholderDetails(providerConfig, cardHolder); Assert.IsTrue(true, "Reached this point without throwing"); return(Content("done")); }
public ActionResult SendToPaymentProvider( PaymentProviderConfiguration configuration, GeneralisedPaymentTransfer transferObject, Action <PaymentProviderConfiguration, GeneralisedPaymentTransfer, string> saveProviderReference) { var civicaXfer = new CivicaPaymentTransfer() { ProviderUrl = Shared.Civica.Default.CivicaPostUrl, ReturnUrl = transferObject.ReturnUrl, CallingApplicationId = Shared.Civica.Default.CivicaAppId, CallingApplicationTransactionReference = transferObject.TransactionId, GeneralLedgerCode = $"{transferObject.GeneralLedgerCode}-{transferObject.ProductId}", //PaymentSourceCode = transferObject.PaymentSourceCode, PaymentSourceCode = transferObject.IsMediated ? "02" : "01", PaymentTotal = transferObject.Amount, PaymentLines = new List <string>() }; foreach (var item in transferObject.LineItems) { civicaXfer.PaymentLines.Add(FormatPaymentLine(item)); } var resultView = PaymentFrameworkUtility.CreateView("~/Views/Payment/SendToCivica.cshtml", civicaXfer); var sendToPaymentLogMessage = PaymentFrameworkUtility.DescribeActionResultForLogging(resultView, true); this.Logger.CreateEntry(typeof(CivicaPaymentProvider), LogLevel.Info, sendToPaymentLogMessage); return(resultView); }
public async Task <PaymentAuthorizationGuiResponse> ProcessResponse( PaymentProviderConfiguration configuration, NameValueCollection paramsCollection, ResponseParameters additionalParameters) { string paramsDesc = PaymentFrameworkUtility.DescribeNameValueCollection(paramsCollection); this.Logger.CreateEntry(typeof(CapitaPaymentProvider), LogLevel.Debug, $"ProcessResponse({paramsDesc})"); string roundTripTransactionReference = paramsCollection[RoundTripTokenKey]; if (String.IsNullOrEmpty(roundTripTransactionReference)) { throw new InvalidOperationException($"response did not include required field '{RoundTripTokenKey}'"); } Guid pendingPaymentRef = new Guid(roundTripTransactionReference); string paymentProviderTransactionReference = additionalParameters.ProviderReference; if (String.IsNullOrEmpty(paymentProviderTransactionReference)) { throw new InvalidOperationException("response did not include required field \'PaymentProviderTransactionReference\'"); } var backendResponse = await CheckAuthorizationInternal(configuration, pendingPaymentRef.ToString(), paymentProviderTransactionReference); return(new PaymentAuthorizationGuiResponse(backendResponse, null)); }
public Task <string> CancelSavedCard( PaymentProviderConfiguration configuration, string cardOwnerIdentifer, string savedCardIdentified) { throw new NotImplementedException(); }
public ActionResult SendToPaymentProvider( PaymentProviderConfiguration configuration, GeneralisedPaymentTransfer transferObject, Action <PaymentProviderConfiguration, GeneralisedPaymentTransfer, string> saveProviderReference) { return(SendToPaymentProvider(configuration, transferObject, DateTime.Now)); }
internal ConsoleApiCaller( IPaymentProviderBackend apiProvider, PaymentProviderConfiguration providerConfig) { this._apiProvider = apiProvider; this._providerConfig = providerConfig; }
public async Task <IPaymentAuthorizationResponse> CheckAuthorization( PaymentProviderConfiguration configuration, string uniqueIdentifier, decimal expectedAmount, string paymentProviderUniqueRefrence) { return(await CheckAuthorizationInternal(configuration, uniqueIdentifier, paymentProviderUniqueRefrence)); }
public ActionResult ProcessPayment(FormCollection form) { string requestId = _paymentProvider.GenerateUniqueIdentifier(); this.Session["RequestId"] = requestId; var xfer = new GeneralisedPaymentTransfer() { Amount = decimal.Parse(form["Amount"]), // -> "AMOUNT" ReturnUrl = "http://localhost:59412" + Url.Action("ProviderCallback", "Capita"), TransactionId = requestId }; PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = this._capitaMerchantid, SharedSecret = this._capitaSecretKey, SubAccountNumber = this._capitaScpid }; xfer.Account = this._capitaScpid; xfer.VariableReference = "164 Wandsworth Borough Council"; xfer.Comment1 = "Activity : After school club"; xfer.Comment2 = "PS56789/456"; xfer.CustomerNumber = "50939"; xfer.GeneralLedgerCode = "WE333292049,WE330192071,WE333592049,WE333792049"; xfer.IsMediated = false; xfer.ProductId = "56789"; //xfer.VatCode = CapitaVatCode.StandardRate; //xfer.VatRate = 20; xfer.VatCode = CapitaVatCode.ZeroRate; xfer.VatRate = 0; //xfer.SaveCard = new SaveCard() //{ // PayerReference = "s12u34" //}; xfer.LineItems = new System.Collections.Generic.List <CivicaLineItem>() { new CivicaLineItem() { Amount = decimal.Parse(form["Amount"]), FundCode = "16", Narrative = "Play Service booking MULTI_153997_112816_138579", Reference = "56789" } }; var result = _paymentProvider.SendToPaymentProvider(providerConfig, xfer, SaveProviderReference); string rawHtml = PaymentFrameworkUtility.DescribeActionResultForLogging(result); System.Diagnostics.Trace.WriteLine(rawHtml); System.Diagnostics.Trace.WriteLine("Provider Reference: " + this.Session["ProviderReference"]); return(result); }
public ActionResult SendToPaymentProvider( PaymentProviderConfiguration configuration, GeneralisedPaymentTransfer transferObject, DateTime nowLocalTime) { var realExXfer = new RealExPaymentTransfer() { MerchantId = configuration.AccountIdentifer, OrderId = transferObject.TransactionId, Amount = (int)(transferObject.Amount * 100), ProviderUrl = Shared.RealEx.Default.RealExPostUrl, ReturnUrl = transferObject.ReturnUrl, Currency = "GBP", Timestamp = nowLocalTime.ToString("yyyyMMddHHmmss"), AutoSettleFlag = true }; realExXfer.Account = transferObject.Account; realExXfer.VariableReference = MessageContentUtility.TruncateAndStripDisallowed(transferObject.VariableReference, 50, RealexFields.RealexFieldVarRefDisallowRegex); realExXfer.CustomerNumber = transferObject.CustomerNumber; realExXfer.ProductId = MessageContentUtility.TruncateAndStripDisallowed(transferObject.ProductId, null, RealexFields.RealexFieldProductIdDisallowRegex); realExXfer.Comment1 = MessageContentUtility.TruncateAndStripDisallowed(transferObject.Comment1, 255, RealexFields.RealexFieldCommentDisallowRegex); realExXfer.Comment2 = MessageContentUtility.TruncateAndStripDisallowed(transferObject.Comment2, 255, RealexFields.RealexFieldCommentDisallowRegex); var fieldsForSignature = new List <string>(); fieldsForSignature.Add(realExXfer.Timestamp); fieldsForSignature.Add(realExXfer.MerchantId); fieldsForSignature.Add(realExXfer.OrderId); fieldsForSignature.Add(realExXfer.Amount.ToString()); fieldsForSignature.Add(realExXfer.Currency); if (transferObject.SaveCard != null) { realExXfer.HasSavedCard = true; realExXfer.CardStorageEnabled = true; realExXfer.OfferSaveCard = transferObject.SaveCard.OfferSaveCard; realExXfer.PaymentReference = MessageContentUtility.TruncateAndStripDisallowed(transferObject.SaveCard.PaymentReference, 30, RealexFields.RealexFieldPaymentRefDisallowRegex); realExXfer.PayerReference = MessageContentUtility.TruncateAndStripDisallowed(transferObject.SaveCard.PayerReference, 50, RealexFields.RealexFieldPayerRefDisallowRegex); realExXfer.PayerExists = transferObject.SaveCard.PayerExists; fieldsForSignature.Add(realExXfer.PayerReference); fieldsForSignature.Add(realExXfer.PaymentReference); } realExXfer.Sha1Hash = CalculateRealexSignature(fieldsForSignature.ToArray(), configuration.SharedSecret); var resultView = PaymentFrameworkUtility.CreateView("~/Views/Payment/SendToRealEx.cshtml", realExXfer); var sendToPaymentLogMessage = PaymentFrameworkUtility.DescribeActionResultForLogging(resultView, true); this.Logger.CreateEntry(typeof(RealExPaymentProvider), LogLevel.Info, sendToPaymentLogMessage); return(resultView); }
protected async Task <PaymentAuthorizationResponse> CheckAuthorizationInternal( PaymentProviderConfiguration configuration, string uniqueIdentifier) { var request = CreateCivicaRequest(Shared.Civica.Default.CivicaAppId, uniqueIdentifier); RespMessage civicaResponse; using (QueryAuthRequestSrvSoapClient civicaClient = new QueryAuthRequestSrvSoapClient("QueryAuthRequestSrvSoap", Shared.Civica.Default.CivicaQueryUrl)) { civicaResponse = await civicaClient.QueryAsync(request); } return(ParseResponseFromCivicaResponse(civicaResponse)); }
public async Task <IPaymentAuthorizationResponse> CheckAuthorization( PaymentProviderConfiguration configuration, string uniqueIdentifier, decimal expectedAmount, string paymentProviderUniqueRefrence) { QueryPaymentResponse response = await RealexQueryPayment(configuration, uniqueIdentifier, expectedAmount, subAccount : String.Empty); PaymentAuthorizationResponse result = new PaymentAuthorizationResponse( responseOk: response.HttpStatus == HttpStatusCode.OK, response: response.ResultMappedToFrameworkResult, amount: expectedAmount, description: response.Message, receiptNumber: response.AuthCode); return(result); }
public async Task <ActionResult> ProviderCallback(FormCollection form) { PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = this._capitaMerchantid, SharedSecret = this._capitaSecretKey, SubAccountNumber = this._capitaScpid }; string scpReference = string.Empty; if (this.Session["ProviderReference"] != null) { scpReference = (string)this.Session["ProviderReference"]; } if (form != null && form[this._paymentProvider.RoundTripTokenKey] == null && this.Request.QueryString["RequestId"] != null) { form[this._paymentProvider.RoundTripTokenKey] = this.Request.QueryString["RequestId"]; } var responseParameters = new ResponseParameters() { NextUrl = "", SuccessImageUrl = "http://www.myplayservice.co.uk/App_Themes/images/Allow.gif", FailureImageUrl = "http://www.myplayservice.co.uk/App_Themes/images/deny.png", ProviderReference = scpReference }; var response = await _paymentProvider.ProcessResponse(providerConfig, form, responseParameters); if (response.ServerReply != null) { return(response.ServerReply); } if (response.AuthorizationResult == PaymentAuthorizationResult.Authorized) { return(Content("Booking confirmed. A confirmation email will be sent shortly")); } else { return(Content("Unsuccessful Payment." + response.Description)); } }
public async Task <string> UpdateCardholderDetails( PaymentProviderConfiguration configuration, CardholderDetails cardholder) { var realExXfer = new PayerEditRequest(configuration.AccountIdentifer, cardholder.PayerRef) { OrderId = Guid.NewGuid().ToString(), }; realExXfer.Payer.Title = cardholder.Title; realExXfer.Payer.FirstName = cardholder.FirstName; realExXfer.Payer.Surname = cardholder.Surname; realExXfer.Payer.PayerType = "Customer"; realExXfer.Payer.Address = new RealexAddress() { Line1 = cardholder.Address1, Line2 = cardholder.Address2, Line3 = cardholder.Address3, City = cardholder.City, County = cardholder.County, Postcode = cardholder.Postcode, Country = new RealexCountry() { CountryCode = "GB", Name = "United Kingdom" } }; realExXfer.Payer.PhoneNumbers = new RealexPhoneNumbers() { Home = cardholder.HomePhone, Work = cardholder.WorkPhone, Mobile = cardholder.MobilePhone }; realExXfer.Payer.EMail = cardholder.Email; realExXfer.Payer.Comments = RealexComment.CreateCommentList(cardholder.Comments, maxNumberOfComments: 2); PayerEditResponse result = await PostXmlToRealex <PayerEditResponse, PayerEditRequest>( realExXfer, configuration.SharedSecret, logLevelForSuccess : LogLevel.Audit); result.ThrowIfNotSuccess(); return(result.PasRef); }
public async Task <PaymentAuthorizationGuiResponse> ProcessResponse( PaymentProviderConfiguration configuration, NameValueCollection paramsCollection, ResponseParameters additionalParameters) { string paramsDesc = PaymentFrameworkUtility.DescribeNameValueCollection(paramsCollection); Logger.CreateEntry(typeof(CivicaPaymentProvider), LogLevel.Debug, $"ProcessResponse({paramsDesc})"); string responseCode = paramsCollection["ResponseCode"] ?? "-1"; int responseCodeParsed = -1; bool didParse = Int32.TryParse(responseCode, out responseCodeParsed); if (didParse && (0 == responseCodeParsed)) { string roundTripTransactionReference = paramsCollection["CallingApplicationTransactionReference"]; if (String.IsNullOrEmpty(roundTripTransactionReference)) { throw new InvalidOperationException(String.Format("response did not include required field '{0}'", "CallingApplicationTransactionReference")); } Guid pendingPaymentRef = new Guid(roundTripTransactionReference); var backendResponse = await CheckAuthorizationInternal(configuration, pendingPaymentRef.ToString()); backendResponse.ResponseCode = responseCode; backendResponse.TransactionId = roundTripTransactionReference; return(new PaymentAuthorizationGuiResponse(backendResponse, null)); } else { var backendResponse = new PaymentAuthorizationResponse(false, PaymentAuthorizationResult.Declined, !string.IsNullOrEmpty(paramsCollection["PaymentAmount"]) ? decimal.Parse(paramsCollection["PaymentAmount"]) : 0.00m, paramsCollection["ResponseDescription"], paramsCollection["IncomeManagementReceiptNumber"]) { ResponseCode = responseCode, TransactionId = paramsCollection["CallingApplicationTransactionReference"] }; return(new PaymentAuthorizationGuiResponse(backendResponse, null)); } }
/// <remarks> /// Wraps calls to Realex's 'Query' API function /// </remarks> public async Task <QueryPaymentResponse> RealexQueryPayment( PaymentProviderConfiguration configuration, string uniqueIdentifier, decimal expectedAmount, string subAccount) { QueryPaymentRequest qRequest = new QueryPaymentRequest(merchantId: configuration.AccountIdentifer, originalOrderId: uniqueIdentifier); qRequest.SubAccount = subAccount; QueryPaymentResponse response = await PostXmlToRealex <QueryPaymentResponse, QueryPaymentRequest>( qRequest, secretKey : configuration.SharedSecret, logLevelForSuccess : LogLevel.Debug); return(response); }
public async Task <string> CancelSavedCard( PaymentProviderConfiguration configuration, string cardOwnerIdentifer, string savedCardIdentified) { CardCancelCardRequest req = new CardCancelCardRequest( merchantId: configuration.AccountIdentifer, payerRef: cardOwnerIdentifer, savedCardName: savedCardIdentified); CardCancelCardResponse response = await PostXmlToRealex <CardCancelCardResponse, CardCancelCardRequest>( req, configuration.SharedSecret, logLevelForSuccess : LogLevel.Audit); response.ThrowIfNotSuccess(); return(response.PasRef); }
public async Task <ActionResult> ProviderCallback(FormCollection form) { PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = _realExMerchantid, SharedSecret = _realExSecretKey }; var responseParameters = new ResponseParameters() { NextUrl = "", SuccessImageUrl = "http://www.myplayservice.co.uk/App_Themes/images/Allow.gif", FailureImageUrl = "http://www.myplayservice.co.uk/App_Themes/images/deny.png", Reference = "REFXXXX" }; var response = await _paymentProvider.ProcessResponse(providerConfig, form, responseParameters); return(response.ServerReply); }
public async Task <ActionResult> TestBackEndApi() { PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = _realExMerchantid, SharedSecret = _realExSecretKey }; try { var pmtAuthResponse = await _paymentProviderBackend.CheckAuthorization( providerConfig, _paymentProvider.GenerateUniqueIdentifier(), 1234, string.Empty); } catch (Exception ex) { throw ex; } return(Content("Success")); }
/// <remarks> /// Wraps calls to Realex's ReceiptIn API function /// </remarks> public async Task <ReceiptInResponse> RealexReceiptIn( PaymentProviderConfiguration configuration, string realexPayerRef, decimal amount, string subAccount, string cardName, RealexTssInfo additionalInfo, IEnumerable <string> optionalComments) { ReceiptInRequest req = new ReceiptInRequest( merchantId: configuration.AccountIdentifer, payerRef: realexPayerRef, paymentMethod: cardName, amount: amount); req.Account = subAccount; if (RealEx.Default.RealVaultRemoteUrl.ToLower().Contains("sandbox")) { req.Account = req.Account + "test"; } req.Comments = RealexComment.CreateCommentList(optionalComments); if (null != additionalInfo) { additionalInfo.TruncateAndStripDisallowed(); req.TssInfo = additionalInfo; } ReceiptInResponse response = await PostXmlToRealex <ReceiptInResponse, ReceiptInRequest>( req, configuration.SharedSecret, logLevelForSuccess : LogLevel.Audit); return(response); }
public ActionResult ProcessPayment(FormCollection form) { var xfer = new GeneralisedPaymentTransfer() { Amount = decimal.Parse(form["Amount"]), // -> "AMOUNT" ReturnUrl = "http://localhost:59412" + Url.Action("ProviderCallback", "Default"), TransactionId = _paymentProvider.GenerateUniqueIdentifier(), // -> "ORDER_ID" GeneralLedgerCode = "SOMECIVICACODE" }; PaymentProviderConfiguration providerConfig = new PaymentProviderConfiguration() { AccountIdentifer = _realExMerchantid, SharedSecret = _realExSecretKey }; xfer.Account = ""; xfer.VariableReference = ""; xfer.Comment1 = ""; xfer.Comment2 = ""; xfer.LineItems.Add(new CivicaLineItem() { Reference = "LINEREF", Amount = 10.00m, Narrative = "Stuff paid for", FundCode = "FUND" }); var result = _paymentProvider.SendToPaymentProvider(providerConfig, xfer, null); string rawHtml = PaymentFrameworkUtility.DescribeActionResultForLogging(result); System.Diagnostics.Trace.WriteLine(rawHtml); return(result); }
protected async Task <PaymentAuthorizationResponse> CheckAuthorizationInternal( PaymentProviderConfiguration configuration, string uniqueIdentifier, string scpUniqueReference) { int siteId; int scpId; int hmacKeyId; string hmacSecretKey; int.TryParse(configuration.AccountIdentifer, out siteId); int.TryParse(configuration.SubAccountNumber, out scpId); CapitaApiHelpers.GetHmacIdAndSecretKey(configuration.SharedSecret, out hmacKeyId, out hmacSecretKey); scpQueryRequest request = CreateCapitaQueryRequest(siteId, scpId, hmacKeyId, hmacSecretKey, scpUniqueReference, uniqueIdentifier); scpSimpleQueryResponse1 response; try { using (CapitaSimple.scpClient capitaClient = new scpClient("CapitaScpSoap", Shared.Capita.Default.CapitaWebServiceUrl)) { try { response = await capitaClient.scpSimpleQueryAsync(request); } catch (Exception ex) { this.Logger.CreateEntry(typeof(CapitaApiProvider), LogLevel.Error, $"Token:{uniqueIdentifier},ProviderToken:{scpUniqueReference}", ex); return(new PaymentAuthorizationResponse(false, PaymentAuthorizationResult.ErrorUnknownStatus, 0, "Error occurred: Provider returned an error in response", null)); } } } //This is a quick fix to cover the scenario where we're calling from AzureFunction and AzureFunction does not have any app.config //So we need to build the bindings and endpoint in the code catch (InvalidOperationException invalidOperationException) { // Create endpoint address gathered from functions app settings var address = new EndpointAddress(Shared.Capita.Default.CapitaWebServiceUrl); // Create binding to match the client proxy configuration var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.Security.Mode = BasicHttpSecurityMode.Transport; using (CapitaSimple.scpClient capitaClient = new scpClient(binding, address)) { try { response = await capitaClient.scpSimpleQueryAsync(request); } catch (Exception ex) { this.Logger.CreateEntry(typeof(CapitaApiProvider), LogLevel.Error, $"Token:{uniqueIdentifier},ProviderToken:{scpUniqueReference}", ex); return(new PaymentAuthorizationResponse(false, PaymentAuthorizationResult.ErrorUnknownStatus, 0, "Error occurred: Provider returned an error in response", null)); } } } catch (Exception ex) { throw ex; } return(ParseResponseFromCapitaResponse(response)); }
public void SaveProviderReference(PaymentProviderConfiguration config, GeneralisedPaymentTransfer paymentTransfer, string providerReference) { this.Session["ProviderReference"] = providerReference; }
public Task <PaymentAuthorizationGuiResponse> ProcessResponse( PaymentProviderConfiguration configuration, NameValueCollection paramsCollection, ResponseParameters additionalParameters) { string timestamp = paramsCollection[RealexFields.RealexFieldTimestamp]; string merchantid = paramsCollection[RealexFields.RealexFieldMerchantId]; string orderid = paramsCollection[RealexFields.RealexFieldOrderId]; string authcode = paramsCollection[RealexFields.RealexFieldAuthCode]; string resultCode = paramsCollection[RealexFields.RealexFieldResult]; string textmsg = paramsCollection[RealexFields.RealexFieldResponseTextMessage]; string receiptNumber = paramsCollection[RealexFields.RealexFieldPasRef]; string responseSignature = paramsCollection[RealexFields.RealexFieldHashSignature]; string amountString = paramsCollection[RealexFields.RealexFieldAmount]; string[] fieldsForResponseSignature = new string[] { timestamp, merchantid, orderid, resultCode, textmsg, receiptNumber, // PASREF authcode }; string expectedResponseHash = CalculateRealexSignature(fieldsForResponseSignature, configuration.SharedSecret); decimal amount; if (decimal.TryParse(amountString, out amount)) { amount = amount / 100m; } else { amount = 0; } if (expectedResponseHash != responseSignature) { PaymentAuthorizationResponse dummyBackendResponse = new PaymentAuthorizationResponse(false, PaymentAuthorizationResult.Unknown, amount, "incorrect SHA1HASH.", receiptNumber) { ResponseCode = resultCode, TransactionId = orderid }; return(Task.FromResult(new PaymentAuthorizationGuiResponse(dummyBackendResponse, null))); } PaymentAuthorizationResult isAuthorized = IsResponseCodeSuccess(resultCode) ? PaymentAuthorizationResult.Authorized : PaymentAuthorizationResult.Declined; var savedCardResponse = new SavedCardResponse(); if (!string.IsNullOrEmpty(paramsCollection[RealVaultFields.ResponsePayerSetupResultCode]) && paramsCollection[RealVaultFields.ResponsePayerSetupResultCode] == "00") { savedCardResponse.NewCardholderSaved = true; } if (!string.IsNullOrEmpty(paramsCollection[RealVaultFields.ResponseSavedPayerRef])) { savedCardResponse.CardholderReference = paramsCollection[RealVaultFields.ResponseSavedPayerRef]; } if (!string.IsNullOrEmpty(paramsCollection[RealVaultFields.ResponseSavedCardResultCode])) { if (IsResponseCodeSuccess(paramsCollection[RealVaultFields.ResponseSavedCardResultCode])) { savedCardResponse.CardSaved = true; savedCardResponse.CardReference = paramsCollection[RealVaultFields.ResponseSavedCardRef]; savedCardResponse.CardDigits = paramsCollection[RealVaultFields.ResponseMaskedCardDigits]; savedCardResponse.ExpiryDate = Utility.ParseExpiryDate(paramsCollection[RealVaultFields.ResponseSavedCardExpiryDate]); } else { savedCardResponse.CardSaved = false; savedCardResponse.CardSaveStatus = paramsCollection[RealVaultFields.ResponseSavedCardResultMessage]; } } PaymentAuthorizationResponse response = new PaymentAuthorizationResponse( IsResponseCodeSuccess(resultCode), isAuthorized, amount, textmsg, receiptNumber) { ResponseCode = resultCode, TransactionId = orderid, SavedCard = savedCardResponse }; var realExResponse = new RealExServerResponse(); StringBuilder displayText = new StringBuilder(); if (!response.ResponseOk) { realExResponse.ImagePath = additionalParameters.FailureImageUrl; realExResponse.ConfigDescription = "Payment failed"; displayText.Append("There was an error while processing your payment.<br />Please contact <a href=\"mailto:[email protected]\">My Play Service Support</a><br />"); displayText.AppendFormat($"ERROR DETAILS : {textmsg}"); } else { // TODO: show AUTHCODE to user (a legal requirement?) and an absolute hyperlink back in to the ebooking application realExResponse.ConfigDescription = "Payment Success"; displayText.AppendFormat($"Payment Reference Number = {response.ReceiptNumber}<br />"); displayText.AppendFormat($"Amount Paid = {response.AmountAuthorized:c}<br />"); displayText.AppendFormat("Booking Reference Number {0}<br />", additionalParameters.Reference); displayText.AppendFormat("A confirmation email will be sent shortly with all details and invoice"); realExResponse.ImagePath = additionalParameters.SuccessImageUrl; realExResponse.AdditionalSuccessMessage = additionalParameters.AdditionalSuccessMessage; } realExResponse.MainResult = displayText.ToString(); realExResponse.NextUrl = additionalParameters.NextUrl; PartialViewResult serverReply = PaymentFrameworkUtility.CreatePartialView("~/Views/Payment/ReplyToRealEx.cshtml", realExResponse); PaymentAuthorizationGuiResponse guiResponse = new PaymentAuthorizationGuiResponse(response, serverReply); return(Task.FromResult <PaymentAuthorizationGuiResponse>(guiResponse)); }
public ActionResult SendToPaymentProvider( PaymentProviderConfiguration configuration, GeneralisedPaymentTransfer transferObject, Action <PaymentProviderConfiguration, GeneralisedPaymentTransfer, string> saveProviderReference) { int siteId; int.TryParse(configuration.AccountIdentifer, out siteId); int scpId; int.TryParse(transferObject.Account, out scpId); int hmacKeyId; string hmacSecretKey; CapitaApiHelpers.GetHmacIdAndSecretKey(configuration.SharedSecret, out hmacKeyId, out hmacSecretKey); string returnUrl = $"{transferObject.ReturnUrl}?{RoundTripTokenKey}={transferObject.TransactionId}"; CapitaInvokeRequest request = new CapitaInvokeRequest() { SiteId = siteId, ScpId = scpId, HmacKeyId = hmacKeyId, HmacKey = hmacSecretKey, UniqueReference = transferObject.TransactionId, PurchaseId = transferObject.ProductId, BookingRef = transferObject.Comment2, PurchaseDescription = transferObject.Comment1, PaymentTotal = (int)(transferObject.Amount * 100), ReturnUrl = returnUrl, IntegraCode = transferObject.GeneralLedgerCode, IsMediated = transferObject.IsMediated, FundCode = Shared.Capita.Default.FundCode, VatCode = transferObject.VatCode, VatRate = transferObject.VatRate }; if (transferObject.SaveCard != null) { request.SaveCard = true; request.CardHolderId = MessageContentUtility.TruncateAndStripDisallowed(transferObject.SaveCard.PayerReference, 50, null); } //Call Capita web service to set up the payment CapitaInvokeResponse response = InvokeRequest(request); if (response != null && !response.Error) { //call this action method to save scpReference into PendingPayment table saveProviderReference(configuration, transferObject, response.ScpReference); RedirectResult resultView = new RedirectResult(response.RedirectUrl, true); var sendToPaymentLogMessage = PaymentFrameworkUtility.DescribeActionResultForLogging(resultView, true); this.Logger.CreateEntry(typeof(CapitaPaymentProvider), LogLevel.Info, sendToPaymentLogMessage); return(resultView); } else { string errorMessage = "Capita Server returns null response."; if (response != null) { errorMessage += " " + response.ErrorMessage; } this.Logger.CreateEntry(typeof(CapitaPaymentProvider), LogLevel.Error, errorMessage); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }
public Task <string> UpdateCardholderDetails( PaymentProviderConfiguration configuration, CardholderDetails cardholder) { throw new NotImplementedException(); }