Example #1
0
        public static ResponseCustomerAddress GetCustomerAddress(long customerNumber)
        {
            try
            {
                CustomerAddress         customerAddress = customerAddressService.SelectByCustomerNumber(customerNumber);
                ResponseCustomerAddress response        = new ResponseCustomerAddress
                {
                    CITY            = customerAddress.CITY,
                    COUNTRY         = customerAddress.COUNTRY,
                    CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                    DESCRIPTION     = customerAddress.DESCRIPTION,
                    ZIPCODE         = customerAddress.ZIPCODE,
                    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 address informations");
                throw ex;
            }
        }
Example #2
0
        public bool CustomerAddressOperation(RequestCustomerAddress request, out ResponseCustomerAddress response)
        {
            CustomerAddressOperation op = new CustomerAddressOperation(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);
                }
                //Operation
                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region ADD
                    long checkGuid = 0;
                    this.customerAddress = new CustomerAddress
                    {
                        INSERT_USER     = this.request.INSERT_USER,
                        UPDATE_USER     = this.request.UPDATE_USER,
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        CITY            = this.request.CITY,
                        COUNTRY         = this.request.COUNTRY,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        ZIPCODE         = this.request.ZIPCODE
                    };
                    //Add Data to Database
                    checkGuid = customerAddressService.Insert(this.customerAddress);

                    this.response = new ResponseCustomerAddress
                    {
                        CUSTOMER_NUMBER = checkGuid,
                        ZIPCODE         = this.request.ZIPCODE,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        COUNTRY         = this.request.COUNTRY,
                        CITY            = this.request.CITY,
                        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
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region GET
                    customerAddress = customerAddressService.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER);
                    this.response   = new ResponseCustomerAddress
                    {
                        CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                        CITY            = customerAddress.CITY,
                        COUNTRY         = customerAddress.COUNTRY,
                        DESCRIPTION     = customerAddress.DESCRIPTION,
                        ZIPCODE         = customerAddress.ZIPCODE,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = true,
                            ResponseCode    = CommonDefinitions.SUCCESS,
                            ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region DELETE
                    this.customerAddress = new CustomerAddress
                    {
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        ZIPCODE         = this.request.ZIPCODE,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        CITY            = this.request.CITY,
                        COUNTRY         = this.request.COUNTRY,
                        UPDATE_USER     = this.request.UPDATE_USER
                    };
                    if (customerAddressService.Delete(this.customerAddress))
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = "",
                            COUNTRY         = "",
                            DESCRIPTION     = "",
                            ZIPCODE         = "",
                            header          = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                    }
                    else
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = customerAddress.CITY,
                            COUNTRY         = customerAddress.COUNTRY,
                            DESCRIPTION     = customerAddress.DESCRIPTION,
                            ZIPCODE         = customerAddress.ZIPCODE,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = false,
                                ResponseCode    = CommonDefinitions.ERROR_MESSAGE,
                                ResponseMessage = CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR
                            }
                        };
                    }
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.UPDATE:
                    #region UPDATE
                    this.customerAddress = new CustomerAddress
                    {
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        ZIPCODE         = this.request.ZIPCODE,
                        DESCRIPTION     = this.request.DESCRIPTION,
                        CITY            = this.request.CITY,
                        COUNTRY         = this.request.COUNTRY,
                        UPDATE_USER     = this.request.UPDATE_USER
                    };
                    if (customerAddressService.Update(this.customerAddress))
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = customerAddress.CITY,
                            COUNTRY         = customerAddress.COUNTRY,
                            DESCRIPTION     = customerAddress.DESCRIPTION,
                            ZIPCODE         = customerAddress.ZIPCODE,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                    }
                    else
                    {
                        this.response = new ResponseCustomerAddress
                        {
                            CUSTOMER_NUMBER = customerAddress.CUSTOMER_NUMBER,
                            CITY            = customerAddress.CITY,
                            COUNTRY         = customerAddress.COUNTRY,
                            DESCRIPTION     = customerAddress.DESCRIPTION,
                            ZIPCODE         = customerAddress.ZIPCODE,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = false,
                                ResponseCode    = CommonDefinitions.ERROR_MESSAGE,
                                ResponseMessage = CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR
                            }
                        };
                    }
                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw;
            }
        }
Example #4
0
        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;
            }
        }
Example #5
0
        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;
            }
        }