/// <summary> /// Method for making group trasaction /// </summary> /// <param name="transactionType">type of transaction</param> /// <param name="amount">amount</param> /// <param name="accounts">list of accounts</param> /// <returns></returns> public TransactionStatus ProcessGroupTransaction(TransactionType transactionType, CurrencyAmount amount, IAccount[] accounts) { TransactionStatus result = TransactionStatus.Failed; if (transactionType.Equals(TransactionType.Credit)) { foreach (IAccount account in accounts) { account.CreditAmmout(amount); CallExternalLogger(account, transactionType, amount); } result = TransactionStatus.Completed; } else if (transactionType.Equals(TransactionType.Debit)) { foreach (IAccount account in accounts) { account.DebitAmmout(amount); CallExternalLogger(account, transactionType, amount); } result = TransactionStatus.Completed; } LogTransaction(transactionType, amount, accounts, result); return(result); }
public Transaction ProcessSecure3d(Secure3dBuilder builder) { TransactionType transType = builder.TransactionType; if (transType.Equals(TransactionType.VerifyEnrolled)) { AuthorizationBuilder authBuilder = new AuthorizationBuilder(transType, builder.PaymentMethod) .WithAmount(builder.Amount) .WithCurrency(builder.Currency) .WithOrderId(builder.OrderId); return(ProcessAuthorization(authBuilder)); } else if (transType.Equals(TransactionType.VerifySignature)) { // get our three d secure object ThreeDSecure secureEcom = builder.ThreeDSecure; // create our transaction reference TransactionReference reference = new TransactionReference { OrderId = secureEcom.OrderId }; ManagementBuilder managementBuilder = new ManagementBuilder(transType) .WithAmount(secureEcom.Amount) .WithCurrency(secureEcom.Currency) .WithPayerAuthenticationResponse(builder.PayerAuthenticationResponse) .WithPaymentMethod(reference); return(ManageTransaction(managementBuilder)); } throw new UnsupportedTransactionException(string.Format("Unknown transaction type {0}", transType)); }
public Transaction ManageTransaction(ManagementBuilder builder) { var et = new ElementTree(); TransactionType transactionType = builder.TransactionType; var transaction = et.Element(MapRequestType(builder)) .Set("xmlns", "http://schemas.merchantwarehouse.com/merchantware/v45/"); // Credentials var credentials = et.SubElement(transaction, "Credentials"); et.SubElement(credentials, "MerchantName").Text(MerchantName); et.SubElement(credentials, "MerchantSiteId").Text(MerchantSiteId); et.SubElement(credentials, "MerchantKey").Text(MerchantKey); // Payment Data if (transactionType.Equals(TransactionType.Refund)) { var paymentData = et.SubElement(transaction, "PaymentData"); et.SubElement(paymentData, "Source").Text("PreviousTransaction"); et.SubElement(paymentData, "Token", builder.TransactionId); } // Request var request = et.SubElement(transaction, "Request"); if (!transactionType.Equals(TransactionType.Refund)) { et.SubElement(request, "Token", builder.TransactionId); } et.SubElement(request, "Amount", builder.Amount.ToCurrencyString()); et.SubElement(request, "InvoiceNumber", builder.InvoiceNumber); et.SubElement(request, "RegisterNumber", RegisterNumber); et.SubElement(request, "MerchantTransactionId", builder.ClientTransactionId); et.SubElement(request, "CardAcceptorTerminalId", TerminalId); if (transactionType.Equals(TransactionType.TokenDelete) || transactionType.Equals(TransactionType.TokenUpdate)) { var card = builder.PaymentMethod as CreditCardData; et.SubElement(request, "VaultToken", card.Token); if (transactionType.Equals(TransactionType.TokenUpdate)) { et.SubElement(request, "ExpirationDate", card.ShortExpiry); } } var response = DoTransaction(BuildEnvelope(et, transaction)); return(MapResponse(builder, response)); }
private void NoTransferOnlySecurites() { if (_SecuritiesTrade == null || _TransactionType.Equals(TransactionType.Transfer)) { throw new Exception("No available on transfer"); } }
public void Should_return_true() { var alpha = new TransactionType { Name = "foo", }; var beta = new TransactionType { Name = "FOO" }; alpha.Equals(beta).ShouldBeTrue(); }
public void Should_return_false() { var alpha = new TransactionType { Name = "foo", }; var beta = new TransactionType { Name = "bar" }; alpha.Equals(beta).ShouldBeFalse(); }
public long InsertTransaction(Transaction t, TransactionType type) { SQLiteCommand command = new SQLiteCommand(_conn); SQLiteTransaction dbTransaction = null; try { dbTransaction = _conn.BeginTransaction(); float value = GetValue() * t.quantity; if ((type.Equals(TransactionType.BUY) && GetUser(t.buyer).balance >= value) || (type.Equals(TransactionType.SELL) && GetAvailableDiginotes(t.seller, t.quantity).Count >= t.quantity)) { bool success = InsertTransactionDirect(t); if (success) { long rowID = _conn.LastInsertRowId; dbTransaction.Commit(); return(rowID); } } dbTransaction.Rollback(); return(-1); } catch (SQLiteException e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); if (dbTransaction != null) { dbTransaction.Rollback(); } return(-1); } }
public override bool Equals(object obj) { var cpl = obj as FakeAgentDisplayRule; if (cpl == null) { return(false); } return(LetterType.Equals(cpl.LetterType) && TransactionPropertyState.Equals(cpl.TransactionPropertyState) && TransactionType.Equals(cpl.TransactionType) && Underwriter.Equals(cpl.Underwriter)); }
//Sales Return public bool SalesReturn(DataTable transfarData, TransactionType transactionType, DBQueres DataWriter, DatabaseRead DataReader, MysqlRowCounter TableRowCounter) { try { DataRow transfarDataRow = transfarData.Rows[0]; AccountingDataSet commonDataSet = new AccountingDataSet(); DataWriter(string.Format("INSERT INTO {0} VALUES('{1}','{2}','{3}','{4}',{5},{6},{7},{8},0,0,{9}-{8})",thisDataSet.ThisTables[20][0],transfarDataRow[0],transfarDataRow[2],transfarDataRow[1],transactionType.Equals(TransactionType.Cash) ? TransactionType.Cash : TransactionType.Credit, transfarDataRow[3],transfarDataRow[4],transfarDataRow[5],transfarDataRow[6],LastRowVaue(thisDataSet.ThisColumn[9][0].ToString(),thisDataSet.ThisTables[20][0].ToString(),new DatabaseRead(DataReader),new MysqlRowCounter(TableRowCounter)))); commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0],transfarDataRow[1],transfarDataRow[2],transfarDataRow[3],transfarDataRow[4],transfarDataRow[5],transfarDataRow[6],transfarDataRow[7]); StockOperation(commonDataSet.ThisCommonUse, ProductOperationType.Purchase, new DBQueres(DataWriter), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)); if (transactionType.Equals(TransactionType.Cash)) { commonDataSet.ThisCommonUse.Clear(); commonDataSet.ThisCommonUse.Dispose(); //Column : 0 Petunia_Date commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[7]); //Column : 1 Description return CashOperation(commonDataSet.ThisCommonUse, TransactionType.Credit, new DBQueres(DataWriter), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)); //Column : 2 Transaction /\ Product_ID } //Column : 3 Quantity else if (transactionType.Equals(TransactionType.debt)) //Column : 4 Rate { //Column : 5 Average_Rate commonDataSet.ThisCommonUse.Clear(); //Column : 6 Invoice_Number commonDataSet.ThisCommonUse.Dispose(); //Column : 7 Debt_Tk Or credit_Tk commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[7], transfarDataRow[8],transfarDataRow[9]); //Column : 8 User_ID return CreditorsAndDebitorsAccount(commonDataSet.ThisCommonUse, TransactionType.debt, new DatabaseRead(DataReader), new DBQueres(DataWriter), new MysqlRowCounter(TableRowCounter)); //Column :9 Product_ID } else { return false; } } catch { return false; } }
private bool TransactionTypeEquals(TransactionType transactionType) { return(TransactionType.Equals(transactionType.ToString(), StringComparison.OrdinalIgnoreCase)); }
//Insert Creditors Account public bool CreditorsAndDebitorsAccount(DataTable transfarData,TransactionType transactionType,DatabaseRead DataReder,DBQueres DataWriter,MysqlRowCounter TableRowCounter) { try { DataRow transfarDataRow = transfarData.Rows[0]; // column :0 PETUNIA_DATE if (transactionType.Equals(TransactionType.Credit)) // column :1 DESCRIPTION { // column :2 CREDIT_TK or DEBIT_TK DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}',0,{5},0,{6}+{5})", thisDataSet.ThisTables[5][0], transfarDataRow[0], transfarDataRow[3], transfarDataRow[4], transfarDataRow[1], transfarDataRow[2], LastRowVaue(thisDataSet.ThisColumn[9][0].ToString(), thisDataSet.ThisTables[5][0].ToString(), new DatabaseRead(DataReder), new MysqlRowCounter(TableRowCounter)))); DataWriter(string.Format("UPDATE {0} SET {1}={1}+{2} WHERE {3}='{4}'",thisDataSet.ThisTables[3][0],thisDataSet.ThisColumn[6][0],transfarDataRow[2],thisDataSet.ThisColumn[12][0],transfarDataRow[3])); // column :3 User_ID return DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}',0,{5},0,0)",thisDataSet.ThisTables[24][0],transfarDataRow[0],transfarDataRow[3],transfarDataRow[4],transfarDataRow[1],transfarDataRow[2]));//need update Credit_Balance_Tk //Column : 4 Product ID } else if (transactionType.Equals(TransactionType.debt)) { DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}',{5},0,{6}-{5},0)", thisDataSet.ThisTables[7][0], transfarDataRow[0], transfarDataRow[3], transfarDataRow[4], transfarDataRow[1], transfarDataRow[2], LastRowVaue(thisDataSet.ThisColumn[9][0].ToString(), thisDataSet.ThisTables[7][0].ToString(), new DatabaseRead(DataReder), new MysqlRowCounter(TableRowCounter)))); DataWriter(string.Format("UPDATE {0} SET {1}={1}-{2} WHERE {3}='{4}'", thisDataSet.ThisTables[3][0], thisDataSet.ThisColumn[7][0], transfarDataRow[2], thisDataSet.ThisColumn[12][0], transfarDataRow[3])); return DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}',{5},0,0,0)", thisDataSet.ThisTables[24][0], transfarDataRow[0],transfarDataRow[3], transfarDataRow[4], transfarDataRow[1], transfarDataRow[2]));//need update Credit_Balance_Tk } else { return false; } } catch (Exception) { return false; } }
//Initial Balance Insert public bool InitialBalanceInsert(string amount ,TransactionType transactionType, DBQueres DataWriter, DatabaseRead DataReader, MysqlRowCounter TableRowCounter) { try { if (transactionType.Equals(TransactionType.Cash)) { DataWriter(string.Format("INSERT INFO {0} VALUES('{1}','0',{2},0,{3}+{2},0)",thisDataSet.ThisTables[2][0],AccountingVariables.PETUNIA_DATE,amount,LastRowVaue(thisDataSet.ThisColumn[8][0].ToString(),thisDataSet.ThisTables[2][0].ToString(),new DatabaseRead(DataReader),new MysqlRowCounter(TableRowCounter)))); return true; } else if (transactionType.Equals(TransactionType.bank)) { DataWriter(string.Format("INSERT INFO {0} VALUES('{1}','{2}',0,{3}+{2},0,0)", thisDataSet.ThisTables[1][0], AccountingVariables.PETUNIA_DATE, amount, LastRowVaue(thisDataSet.ThisColumn[8][0].ToString(), thisDataSet.ThisTables[1][0].ToString(), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)))); return true; } else { return false; } } catch { return false; } }
//Column : 0 Petunia_Date //Insert & Update Cash debt or credits private bool CashOperation(DataTable transfarData, TransactionType transactionType, DBQueres DataWriter, DatabaseRead DataReader, MysqlRowCounter TableRowCounter) { //Column : 1 Description try //Column : 2 Credit Taka or Debt Taka { //Column : DataRow transfarDataRow = transfarData.Rows[0]; if (transactionType.Equals(TransactionType.debt)) { DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}',{3},0,{4}+{3},0)", thisDataSet.ThisTables[2][0].ToString(), transfarDataRow[0], transfarDataRow[1], transfarDataRow[2], LastRowVaue(thisDataSet.ThisColumn[8][0].ToString(), thisDataSet.ThisTables[2][0].ToString(), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)))); return DataWriter(string.Format("UPDATE {0} SET {1}={1}+{2}, {3}={3}+{2} WHERE {4}='{5}'", thisDataSet.ThisTables[6][0].ToString(), thisDataSet.ThisColumn[6][0], transfarDataRow[2], thisDataSet.ThisColumn[8][0], thisDataSet.ThisColumn[0][0].ToString(), transfarDataRow[0])); } else if(transactionType.Equals(TransactionType.Credit)) { DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}',0,{3},{4}-{3},0)", thisDataSet.ThisTables[2][0].ToString(), transfarDataRow[0], transfarDataRow[1], transfarDataRow[2], LastRowVaue(thisDataSet.ThisColumn[8][0].ToString(), thisDataSet.ThisTables[2][0].ToString(), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)))); return DataWriter(string.Format("UPDATE {0} SET {1}={1}-{2}, {3}={3}-{2} WHERE {4}='{5}'", thisDataSet.ThisTables[6][0].ToString(), thisDataSet.ThisColumn[7][0], transfarDataRow[2], thisDataSet.ThisColumn[8][0], thisDataSet.ThisColumn[0][0].ToString(), transfarDataRow[0])); } else { return false; } } catch { return false; } }
//Office Instrument public bool OfficeInstrumentLedger(DataTable transfarData, TransactionType transactionType, DBQueres DataWriter, DatabaseRead DataReader, MysqlRowCounter TableRowCounter) { try { AccountingDataSet commonDataSet = new AccountingDataSet(); DataRow transfarDataRow = transfarData.Rows[0]; DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}',{3},0,{4}+{3},0)",thisDataSet.ThisTables[14][0], transfarDataRow[0], transfarDataRow[1], transfarDataRow[3], LastRowVaue(thisDataSet.ThisColumn[8][0].ToString(), thisDataSet.ThisTables[10][0].ToString(), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)))); if (transactionType.Equals(TransactionType.Cash)) { commonDataSet.ThisCommonUse.Clear(); commonDataSet.ThisCommonUse.Dispose(); //Column : 0 Petunia_Date commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[3]); //Column : 1 Description return CashOperation(commonDataSet.ThisCommonUse, TransactionType.Credit, new DBQueres(DataWriter), new DatabaseRead(DataReader), new MysqlRowCounter(TableRowCounter)); //Column : 2 Debt_Tk Or credit_Tk } else if (transactionType.Equals(TransactionType.check)) { commonDataSet.ThisCommonUse.Clear(); commonDataSet.ThisCommonUse.Dispose(); commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[3]); return BankAccount(commonDataSet.ThisCommonUse, TransactionType.debt, new DatabaseRead(DataReader), new DBQueres(DataWriter), new MysqlRowCounter(TableRowCounter)); } else if (transactionType.Equals(TransactionType.Credit)) { commonDataSet.ThisCommonUse.Clear(); commonDataSet.ThisCommonUse.Dispose(); commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[3], transfarDataRow[4]); return CreditorsAndDebitorsAccount(commonDataSet.ThisCommonUse, TransactionType.Credit, new DatabaseRead(DataReader), new DBQueres(DataWriter), new MysqlRowCounter(TableRowCounter)); } else { return false; } } catch { return false; } }
public ThreeDSecure Execute(Secure3dVersion version, string configName = "default") { Validations.Validate(this); // setup return object ThreeDSecure rvalue = ThreeDSecure; if (rvalue == null) { rvalue = new ThreeDSecure(); rvalue.Version = version; } // working version if (rvalue.Version != null) { version = rvalue.Version.Value; } // get the provider ISecure3dProvider provider = ServicesContainer.Instance.GetSecure3d(configName, version); if (provider != null) { bool canDowngrade = false; if (provider.Version.Equals(Secure3dVersion.Two) && version.Equals(Secure3dVersion.Any)) { try { var oneProvider = ServicesContainer.Instance.GetSecure3d(configName, Secure3dVersion.One); canDowngrade = (oneProvider != null); } catch (ConfigurationException) { /* NOT CONFIGURED */ } } /* process the request, capture any exceptions which might have been thrown */ Transaction response = null; try { response = provider.ProcessSecure3d(this); if (response == null && canDowngrade) { return(Execute(Secure3dVersion.One, configName)); } } catch (GatewayException exc) { // check for not enrolled if ("110".Equals(exc.ResponseCode) && provider.Version.Equals(Secure3dVersion.One)) { return(rvalue); } // check if we can downgrade else if (canDowngrade && TransactionType.Equals(TransactionType.VerifyEnrolled)) { return(Execute(Secure3dVersion.One, configName)); } // throw exception else { throw exc; } } // check the response if (response != null) { switch (TransactionType) { case TransactionType.VerifyEnrolled: { if (response.ThreeDSecure != null) { rvalue = response.ThreeDSecure; if (new List <string>() { "True", "Y" }.Contains(rvalue.Enrolled)) { rvalue.Amount = Amount; rvalue.Currency = Currency; rvalue.OrderId = response.OrderId; rvalue.Version = provider.Version; } else if (canDowngrade) { return(Execute(Secure3dVersion.One, configName)); } } else if (canDowngrade) { return(Execute(Secure3dVersion.One, configName)); } } break; case TransactionType.InitiateAuthentication: case TransactionType.VerifySignature: { rvalue.Merge(response.ThreeDSecure); } break; } } } return(rvalue); }
//Sales Ledger public bool SalesLedger(DataTable transfarData, TransactionType transactionType, DBQueres DataWriter, DatabaseRead DataReadr, MysqlRowCounter TableRowCounter) { try { AccountingDataSet commonDataSet = new AccountingDataSet(); DataRow transfarDataRow=transfarData.Rows[0]; DataWriter(string.Format("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}','{5}','{6}',{7},0,{8},0,{9}+{8})", thisDataSet.ThisTables[20][0], transfarDataRow[0],transfarDataRow[6],transfarDataRow[1], transactionType, transfarDataRow[2], transfarDataRow[3], transfarDataRow[4], transfarDataRow[5],LastRowVaue(thisDataSet.ThisColumn[9][0].ToString(),thisDataSet.ThisTables[20][0].ToString(),new DatabaseRead(DataReadr),new MysqlRowCounter(TableRowCounter)))); commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], ProductOperationType.Sales, transfarDataRow[2],Convert.ToDouble(transfarDataRow[2]) * Convert.ToDouble(transfarDataRow[8]),transfarDataRow[8], transfarDataRow[4], transfarDataRow[5], transfarDataRow[6]); StockOperation(commonDataSet.ThisCommonUse, ProductOperationType.Sales, new DBQueres(DataWriter), new DatabaseRead(DataReadr), new MysqlRowCounter(TableRowCounter)); if (transactionType.Equals(TransactionType.Cash)) { commonDataSet.ThisCommonUse.Clear(); //Column :0 Petunia_Date commonDataSet.ThisCommonUse.Dispose(); //Column :1 Description commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1],transfarDataRow[5]); //Column :2 Transaction //should be remove return CashOperation(commonDataSet.ThisCommonUse, TransactionType.debt, new DBQueres(DataWriter), new DatabaseRead(DataReadr), new MysqlRowCounter(TableRowCounter)); //Column :2 Quantity } //Column :3 Rate else if (transactionType.Equals(TransactionType.Credit)) //Column :4 Invoice_Number { //Column :5 Debt_Tk or Credit_tk commonDataSet.ThisCommonUse.Clear(); //Column :6 Product_ID commonDataSet.ThisCommonUse.Dispose(); //Column :7 User_ID commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[10]); //Column :8 Average_Rate CashOperation(commonDataSet.ThisCommonUse, TransactionType.debt, new DBQueres(DataWriter), new DatabaseRead(DataReadr), new MysqlRowCounter(TableRowCounter)); //Column :9 Credit Balance commonDataSet.ThisCommonUse.Clear(); //Column :10 Payment Balance commonDataSet.ThisCommonUse.Dispose(); commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[9], transfarDataRow[7], transfarDataRow[6]); return CreditorsAndDebitorsAccount(commonDataSet.ThisCommonUse, TransactionType.debt, new DatabaseRead(DataReadr), new DBQueres(DataWriter), new MysqlRowCounter(TableRowCounter)); } else if (transactionType.Equals(TransactionType.check)) { commonDataSet.ThisCommonUse.Clear(); commonDataSet.ThisCommonUse.Dispose(); commonDataSet.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[5]); return BankAccount(commonDataSet.ThisCommonUse, TransactionType.Credit, new DatabaseRead(DataReadr), new DBQueres(DataWriter), new MysqlRowCounter(TableRowCounter)); } else { return false; } } catch { return false; } }
//Purchase Ledger public bool PurchaseLedger(DataTable transfarData, TransactionType transactionType, DBQueres DataWrite, DatabaseRead DataRader, MysqlRowCounter TableRowCounter) { try { AccountingDataSet commonDataSat = new AccountingDataSet(); DataRow transfarDataRow = transfarData.Rows[0]; //string tableStockLedger = thisDataSet.ThisTables.Rows[0][thisDataSet.ThisTables.Columns[0].ToString()].ToString(); DataWrite(string.Format("INSERT INTO {0} VALUES('{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}',{9},0,{10}+{9},0)", thisDataSet.ThisTables[17][0], transfarDataRow[0],transfarDataRow[8], transfarDataRow[1], transactionType, transfarDataRow[2], transfarDataRow[3], transfarDataRow[4], transfarDataRow[5], transfarDataRow[6], LastRowVaue(thisDataSet.ThisColumn[8][0].ToString(), thisDataSet.ThisTables[17][0].ToString(), new DatabaseRead(DataRader), new MysqlRowCounter(TableRowCounter)))); //PurchaseLedger commonDataSat.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1],ProductOperationType.Purchase, transfarDataRow[2],transfarDataRow[6],transfarDataRow[4],transfarDataRow[5],transfarDataRow[6],transfarDataRow[8]); StockOperation(commonDataSat.ThisCommonUse, ProductOperationType.Purchase, new DBQueres(DataWrite),new DatabaseRead(DataRader),new MysqlRowCounter(TableRowCounter)); if (transactionType.Equals(TransactionType.Cash)) //Column : 0 Petunia_Date { //Column : 1 Description commonDataSat.ThisCommonUse.Clear(); //Column : 2 Transaction="";\\Should be Remove commonDataSat.ThisCommonUse.Dispose(); //Column : 2 Quantity commonDataSat.ThisCommonUse.Rows.Add(transfarDataRow[0],transfarDataRow[1],transfarDataRow[6]); //Column : 3 Rate return CashOperation(commonDataSat.ThisCommonUse, TransactionType.Credit, new DBQueres(DataWrite), new DatabaseRead(DataRader), new MysqlRowCounter(TableRowCounter)); //Column : 4 Average_Rate } //Column : 5 Invoice_Number else if (transactionType.Equals(TransactionType.check)) //Column : 6 Debt_Tk or Credit_Tk { //Column : 7 User_ID commonDataSat.ThisCommonUse.Clear(); //Column : 8 ProductID commonDataSat.ThisCommonUse.Dispose(); //Column : 9 Credit Balance commonDataSat.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[6]); //Column :10 Payment Balance return BankAccount(commonDataSat.ThisCommonUse, TransactionType.Credit, new DatabaseRead(DataRader), new DBQueres(DataWrite), new MysqlRowCounter(TableRowCounter)); } else if (transactionType.Equals(TransactionType.Credit)) { commonDataSat.ThisCommonUse.Clear(); commonDataSat.ThisCommonUse.Dispose(); commonDataSat.ThisCommonUse.Rows.Add(transfarDataRow[0], transfarDataRow[1], transfarDataRow[10]); CashOperation(commonDataSat.ThisCommonUse, TransactionType.Credit, new DBQueres(DataWrite), new DatabaseRead(DataRader), new MysqlRowCounter(TableRowCounter)); commonDataSat.ThisCommonUse.Clear(); commonDataSat.ThisCommonUse.Dispose(); commonDataSat.ThisCommonUse.Rows.Add(transfarDataRow[0],transactionType,transfarDataRow[9],transfarDataRow[7],transfarDataRow[8]); return CreditorsAndDebitorsAccount(commonDataSat.ThisCommonUse, TransactionType.Credit, new DatabaseRead(DataRader), new DBQueres(DataWrite), new MysqlRowCounter(TableRowCounter)); } else { return false; } } catch { return false; } }
public Transaction ProcessSecure3d(Secure3dBuilder builder) { TransactionType transType = builder.TransactionType; IPaymentMethod paymentMethod = builder.PaymentMethod; ISecure3d secure3d = (ISecure3d)paymentMethod; string timestamp = DateTime.Now.ToString("yyyy-MM-dd'T'hh:mm:ss.ffffff"); JsonDoc request = new JsonDoc(); if (transType.Equals(TransactionType.VerifyEnrolled)) { request.Set("request_timestamp", timestamp); request.Set("merchant_id", MerchantId); request.Set("account_id", AccountId); request.Set("method_notification_url", MethodNotificationUrl); string hashValue = string.Empty; if (paymentMethod is CreditCardData cardData) { request.Set("number", cardData.Number); request.Set("scheme", MapCardScheme(cardData.CardType.ToUpper())); hashValue = cardData.Number; } else if (paymentMethod is RecurringPaymentMethod storedCard) { request.Set("payer_reference", storedCard.CustomerKey); request.Set("payment_method_reference", storedCard.Key); hashValue = storedCard.CustomerKey; } string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, hashValue); SetAuthHeader(hash); string rawResponse = DoTransaction(HttpMethod.Post, "protocol-versions", request.ToString()); return(MapResponse(rawResponse)); } else if (transType.Equals(TransactionType.VerifySignature)) { string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, builder.ServerTransactionId); SetAuthHeader(hash); var queryValues = new Dictionary <string, string>(); queryValues.Add("merchant_id", MerchantId); queryValues.Add("request_timestamp", timestamp); string rawResponse = DoTransaction(HttpMethod.Get, string.Format("authentications/{0}", builder.ServerTransactionId), null, queryValues); return(MapResponse(rawResponse)); } else if (transType.Equals(TransactionType.InitiateAuthentication)) { string orderId = builder.OrderId; if (string.IsNullOrEmpty(orderId)) { orderId = GenerationUtils.GenerateOrderId(); } ThreeDSecure secureEcom = secure3d.ThreeDSecure; request.Set("request_timestamp", timestamp); request.Set("authentication_source", builder.AuthenticationSource.ToString()); request.Set("authentication_request_type", builder.AuthenticationRequestType.ToString()); request.Set("message_category", builder.MessageCategory.ToString()); request.Set("message_version", "2.1.0"); request.Set("server_trans_id", secureEcom.ServerTransactionId); request.Set("merchant_id", MerchantId); request.Set("account_id", AccountId); request.Set("challenge_notification_url", ChallengeNotificationUrl); request.Set("method_url_completion", builder.MethodUrlCompletion.ToString()); request.Set("merchant_contact_url", MerchantContactUrl); request.Set("merchant_initiated_request_type", builder.MerchantInitiatedRequestType?.ToString()); request.Set("whitelist_status", builder.WhitelistStatus); request.Set("decoupled_flow_request", builder.DecoupledFlowRequest); request.Set("decoupled_flow_timeout", builder.DecoupledFlowTimeout); request.Set("decoupled_notification_url", builder.DecoupledNotificationUrl); request.Set("enable_exemption_optimization", builder.EnableExemptionOptimization); // card details string hashValue = string.Empty; JsonDoc cardDetail = request.SubElement("card_detail"); if (paymentMethod is CreditCardData cardData) { hashValue = cardData.Number; cardDetail.Set("number", cardData.Number); cardDetail.Set("scheme", cardData.CardType.ToUpper()); cardDetail.Set("expiry_month", cardData.ExpMonth.ToString()); cardDetail.Set("expiry_year", cardData.ExpYear.ToString().Substring(2)); cardDetail.Set("full_name", cardData.CardHolderName); if (!string.IsNullOrEmpty(cardData.CardHolderName)) { string[] names = cardData.CardHolderName.Split(' '); if (names.Length >= 1) { cardDetail.Set("first_name", names[0]); } if (names.Length >= 2) { cardDetail.Set("last_name", string.Join(" ", names.Skip(1))); } } } else if (paymentMethod is RecurringPaymentMethod storedCard) { hashValue = storedCard.CustomerKey; cardDetail.Set("payer_reference", storedCard.CustomerKey); cardDetail.Set("payment_method_reference", storedCard.Key); } // order details JsonDoc order = request.SubElement("order"); order.Set("amount", builder.Amount.ToNumericCurrencyString()); order.Set("currency", builder.Currency); order.Set("id", orderId); order.Set("address_match_indicator", builder.AddressMatchIndicator ? "true" : "false"); order.Set("date_time_created", builder.OrderCreateDate?.ToString("yyyy-MM-dd'T'hh:mm'Z'")); order.Set("gift_card_count", builder.GiftCardCount); order.Set("gift_card_currency", builder.GiftCardCurrency); order.Set("gift_card_amount", builder.GiftCardAmount.ToNumericCurrencyString()); order.Set("delivery_email", builder.DeliveryEmail); order.Set("delivery_timeframe", builder.DeliveryTimeframe?.ToString()); order.Set("shipping_method", builder.ShippingMethod?.ToString()); order.Set("shipping_name_matches_cardholder_name", builder.ShippingNameMatchesCardHolderName); order.Set("preorder_indicator", builder.PreOrderIndicator?.ToString()); order.Set("reorder_indicator", builder.ReorderIndicator?.ToString()); order.Set("transaction_type", builder.OrderTransactionType?.ToString()); order.Set("preorder_availability_date", builder.PreOrderAvailabilityDate?.ToString("yyyy-MM-dd")); // shipping address Address shippingAddress = builder.ShippingAddress; if (shippingAddress != null) { JsonDoc shippingAddressElement = order.SubElement("shipping_address"); shippingAddressElement.Set("line1", shippingAddress.StreetAddress1); shippingAddressElement.Set("line2", shippingAddress.StreetAddress2); shippingAddressElement.Set("line3", shippingAddress.StreetAddress3); shippingAddressElement.Set("city", shippingAddress.City); shippingAddressElement.Set("postal_code", shippingAddress.PostalCode); shippingAddressElement.Set("state", shippingAddress.State); shippingAddressElement.Set("country", shippingAddress.CountryCode); } // payer JsonDoc payer = request.SubElement("payer"); payer.Set("email", builder.CustomerEmail); payer.Set("id", builder.CustomerAccountId); payer.Set("account_age", builder.AccountAgeIndicator?.ToString()); payer.Set("account_creation_date", builder.AccountCreateDate?.ToString("yyyy-MM-dd")); payer.Set("account_change_indicator", builder.AccountChangeIndicator?.ToString()); payer.Set("account_change_date", builder.AccountChangeDate?.ToString("yyyy-MM-dd")); payer.Set("account_password_change_indicator", builder.PasswordChangeIndicator?.ToString()); payer.Set("account_password_change_date", builder.PasswordChangeDate?.ToString("yyyy-MM-dd")); payer.Set("payment_account_age_indicator", builder.PaymentAgeIndicator?.ToString()); payer.Set("payment_account_creation_date", builder.PaymentAccountCreateDate?.ToString("yyyy-MM-dd")); payer.Set("purchase_count_last_6months", builder.NumberOfPurchasesInLastSixMonths); payer.Set("transaction_count_last_24hours", builder.NumberOfTransactionsInLast24Hours); payer.Set("transaction_count_last_year", builder.NumberOfTransactionsInLastYear); payer.Set("provision_attempt_count_last_24hours", builder.NumberOfAddCardAttemptsInLast24Hours); payer.Set("shipping_address_creation_indicator", builder.ShippingAddressUsageIndicator?.ToString()); payer.Set("shipping_address_creation_date", builder.ShippingAddressCreateDate?.ToString("yyyy-MM-dd")); // suspicious activity if (builder.PreviousSuspiciousActivity != null) { payer.Set("suspicious_account_activity", builder.PreviousSuspiciousActivity.Value ? "SUSPICIOUS_ACTIVITY" : "NO_SUSPICIOUS_ACTIVITY"); } // home phone if (!string.IsNullOrEmpty(builder.HomeNumber)) { payer.SubElement("home_phone") .Set("country_code", builder.HomeCountryCode) .Set("subscriber_number", builder.HomeNumber); } // work phone if (!string.IsNullOrEmpty(builder.WorkNumber)) { payer.SubElement("work_phone") .Set("country_code", builder.WorkCountryCode) .Set("subscriber_number", builder.WorkNumber); } // payer login data if (builder.HasPayerLoginData) { request.SubElement("payer_login_data") .Set("authentication_data", builder.CustomerAuthenticationData) .Set("authentication_timestamp", builder.CustomerAuthenticationTimestamp?.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")) .Set("authentication_type", builder.CustomerAuthenticationMethod?.ToString()); } // prior authentication data if (builder.HasPriorAuthenticationData) { request.SubElement("payer_prior_three_ds_authentication_data") .Set("authentication_method", builder.PriorAuthenticationMethod?.ToString()) .Set("acs_transaction_id", builder.PriorAuthenticationTransactionId) .Set("authentication_timestamp", builder.PriorAuthenticationTimestamp?.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")) .Set("authentication_data", builder.PriorAuthenticationData); } // recurring authorization data if (builder.HasRecurringAuthData) { request.SubElement("recurring_authorization_data") .Set("max_number_of_instalments", builder.MaxNumberOfInstallments) .Set("frequency", builder.RecurringAuthorizationFrequency) .Set("expiry_date", builder.RecurringAuthorizationExpiryDate?.ToString("yyyy-MM-dd")); } // billing details Address billingAddress = builder.BillingAddress; if (billingAddress != null) { JsonDoc billingAddressElement = payer.SubElement("billing_address"); billingAddressElement.Set("line1", billingAddress.StreetAddress1); billingAddressElement.Set("line2", billingAddress.StreetAddress2); billingAddressElement.Set("line3", billingAddress.StreetAddress3); billingAddressElement.Set("city", billingAddress.City); billingAddressElement.Set("postal_code", billingAddress.PostalCode); billingAddressElement.Set("state", billingAddress.State); billingAddressElement.Set("country", billingAddress.CountryCode); } // mobile phone if (!string.IsNullOrEmpty(builder.MobileNumber)) { JsonDoc mobilePhone = payer.SubElement("mobile_phone"); mobilePhone.Set("country_code", builder.MobileCountryCode); mobilePhone.Set("subscriber_number", builder.MobileNumber); } // browser_data BrowserData broswerData = builder.BrowserData; if (broswerData != null) { JsonDoc browserDataElement = request.SubElement("browser_data"); browserDataElement.Set("accept_header", broswerData.AcceptHeader); browserDataElement.Set("color_depth", broswerData.ColorDepth.ToString()); browserDataElement.Set("ip", broswerData.IpAddress); browserDataElement.Set("java_enabled", broswerData.JavaEnabled); browserDataElement.Set("javascript_enabled", broswerData.JavaScriptEnabled); browserDataElement.Set("language", broswerData.Language); browserDataElement.Set("screen_height", broswerData.ScreenHeight); browserDataElement.Set("screen_width", broswerData.ScreenWidth); browserDataElement.Set("challenge_window_size", broswerData.ChallengeWindowSize.ToString()); browserDataElement.Set("timezone", broswerData.Timezone); browserDataElement.Set("user_agent", broswerData.UserAgent); } // mobile fields if (builder.HasMobileFields) { JsonDoc sdkInformationElement = request.SubElement("sdk_information") .Set("application_id", builder.ApplicationId) .Set("ephemeral_public_key", builder.EphemeralPublicKey) .Set("maximum_timeout", builder.MaximumTimeout) .Set("reference_number", builder.ReferenceNumber) .Set("sdk_trans_id", builder.SdkTransactionId) .Set("encoded_data", builder.EncodedData) ; // device render options if (builder.SdkInterface != null || builder.SdkUiTypes != null) { var dro = sdkInformationElement.SubElement("device_render_options"); dro.Set("sdk_interface", builder.SdkInterface?.ToString()); if (builder.SdkUiTypes != null) { var uiTypes = new List <string>(); foreach (var sdkuiType in builder.SdkUiTypes) { uiTypes.Add(sdkuiType.ToString()); } dro.Set("sdk_ui_type", uiTypes.ToArray()); } } } string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, hashValue, secureEcom.ServerTransactionId); SetAuthHeader(hash); string rawResponse = DoTransaction(HttpMethod.Post, "authentications", request.ToString()); return(MapResponse(rawResponse)); } throw new ApiException(string.Format("Unknown transaction type {0}.", transType)); }
//Insert into Bank private bool BankAccount(DataTable transfarData,TransactionType transactionType,DatabaseRead DataReder, DBQueres DataWriter, MysqlRowCounter TableRowCounter) { try { DataRow transfarDataRow = transfarData.Rows[0]; if (transactionType.Equals(TransactionType.debt)) //Max Column 3 { //Column : PETUNIA_DATE return DataWriter(string.Format("INSERT INTO {0} VALUES('{1}','{2}',0,{3},{4}-{3},0)", thisDataSet.ThisTables[1][0].ToString(), transfarDataRow[0], transfarDataRow[1], transfarDataRow[2], LastRowVaue(thisDataSet.ThisColumn[9][0].ToString(), thisDataSet.ThisTables[1][0].ToString(), new DatabaseRead(DataReder), new MysqlRowCounter(TableRowCounter)))); //Column : DESCRIPTION } //Column : DEBIT_TK or CREDIT_TK else if (transactionType.Equals(TransactionType.Credit)) { return DataWriter(string.Format("INSERT INTO {0} VALUES('{1}','{2}',{3},0,{4}+{3},0)", thisDataSet.ThisTables[1][0].ToString(), transfarDataRow[0], transfarDataRow[1], transfarDataRow[2], LastRowVaue(thisDataSet.ThisColumn[9][0].ToString(), thisDataSet.ThisTables[1][0].ToString(), new DatabaseRead(DataReder), new MysqlRowCounter(TableRowCounter)))); } else { return false; } } catch (Exception) { return false; } }