public static ResponsePersonalInformation GetCustomer(long customerNumber) { try { Customer customer = customerServices.SelectByCustomerNumber(customerNumber); ResponsePersonalInformation response = new ResponsePersonalInformation { CUSTOMER_NAME = customer.CUSTOMER_NAME, CUSTOMER_MIDDLE_NAME = customer.CUSTOMER_MIDDLE_NAME, CUSTOMER_SURNAME = customer.CUSTOMER_SURNAME, CUSTOMER_NUMBER = customer.CUSTOMER_NUMBER, EMAIL = customer.EMAIL, GENDER = customer.GENDER, IDENTIFICATION_ID = customer.IDENTIFICATION_ID, PHONE_NUMBER = customer.PHONE_NUMBER, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; return(response); } catch (Exception ex) { log.Error("An unexpected error occured while getting customer informations"); throw ex; } }
public bool CustomerOperation(RequestPersonalInformation request, out ResponsePersonalInformation response) { PersonalInformationOperation op = new PersonalInformationOperation(request); op.Execute(); response = op.response; if (!op.response.header.IsSuccess) { return(false); } return(true); }
public override void DoOperation() { try { //Validate Reques Header / Constants this.baseResponseMessage = ValidateInput(); if (!this.baseResponseMessage.header.IsSuccess) { throw new Exception(this.baseResponseMessage.header.ResponseMessage); } byte[] passwordHash, passwordSalt; //Operation switch (this.request.Header.OperationTypes) { case (int)OperationType.OperationTypes.ADD: long checkGuid = 0; //hash algorithm CreatePasswordHash(this.request.PASSWORD_HASH.ToString(), out passwordHash, out passwordSalt); this.customer = new Customer { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, CUSTOMER_NAME = this.request.CUSTOMER_NAME, CUSTOMER_SURNAME = this.request.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.request.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, PASSWORD_HASH = passwordHash, PASSWORD_SALT = passwordSalt, GENDER = this.request.GENDER, }; //Add Data to Database checkGuid = this.customerService.Insert(this.customer); string token = Tokenizer.CreateToken(checkGuid); this.response = new ResponsePersonalInformation { INSERT_USER = this.customer.INSERT_USER, UPDATE_USER = this.customer.UPDATE_USER, CUSTOMER_NAME = this.customer.CUSTOMER_NAME, CUSTOMER_SURNAME = this.customer.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.customer.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.customer.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.customer.IDENTIFICATION_ID, EMAIL = this.customer.EMAIL, PHONE_NUMBER = this.customer.PHONE_NUMBER, GENDER = this.request.GENDER, header = new ResponseHeader { IsSuccess = checkGuid == 0 ? false : true, ResponseCode = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS, ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE, Token = token } }; break; case (int)OperationType.OperationTypes.GET: //Get Data this.customer = customerService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER); this.response = new ResponsePersonalInformation { INSERT_USER = this.customer.INSERT_USER, UPDATE_USER = this.customer.UPDATE_USER, CUSTOMER_NAME = this.customer.CUSTOMER_NAME, CUSTOMER_SURNAME = this.customer.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.customer.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.customer.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.customer.IDENTIFICATION_ID, EMAIL = this.customer.EMAIL, PHONE_NUMBER = this.customer.PHONE_NUMBER, PASSWORD_HASH = this.customer.PASSWORD_HASH, PASSWORD_SALT = this.customer.PASSWORD_SALT, GENDER = this.request.GENDER, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; break; case (int)OperationType.OperationTypes.UPDATE: CreatePasswordHash(this.request.PASSWORD_HASH.ToString(), out passwordHash, out passwordSalt); this.customer = customerService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER); this.customer = new Customer { INSERT_USER = this.request.INSERT_USER, UPDATE_USER = this.request.UPDATE_USER, CUSTOMER_NAME = this.request.CUSTOMER_NAME, CUSTOMER_SURNAME = this.request.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.request.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, PASSWORD_HASH = this.customer.PASSWORD_HASH, PASSWORD_SALT = this.customer.PASSWORD_SALT, GENDER = this.request.GENDER, }; //Update Customer Information customerService.Update(this.customer); this.response = new ResponsePersonalInformation { INSERT_USER = this.customer.INSERT_USER, UPDATE_USER = this.customer.UPDATE_USER, CUSTOMER_NAME = this.customer.CUSTOMER_NAME, CUSTOMER_SURNAME = this.customer.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.customer.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.customer.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.customer.IDENTIFICATION_ID, EMAIL = this.customer.EMAIL, PHONE_NUMBER = this.customer.PHONE_NUMBER, GENDER = this.request.GENDER, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; break; case (int)OperationType.OperationTypes.DELETE: this.customer = customerService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER); this.customer = new Customer { INSERT_USER = this.request.INSERT_USER, RECORD_STATUS = 0, UPDATE_USER = this.request.UPDATE_USER, CUSTOMER_NAME = this.request.CUSTOMER_NAME, CUSTOMER_SURNAME = this.request.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.request.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.request.IDENTIFICATION_ID, EMAIL = this.request.EMAIL, PHONE_NUMBER = this.request.PHONE_NUMBER, GENDER = this.request.GENDER, }; //Update Customer to Passive customerService.Delete(this.customer); this.response = new ResponsePersonalInformation { INSERT_USER = this.customer.INSERT_USER, UPDATE_USER = this.customer.UPDATE_USER, CUSTOMER_NAME = this.customer.CUSTOMER_NAME, CUSTOMER_SURNAME = this.customer.CUSTOMER_SURNAME, CUSTOMER_MIDDLE_NAME = this.customer.CUSTOMER_MIDDLE_NAME, CUSTOMER_NUMBER = this.customer.CUSTOMER_NUMBER, IDENTIFICATION_ID = this.customer.IDENTIFICATION_ID, EMAIL = this.customer.EMAIL, PHONE_NUMBER = this.customer.PHONE_NUMBER, GENDER = this.request.GENDER, header = new ResponseHeader { IsSuccess = true, ResponseCode = CommonDefinitions.SUCCESS, ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE } }; break; default: break; } passwordHash = null; passwordSalt = null; } catch (Exception ex) { string operationError = "HATA:[" + "CustomerNumber:" + this.request.CUSTOMER_NUMBER + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]"; log.InfoFormat(operationError, ex); throw new Exception(ex.Message, ex.InnerException); } }
private CreatePaymentRequest Prepare3DRequest(ref Options baseHeader) { try { ResponsePersonalInformation responseCustomer = CommonServices.GetCustomer(this.request.CUSTOMER_NUMBER); ResponseCustomerAddress responseCustomerAddress = CommonServices.GetCustomerAddress(this.request.CUSTOMER_NUMBER); ResponseBoats responseBoat = CommonServices.GetBoatInfo(this.request.BOAT_ID); baseHeader = new Options(); baseHeader.ApiKey = this.request.ApiKey; // "sandbox-lJr5mWuuVSnwTa5Dt8bE6ohOi6chI463"; baseHeader.SecretKey = this.request.SecretKey; // "sandbox-yLkfxt1paeOWTZjV7qzn3rwyFPRrC6Cj"; baseHeader.BaseUrl = this.request.BaseUrl; // "https://sandbox-merchant.iyzipay.com"; CreatePaymentRequest paymentRequest = new CreatePaymentRequest(); paymentRequest.Locale = Locale.TR.ToString(); paymentRequest.ConversationId = this.request.CONVERSATION_ID; paymentRequest.Price = this.request.PRICE; paymentRequest.PaidPrice = this.request.PAID_PRICE; paymentRequest.Currency = Iyzipay.Model.Currency.TRY.ToString(); paymentRequest.Installment = 1; paymentRequest.BasketId = GenerateNumberManager.GenerateBasketId(); paymentRequest.PaymentChannel = PaymentChannel.WEB.ToString(); paymentRequest.PaymentGroup = PaymentGroup.PRODUCT.ToString(); paymentRequest.CallbackUrl = "https://www.merchant.com/callback"; paymentRequest.Buyer = new Iyzipay.Model.Buyer() { Id = this.request.CUSTOMER_NUMBER.ToString(), Name = responseCustomer.CUSTOMER_NAME, Surname = responseCustomer.CUSTOMER_SURNAME, GsmNumber = responseCustomer.PHONE_NUMBER, Email = responseCustomer.EMAIL, IdentityNumber = responseCustomer.IDENTIFICATION_ID.ToString(), LastLoginDate = DateTime.Now.ToShortDateString(), RegistrationDate = DateTime.Now.ToShortDateString(), RegistrationAddress = responseCustomerAddress.DESCRIPTION, Ip = this.request.IP, City = responseCustomerAddress.CITY, Country = responseCustomerAddress.COUNTRY, ZipCode = responseCustomerAddress.ZIPCODE }; paymentRequest.ShippingAddress = new Iyzipay.Model.Address() { ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME, City = responseCustomerAddress.CITY, Country = responseCustomerAddress.COUNTRY, ZipCode = responseCustomerAddress.ZIPCODE, Description = responseCustomerAddress.DESCRIPTION }; paymentRequest.BillingAddress = new Iyzipay.Model.Address() { ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME, City = responseCustomerAddress.CITY, Country = responseCustomerAddress.COUNTRY, ZipCode = responseCustomerAddress.ZIPCODE, Description = responseCustomerAddress.DESCRIPTION }; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem firstBasketItem = new BasketItem(); firstBasketItem.Id = paymentRequest.BasketId;//Sepet ID si geliştirilecek firstBasketItem.Name = responseBoat.BOAT_NAME; firstBasketItem.Category1 = responseBoat.TOUR_TYPE; firstBasketItem.Category2 = Enum.GetName(typeof(Enums.TourType), responseBoat.TOUR_TYPE); firstBasketItem.ItemType = BasketItemType.VIRTUAL.ToString(); firstBasketItem.Price = responseBoat.TOUR_TYPE == "1" ? responseBoat.PRICE : responseBoat.PRIVATE_PRICE; basketItems.Add(firstBasketItem); paymentRequest.BasketItems = basketItems; return(paymentRequest); } catch (Exception) { throw; } }
private CreatePaymentRequest PrepareRequest(ref bool result, ref string errMsg, ref Options baseHeader, ref string errCode) { try { Iyzipay.Request.CreatePaymentRequest paymentRequest = new Iyzipay.Request.CreatePaymentRequest(); ResponsePersonalInformation responseCustomer = CommonServices.GetCustomer(this.request.CUSTOMER_NUMBER); ResponseCustomerAddress responseCustomerAddress = CommonServices.GetCustomerAddress(this.request.CUSTOMER_NUMBER); ResponseBoats responseBoat = CommonServices.GetBoatInfo(this.request.BOAT_ID); baseHeader = new Options(); baseHeader.ApiKey = this.request.ApiKey; // "sandbox-lJr5mWuuVSnwTa5Dt8bE6ohOi6chI463"; baseHeader.SecretKey = this.request.SecretKey; // "sandbox-yLkfxt1paeOWTZjV7qzn3rwyFPRrC6Cj"; baseHeader.BaseUrl = this.request.BaseUrl; // "https://sandbox-merchant.iyzipay.com"; string cvc = ""; if (String.IsNullOrEmpty(this.request.PaymentCard.CARD_CVV)) { cvc = "000"; } else { cvc = this.request.PaymentCard.CARD_CVV; } paymentRequest.PaymentCard = new Iyzipay.Model.PaymentCard() { CardHolderName = this.request.PaymentCard.CARD_HOLDER_NAME, CardNumber = Common.CipherAlgorithm.Decrypt(this.request.PaymentCard.CARD_REF_NUMBER, CipherAlgorithm.password), ExpireMonth = this.request.PaymentCard.CARD_EXPIRE_MONTH, ExpireYear = this.request.PaymentCard.CARD_EXPIRE_YEAR, Cvc = cvc, RegisterCard = 0//default }; paymentRequest.Buyer = new Iyzipay.Model.Buyer() { Id = this.request.CUSTOMER_NUMBER.ToString(), Name = responseCustomer.CUSTOMER_NAME, Surname = responseCustomer.CUSTOMER_SURNAME, GsmNumber = responseCustomer.PHONE_NUMBER, Email = responseCustomer.EMAIL, IdentityNumber = responseCustomer.IDENTIFICATION_ID.ToString(), LastLoginDate = DateTime.Now.ToShortDateString(), RegistrationDate = DateTime.Now.ToShortDateString(), RegistrationAddress = responseCustomerAddress.DESCRIPTION, Ip = this.request.IP, City = responseCustomerAddress.CITY, Country = responseCustomerAddress.COUNTRY, ZipCode = responseCustomerAddress.ZIPCODE }; paymentRequest.ShippingAddress = new Iyzipay.Model.Address() { ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME, City = responseCustomerAddress.CITY, Country = responseCustomerAddress.COUNTRY, ZipCode = responseCustomerAddress.ZIPCODE, Description = responseCustomerAddress.DESCRIPTION }; paymentRequest.BillingAddress = new Iyzipay.Model.Address() { ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME, City = responseCustomerAddress.CITY, Country = responseCustomerAddress.COUNTRY, ZipCode = responseCustomerAddress.ZIPCODE, Description = responseCustomerAddress.DESCRIPTION }; List <BasketItem> basketItems = new List <BasketItem>(); BasketItem firstBasketItem = new BasketItem(); firstBasketItem.Id = GenerateNumberManager.GenerateBasketId(); firstBasketItem.Name = responseBoat.BOAT_NAME; firstBasketItem.Category1 = responseBoat.TOUR_TYPE; firstBasketItem.Category2 = Enum.GetName(typeof(Enums.TourType), responseBoat.TOUR_TYPE); firstBasketItem.ItemType = BasketItemType.VIRTUAL.ToString(); firstBasketItem.Price = responseBoat.TOUR_TYPE == "1" ? responseBoat.PRICE : responseBoat.PRIVATE_PRICE; basketItems.Add(firstBasketItem); paymentRequest.BasketItems = basketItems; paymentRequest.Locale = Locale.TR.ToString(); paymentRequest.ConversationId = this.request.CONVERSATION_ID; paymentRequest.Price = this.request.PRICE; paymentRequest.PaidPrice = (Convert.ToDecimal(this.request.PAID_PRICE) / 100).ToString().Replace(',', '.'); paymentRequest.Installment = 0; paymentRequest.BasketId = firstBasketItem.Id;//Sepet Id'si. paymentRequest.PaymentChannel = this.request.PAYMENT_CHANNEL.ToString(); paymentRequest.PaymentGroup = PaymentGroup.PRODUCT.ToString(); switch (this.request.CURRENCY) { case "949": paymentRequest.Currency = Iyzipay.Model.Currency.TRY.ToString(); break; case "840": paymentRequest.Currency = Iyzipay.Model.Currency.USD.ToString(); break; case "978": paymentRequest.Currency = Iyzipay.Model.Currency.EUR.ToString(); break; case "826": paymentRequest.Currency = Iyzipay.Model.Currency.GBP.ToString(); break; case "364": paymentRequest.Currency = Iyzipay.Model.Currency.IRR.ToString(); break; default: paymentRequest.Currency = ""; break; } if (String.IsNullOrEmpty(paymentRequest.Currency)) { errCode = CommonDefinitions.INTERNAL_SYSTEM_ERROR; errMsg = CommonDefinitions.CURRENCY_CODE_IS_NOT_VALID; result = false; log.Info("iyzico Sale Call.. Error on PrepareRequest. Detail : " + errMsg); } return(paymentRequest); } catch (Exception ex) { log.Error("Prepare payment data has occured an ERROR. [Error: " + ex.Message + "]"); throw ex; } }
public static void AddTransaction(RequestPayment request, ref bool checkValue) { try { long checkguid = 0; ResponseBoats responseBoat = GetBoatInfo(request.BOAT_ID); ResponsePersonalInformation responseCustomer = GetCustomer(request.CUSTOMER_NUMBER); PaymentTransaction transaction = new PaymentTransaction { BOAT_ID = request.BOAT_ID, CALLBACK_URL = request.CALLBACK_URL, CARD_HOLDER_NAME = request.CARD_HOLDER_NAME, CARD_REF_NUMBER = request.CARD_REF_NUMBER, CONVERSATION_ID = request.CONVERSATION_ID, CURRENCY = request.CURRENCY, CUSTOMER_NUMBER = request.CUSTOMER_NUMBER, IP = request.IP, PAID_PRICE = request.PAID_PRICE, PRICE = request.PRICE, PAYMENT_CHANNEL = request.PAYMENT_CHANNEL, PAYMENT_ID = request.PAYMENT_ID, TOUR_TYPE = responseBoat.TOUR_TYPE, PAYMENT_TYPE = request.Header.OperationTypes.ToString(), UPDATE_USER = responseCustomer.UPDATE_USER, INSERT_USER = responseCustomer.INSERT_USER }; checkguid = paymentTransactionService.Insert(transaction); if (checkguid == 0) { checkValue = false; } else { checkValue = true; } //Reservation date && id will be update Reservation reservation = new Reservation { UPDATE_USER = responseCustomer.UPDATE_USER, INSERT_USER = responseCustomer.INSERT_USER, CUSTOMER_NUMBER = request.CUSTOMER_NUMBER, BOAT_ID = request.BOAT_ID, PAYMENT_ID = request.PAYMENT_ID, PAYMENT_TYPE = request.Header.OperationTypes.ToString(), PRICE = request.PRICE, TOUR_TYPE = request.TOUR_TYPE, RESERVATION_DATE = request.RESERVATION_DATE, RESERVATION_END_DATE = request.RESERVATION_END_DATE, RESERVATION_ID = request.RESERVATION_ID, CONFIRM = 0 }; //Modify Reservation Informations checkValue = reservationService.Update(reservation); } catch (Exception ex) { log.Error("AddTransaction has an ERROR: [ERROR : " + ex.Message + "]"); throw new Exception(ex.Message); } }