/// <summary> /// Creates some general payza button /// </summary> /// <param name="itemName">Name describing the item or service. Max Length: 50 characters</param> /// <param name="amount">The price or cost of the product or service. The value for /// amount must be positive. Null or negative numbers are not allowed.</param> /// <param name="command">Describes how handler should handle IPN request. /// Stored in field apc_1. Max Length: 100 characters</param> /// <param name="args"> /// Custom values you can pass along with the payment button. /// The values are not displayed to the payer on our Pay Process page. /// Payza returns these fields back in the IPN. /// Used by IIpnHandler ('command') /// Stored in fields apc_2 - apc_6. Max Length: 100 characters /// </param> /// <returns>Http address where member should be redirected after clicking button.</returns> protected override string generate(string itemName, Money amount, string command, object[] args) { string url = String.Empty; var shooppingVoucher = new ShoppingVoucherEntity(); shooppingVoucher.Amount = amount.ToDecimal(); shooppingVoucher.ProductName = itemName; shooppingVoucher.CategoryName = HashingManager.Base64Encode(command); shooppingVoucher.TotalAmount = amount.ToDecimal(); shooppingVoucher.Quantity = 1; int orderId = PaparaOrder.Create(amount, command, String.Join(ButtonGenerationStrategy.ArgsDelimeter.ToString(), args)); var client = new ApiRequestSoapClient(); var result = client.TransactionRequest(account.ApiName, account.ApiKey, account.Username, orderId.ToString(), amount.ToDecimal(), Money.Zero.ToDecimal(), new ShoppingVoucherEntity[1] { shooppingVoucher }, AppSettings.Site.Url + "Handlers/Payment/Papara.ashx", 2); client.Close(); if (result.ResultStatus && !String.IsNullOrEmpty(result.ResultObject)) { url = result.ResultObject; } return(url); }
public override void ProcessRequest() { string pre1 = context.Request["pre1"]; string pre2 = context.Request["pre2"]; pre1 = HashingManager.Base64Decode(pre1); string orderId = pre1.Split('+')[0]; string statusCode = pre1.Split('+')[1]; string key = orderId + "+" + statusCode; key = HashingManager.Base64Encode(key); string md5String = HashingManager.GenerateMD5(key + PaparaAccountDetails.GetSecretKey()); //Papara transaction OK check if (md5String == pre2) { //Set variables OrderID = orderId; try { PaparaOrder Order = PaparaOrder.Get(Convert.ToInt32(OrderID)); Args = Order.Args; TransactionID = OrderID; Amount = Order.Amount.ToShortClearString(); CommandName = Order.CommandName; //Check duplicated transactions CheckIfNotDoneYet(OrderID); //All OK, let's proceed Assembly assembly = Assembly.GetAssembly(typeof(IIpnHandler)); var type = assembly.GetType(CommandName, true, true); IIpnHandler command = Activator.CreateInstance(type) as IIpnHandler; command.HandlePapara(Args, TransactionID, Amount); Order.IsPaid = true; Order.Save(); context.Response.Redirect(ButtonGenerationStrategy.SUCCESS_URL); } catch (Exception ex) { ErrorLogger.Log(ex); context.Response.Redirect(ButtonGenerationStrategy.FAILURE_URL); } } else { context.Response.Redirect(ButtonGenerationStrategy.FAILURE_URL); } }
public static PaparaOrder Get(int id) { var result = new PaparaOrder(id); if (!result.IsPaid) { return(result); } return(null); }
public static int Create(Money amount, string command, string args) { PaparaOrder order = new PaparaOrder(); order.Amount = amount; order.CommandName = command; order.Args = args; order.DateAdded = AppSettings.ServerTime; order.IsPaid = false; order.Save(); return(order.Id); }