public bool RecieveGuest(Room room, Family family) { if (room != null && family != null) { if (room.Guests != null) { PeopleCountError?.Invoke(); return(false); } if (room.Cost > family.Money) { PaymentError?.Invoke(); return(false); } room.Guests = family; room.IsFree = false; SettledPeopleCount += family.MembersCount; Score += CalculateScore(family.Requirements, room); room.EndSettleGuest = family.EndSettle; return(true); } return(false); }
public async Task Consume(ConsumeContext <ProcessPayment> context) { var command = context.Message; var publishEndpoint = serviceProvider.GetService <IPublishEndpoint>(); var bankService = serviceProvider.GetService <ICallBankApi>(); (Guid paymentResponseId, string paymentMessage)bankApiResult = bankService.CallBank(command); //TODO: Add event store if (bankApiResult.paymentMessage == "SUCCESS") { var msg = new PaymentSuccessful() { CardNumber = TrimCardNumber(command.CardNumber), Amount = command.Amount, Currency = command.Currency, PaymentId = command.PaymentId, PaymentResponseId = bankApiResult.paymentResponseId.ToString(), PaymentResponseStatus = bankApiResult.paymentMessage, OrderId = command.OrderId, MerchantId = command.MerchantId, Cvv = command.Cvv, ExpiryDate = command.ExpiryDate }; await publishEndpoint.Publish(msg); } else if (bankApiResult.paymentMessage.Contains("System error")) { var paymentError = new PaymentError() { Amount = command.Amount, MerchantId = command.MerchantId, CardNumber = TrimCardNumber(command.CardNumber), Currency = command.Currency, OrderId = command.OrderId, PaymentId = command.PaymentId, Error = bankApiResult.paymentMessage, Cvv = command.Cvv, ExpiryDate = command.ExpiryDate }; await publishEndpoint.Publish(paymentError); } else { var msg = new PaymentUnsuccessful() { CardNumber = TrimCardNumber(command.CardNumber), Amount = command.Amount, Currency = command.Currency, ErrorMessage = bankApiResult.paymentMessage, OrderId = command.OrderId, MerchantId = command.MerchantId, Cvv = command.Cvv, ExpiryDate = command.ExpiryDate }; await publishEndpoint.Publish(msg); } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { /* Override onActivityResult to get notified when the checkout process is done. */ if (requestCode == CHECKOUT_ACTIVITY.CheckoutActivity) { switch ((int)resultCode) { case CHECKOUT_ACTIVITY.ResultOk: /* Transaction completed. */ Transaction transaction = (Com.Oppwa.Mobile.Connect.Provider.Transaction)data.GetParcelableExtra( CHECKOUT_ACTIVITY.CheckoutResultTransaction); resourcePath = data.GetStringExtra( CHECKOUT_ACTIVITY.CheckoutResultResourcePath); /* Check the transaction type. */ if (transaction.TransactionType == TransactionType.Sync) { /* Check the status of synchronous transaction. */ PaymentTaskCompletion.SetResult(true); } else { /* The on onNewIntent method may be called before onActivityResult * if activity was destroyed in the background, so check * if the intent already has the callback scheme */ if (hasCallbackScheme(Intent)) { PaymentTaskCompletion.SetResult(true); } else { /* The on onNewIntent method wasn't called yet, * wait for the callback. */ showProgressDialog(Resource.String.progress_message_please_wait); } } break; case CHECKOUT_ACTIVITY.ResultCanceled: hideProgressDialog(); break; case CHECKOUT_ACTIVITY.ResultError: hideProgressDialog(); PaymentError error = (Com.Oppwa.Mobile.Connect.Exception.PaymentError)data.GetParcelableExtra( CHECKOUT_ACTIVITY.CheckoutResultError); showAlertDialog(Resource.String.error_message); break; } } }
private T HandleResponse <T>(IRestResponse <T> response) { if (response.IsSuccessful) { return(response.Data); } PaymentError errorResponse = JsonConvert.DeserializeObject <IEnumerable <PaymentError> >(response.Content) .FirstOrDefault(); throw new VippsPaymentException(errorResponse); }
/// <summary> /// Gets the string value of a payment property. /// </summary> /// <param name="propertyHashtable">The property hashtable.</param> /// <param name="propertyNamespace">The namespace.</param> /// <param name="propertyName">The name.</param> /// <param name="required">The flag indicating whether the property is required.</param> /// <param name="errors">The error list in case the property is required but not found.</param> /// <returns>The string value.</returns> private static string GetPropertyStringValue(Hashtable propertyHashtable, string propertyNamespace, string propertyName, bool required, List <PaymentError> errors) { string propertyValue; bool found = PaymentProperty.GetPropertyValue( propertyHashtable, propertyNamespace, propertyName, out propertyValue); if (!found && required) { var error = new PaymentError(ErrorCode.InvalidRequest, string.Format("Property '{0}' is null or not set", propertyName)); errors.Add(error); } return(propertyValue); }
/// <summary> /// Validates the merchant account. /// </summary> /// <param name="request">The request.</param> /// <param name="errors">The error list to add any validation errors.</param> private static void ValidateMerchantAccount(Request request, List <PaymentError> errors) { // Get payment processor PaymentProcessorManager.Create(new string[] { AppSettings.ConnectorAssembly }); IPaymentProcessor processor = PaymentProcessorManager.GetPaymentProcessor(AppSettings.ConnectorName); // Prepare a request for validating merchant account var validateMerchantAccountRequest = new Request(); validateMerchantAccountRequest.Locale = request.Locale; var validateMerchantAccountRequestPropertyList = new List <PaymentProperty>(); foreach (var paymentProperty in request.Properties) { if (paymentProperty.Namespace == GenericNamespace.MerchantAccount) { validateMerchantAccountRequestPropertyList.Add(paymentProperty); } } validateMerchantAccountRequest.Properties = validateMerchantAccountRequestPropertyList.ToArray(); // Validates the merchant account by calling the payment processor Response validateMerchantAccountResponse = processor.ValidateMerchantAccount(validateMerchantAccountRequest); if (validateMerchantAccountResponse != null) { if (validateMerchantAccountResponse.Errors != null) { errors.AddRange(validateMerchantAccountResponse.Errors); } } else { var error = new PaymentError(ErrorCode.InvalidMerchantConfiguration, "Merchant configuraiton is invalid."); errors.Add(error); } }
public override void OnActionExecuting(HttpActionContext actionContext) { string message = string.Empty; bool firstError = true; if (actionContext.ModelState.IsValid == false) { foreach (var item in actionContext.ModelState.Values) { foreach (var e in item.Errors) { if (!firstError) { message += "; "; } message += e.ErrorMessage; firstError = false; } } PaymentError paymentError = new PaymentError(); paymentError.ErrorMessage = message; paymentError.ErrorType = typeof(PaymentRequiredFieldException).Name; var response = new PaymentServiceResponse <Object>() { Status = HttpStatusCode.BadRequest, DataContent = null, Error = paymentError }; actionContext.Response = actionContext.Request.CreateResponse(response); } }
private static void LogBeforeReturn(string methodName, string connectorName, string platform, IList <PaymentError> errors) { if (errors != null && errors.Count > 0) { RetailLogger.Log.PaymentConnectorLogErrors("methodName", connectorName, platform, PaymentError.GetErrorsAsTraceString(errors)); } RetailLogger.Log.PaymentConnectorLogOperation(methodName, OperationCompleted, connectorName, platform); }
private void onPaymentError(PaymentError error, string errorMsg) { log(string.Format("ERROR : {0} ({1})", error.ToString(), errorMsg ?? "")); }
private bool onScheduleCreationFailed(PaymentError error, string description = null) { log(String.Format("PAYMENT CREATION FAILED : {0}({1})", error, description ?? "")); return MessageBox.Show("Payment creation failed. Retry?", "Payment creation failed", MessageBoxButtons.YesNo) == DialogResult.Yes; }
private bool onScheduleCreationFailed(PaymentError error, string description = null) { log(string.Format("PAYMENT CREATION FAILED : {0}({1})", error, description ?? "")); return(MessageBox.Show("Payment creation failed. Retry?", "Payment creation failed", MessageBoxButtons.YesNo) == DialogResult.Yes); }
public VippsPaymentException(PaymentError error) : base(error.ErrorMessage) { Error = error; }
public IActionResult Error(PaymentError model) { return(View(model)); }
public PaymentException(PaymentError error, string message, Exception?innerException = null) : base(message, innerException) { Error = error; }
public async Task <IActionResult> getBanks() { Utility utility = new Utility(settings); PaymentError e = new PaymentError(); List <AccountData> banks = new List <AccountData>(); Redis redis = new Redis(settings, cache); string key = "all_paystack_banks"; CancellationTokenSource cts; cts = new CancellationTokenSource(); cts.CancelAfter(settings.Value.redisCancellationToken); // validate request if (!ModelState.IsValid) { var modelErrors = new List <PaymentError>(); var eD = new List <string>(); foreach (var modelState in ModelState.Values) { foreach (var modelError in modelState.Errors) { eD.Add(modelError.ErrorMessage); } } e.error = ((int)HttpStatusCode.BadRequest).ToString(); e.errorDetails = eD; return(BadRequest(e)); } try { banks = await redis.getBankDetails(key, cts.Token); if (banks != null && banks.Count > 0) { return(CreatedAtAction("GetBanks", banks)); } } catch (Exception ex) { Console.Write(ex.ToString()); } try { banks = await utility.getBanks(); } catch (Exception ex) { Console.Write(ex.ToString()); } //Write to Redis try { if (banks != null && banks.Count > 0) { await redis.setbankdetails(key, banks, cts.Token); } } catch (Exception ex) { Console.Write(ex.Message); } return(CreatedAtAction("GetBanks", banks)); }
public async Task <IActionResult> getAccountName(string id, string acctnum) { Utility utility = new Utility(settings); PaymentError e = new PaymentError(); AccountNameData name = new AccountNameData(); Redis redis = new Redis(settings, cache); string key = id + "_" + acctnum; CancellationTokenSource cts; cts = new CancellationTokenSource(); cts.CancelAfter(settings.Value.redisCancellationToken); // validate request if (!ModelState.IsValid) { var modelErrors = new List <PaymentError>(); var eD = new List <string>(); foreach (var modelState in ModelState.Values) { foreach (var modelError in modelState.Errors) { eD.Add(modelError.ErrorMessage); } } e.error = ((int)HttpStatusCode.BadRequest).ToString(); e.errorDetails = eD; return(BadRequest(e)); } try { name = await redis.getaccountname(key, cts.Token); if (name != null && !string.IsNullOrEmpty(name.account_name)) { return(CreatedAtAction("GetAccountName", name)); } } catch (Exception ex) { Console.Write(ex.ToString()); } try { name = await utility.getAccountName(id, acctnum); } catch (Exception ex) { Console.Write(ex.ToString()); } //Write to Redis try { if (name != null && !string.IsNullOrEmpty(name.account_name)) { await redis.setNameAsync(key, name, cts.Token); } } catch (Exception ex) { Console.Write(ex.Message); } return(CreatedAtAction("GetAccountName", name)); }
public ActionResult ErrorEncountered(PaymentError error) { var context = new IPTV2Entities(); var UserId = new Guid(User.Identity.Name); var userWallet = context.UserWallets.FirstOrDefault(u => u.UserId == UserId); string message = String.Empty; switch (error) { case PaymentError.CREDIT_CARD_PAYMENT_IS_DISABLED: message = "Credit card payment is currenty disabled."; break; case PaymentError.EWALLET_PAYMENT_IS_DISABLED: message = "E-Wallet payment is currently disabled."; break; case PaymentError.INSUFFICIENT_WALLET_LOAD: if (GlobalConfig.IsMopayReloadModeEnabled && GlobalConfig.MopayCountryWhitelist.Contains(userWallet.User.CountryCode)) { message = String.Format("You don't have enough credits to purchase this product. Your current balance is {0}. Reload <a href=\"/Load/Mopay\">here</a>.", userWallet.Balance.ToString("0.00")); } else message = String.Format("You don't have enough credits to purchase this product. Your current balance is {0}. Reload <a href=\"/Load/CreditCard\">here</a>.", userWallet.Balance.ToString("0.00")); break; case PaymentError.MAXIMUM_TRANSACTION_THRESHOLD_REACHED: message = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day.", GlobalConfig.paymentTransactionMaximumThreshold); break; case PaymentError.PAYPAL_PAYMENT_IS_DISABLED: message = "Paypal payment is currently disabled."; break; case PaymentError.PENDING_GOMS_CHANGE_COUNTRY: message = "We are still processing your recent change in location. Please try again later."; break; case PaymentError.PREPAID_CARD_PAYMENT_IS_DISABLED: message = "Prepaid card payment is currently disabled."; break; case PaymentError.USER_ENROLLED_IN_SAME_RECURRING_GROUP_PRODUCT: message = "You are currently automatically renewing a similar subscription product through Paypal/Credit card."; break; case PaymentError.CREDIT_CARD_IS_NOT_AVAILABLE_IN_YOUR_AREA: message = "Credit card payment is not available in your country."; break; default: message = "The system encountered an unspecified error. Please contact Customer Support."; break; } var ReturnCode = new TransactionReturnType() { StatusMessage = message }; return PartialView(ReturnCode); }