Пример #1
0
        /// <summary>
        /// ExecuteAsync to execute and retrieve payment
        /// </summary>
        /// <param name="retrievePaymentRequest"></param>
        /// <returns>Task<ActionResult<RetrievePaymentResponse>></returns>
        public async Task <ActionResult <RetrievePaymentResponse> > ExecuteAsync(RetrievePaymentRequest retrievePaymentRequest)
        {
            var payment = await this._dataStoreDbContext.Payments
                          .Where(r => r.PaymentId == retrievePaymentRequest.PaymentId)
                          .FirstOrDefaultAsync <Payment>();

            if (payment is null)
            {
                this._logger.LogWarning($@"RequestId:{this._requestTrackingService.RequestTraceId} 
                Payment details Not Found in DB for PaymentId:{retrievePaymentRequest.PaymentId}");

                var errorResponse = new StandardErrorResponse
                {
                    Type           = HttpStatusCode.NotFound.ToString(),
                    RequestTraceId = this._requestTrackingService.RequestTraceId.ToString(),
                    Error          = $"No Record found for PaymentId : {retrievePaymentRequest.PaymentId}"
                };

                return(new NotFoundObjectResult(errorResponse));
            }

            this._logger.LogDebug($@"RequestId:{this._requestTrackingService.RequestTraceId} 
            Payment details retrived from DataStore for PaymentId:{payment.PaymentId}");
            var response = new RetrievePaymentResponse
            {
                PaymentId  = payment.PaymentId,
                CardNumber = payment.CardNumber,
                Status     = payment.PaymentStatus,
                Expiry     = payment.Expiry,
                Amount     = (decimal)payment.Amount,
                Currency   = payment.Currency
            };

            return(new OkObjectResult(response));
        }
Пример #2
0
        public async Task Should_Retrieve_Payment()
        {
            CreatePaymentRequest request = CreatePaymentRequestBuilder.Create()
                                           .StandardListingPayment()
                                           .Build();

            Payment createdPayment = await Payment.CreateAsync(request, Options);

            PrintResponse(createdPayment);

            RetrievePaymentRequest retrievePaymentRequest = new RetrievePaymentRequest
            {
                Locale         = Locale.TR.ToString(),
                ConversationId = "123456789",
                PaymentId      = createdPayment.PaymentId
            };

            Payment payment = await Payment.RetrieveAsync(retrievePaymentRequest, Options);

            Assert.AreEqual(Locale.TR.ToString(), payment.Locale);
            Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status);
            Assert.AreEqual(1, payment.Installment);
            Assert.AreEqual("123456789", payment.ConversationId);
            Assert.AreEqual(createdPayment.PaymentId, payment.PaymentId);
            Assert.NotNull(payment.SystemTime);
            Assert.Null(payment.ErrorCode);
            Assert.Null(payment.ErrorMessage);
            Assert.Null(payment.ErrorGroup);
            Assert.NotNull(payment.BasketId);
        }
Пример #3
0
        public PaymentInformation Get(RetrievePaymentRequest paymentRequest)
        {
            using (var db = new LiteDatabase(@"MyData.db"))
            {
                var payments = db.GetCollection <PaymentInformation>("payments");

                return(payments.Find(x => x.Id == paymentRequest.PaymentId && x.MerchantDetails.MerchantId == paymentRequest.MerchantId).FirstOrDefault());
            }
        }
Пример #4
0
 public void RetrievePayment(RetrievePaymentRequest rpr)
 {
     if (websocket != null)
     {
         RetrievePaymentRequestMessage msg = new RetrievePaymentRequestMessage();
         msg.payload = rpr;
         websocket.Send(JsonUtils.Serialize(msg));
     }
 }
        public Models.PaymentReadModel RetrievePayment(Models.RetrievePaymentRequest paymentRequest)
        {
            var repoPaymentRequest =
                new RetrievePaymentRequest(paymentRequest.PaymentId, paymentRequest.MerchantId, paymentRequest.CorrelationId);

            var paymentRequestResponse = _paymentRepository.RetrievePayment(repoPaymentRequest, paymentRequest.CorrelationId);

            if (paymentRequestResponse == null)
            {
                return(null);
            }

            return(Models.PaymentReadModel.BuildPaymentReadModel(paymentRequestResponse));
        }
Пример #6
0
        public PaymentReadModel RetrievePayment(RetrievePaymentRequest paymentRequest, string correlationId)
        {
            _logger.LogInformation($"retrieving payment payment with correlationId {correlationId} locally");

            var payment = _databaseWrapper.Get(paymentRequest);

            _logger.LogWarning($"Payment with Id {paymentRequest.PaymentId} && merchant Id {paymentRequest.MerchantId} not found!");

            if (payment == null)
            {
                return(null);
            }

            return(PaymentReadModel.BuildPaymentReadModel(payment));
        }
Пример #7
0
 public void RetrievePayment(HttpListenerContext context)
 {
     try
     {
         RetrievePaymentRequest message = ParseRequest <RetrievePaymentRequest>(context);
         GetServer.CloverConnector.RetrievePayment(message);
         this.SendTextResponse(context, "");
     }
     catch (Exception e)
     {
         context.Response.StatusCode        = 400;
         context.Response.StatusDescription = e.Message;
         this.SendTextResponse(context, "error processing request");
     }
 }
Пример #8
0
        public void Should_Retrieve_Payment_Result()
        {
            RetrievePaymentRequest request = new RetrievePaymentRequest();

            request.Locale                = Locale.TR.ToString();
            request.ConversationId        = "123456789";
            request.PaymentId             = "1";
            request.PaymentConversationId = "123456789";

            Payment payment = Payment.Retrieve(request, options);

            PrintResponse <Payment>(payment);

            Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status);
            Assert.AreEqual(Locale.TR.ToString(), payment.Locale);
            Assert.AreEqual("123456789", payment.ConversationId);
            Assert.IsNotNull(payment.SystemTime);
            Assert.IsNull(payment.ErrorCode);
            Assert.IsNull(payment.ErrorMessage);
            Assert.IsNull(payment.ErrorGroup);
        }
Пример #9
0
        public async Task Should_Retrieve_Payment_Result()
        {
            RetrievePaymentRequest request = new RetrievePaymentRequest
            {
                Locale                = Locale.TR.ToString(),
                ConversationId        = "123456789",
                PaymentId             = "1",
                PaymentConversationId = "123456789"
            };

            Payment payment = await Payment.RetrieveAsync(request, Options);

            PrintResponse(payment);

            Assert.AreEqual(Status.SUCCESS.ToString(), payment.Status);
            Assert.AreEqual(Locale.TR.ToString(), payment.Locale);
            Assert.AreEqual("123456789", payment.ConversationId);
            Assert.IsNotNull(payment.SystemTime);
            Assert.IsNull(payment.ErrorCode);
            Assert.IsNull(payment.ErrorMessage);
            Assert.IsNull(payment.ErrorGroup);
        }
Пример #10
0
        public async Task <IActionResult> Get([FromQuery] RetrievePaymentRequest retrievePaymentRequest, [FromHeader] string correlationId = null)
        {
            _logger.LogInformation($"Retrieve Payment request with correlationId {correlationId} received");
            var orchestratorPaymentRequest = new Services.Models.RetrievePaymentRequest(retrievePaymentRequest.PaymentId, retrievePaymentRequest.MerchantId, correlationId);

            var payment = _paymentOrchestrator.RetrievePayment(orchestratorPaymentRequest);

            if (payment != null)
            {
                return(Ok(new RetrievePaymentResponse
                {
                    CVV = payment.CVV,
                    Currency = payment.Currency,
                    ExpiryDate = payment.ExpiryDate,
                    PaymentResponseStatus = payment.PaymentStatus,
                    CardNumber = payment.CardNumber,
                    Amount = payment.Amount
                }));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #11
0
 public static PaymentPreAuth Retrieve(RetrievePaymentRequest request, Options options)
 {
     return(RestHttpClient.Create().Post <PaymentPreAuth>(options.BaseUrl + "/payment/detail", GetHttpHeaders(request, options), request));
 }
Пример #12
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            string logSource = "_TransportEventLog";

            if (!EventLog.SourceExists(logSource))
            {
                EventLog.CreateEventSource(logSource, logSource);
            }

            EventLogTraceListener myTraceListener = new EventLogTraceListener(logSource);

            // Add the event log trace listener to the collection.
            Trace.Listeners.Add(myTraceListener);

            if (args.Length == 0)
            {
                // Retrieve the arguments from the service ImagePath
                args = Environment.GetCommandLineArgs();
            }

            if (args.Length > 0)
            {
                if (((ICollection <string>)args).Contains("-debug"))
                {
                    Debug = true;
                }

                if (((ICollection <string>)args).Any(a => a.Contains("-timer")))
                {
                    IEnumerable <string> timerStrings = ((ICollection <string>)args).Where(a => a.Contains("-timer"));
                    if (timerStrings.Count() == 1)
                    {
                        try
                        {
                            string timerString  = timerStrings.First();
                            int    index        = timerString.IndexOf('=');
                            string timerSeconds = timerString.Substring(index + 1);
                            Timer = Convert.ToInt32(timerSeconds);
                        }
                        catch
                        {
                            Timer = 1;
                            EventLog.WriteEntry(SERVICE_NAME, "Error parsing the -timer command line argument.  Setting timer to 1 second.");
                        }
                    }
                }
            }

            //load args in to dictionary
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if ("/T".Equals(args[i]))
                    {
                        parameters.Add("/T", "true");
                    }
                    else if (i + 1 < args.Length)
                    {
                        parameters.Add(args[i], args[++i]);
                    }
                }
            }

            IWebSocketConnection          sendSocket   = null;
            Action <IWebSocketConnection> serverSocket = socket =>
            {
                socket.OnOpen = () =>
                {
                    Console.WriteLine("Open! " + clientConnections.Count);
                    if (clientConnections.Count > 0)
                    {
                        if (clientConnections[0].IsAvailable)
                        {
                            socket.Close();
                            connectorListener.OnDeviceError(new CloverDeviceErrorEvent(CloverDeviceErrorEvent.CloverDeviceErrorType.EXCEPTION, 0, null, "Another client is already connected"));
                            return;
                        }
                    }
                    sendSocket = socket;
                    clientConnections.Add(socket);

                    connectorListener.WebSocket = sendSocket;
                    connectorListener.SendConnectionStatus();
                };
                socket.OnClose = () =>
                {
                    clientConnections.Remove(socket);
                    Console.WriteLine("Close!");
                    connectorListener.WebSocket = null;
                };
                socket.OnMessage = message =>
                {
                    try
                    {
                        JObject         jsonObj = (JObject)JsonConvert.DeserializeObject(message);
                        JToken          method  = jsonObj.GetValue(ServicePayloadConstants.PROP_METHOD);
                        JObject         payload = (JObject)jsonObj.GetValue(ServicePayloadConstants.PROP_PAYLOAD);
                        WebSocketMethod wsm     = (WebSocketMethod)Enum.Parse(typeof(WebSocketMethod), method.ToString());

                        switch (wsm)
                        {
                        case WebSocketMethod.Status:
                        {
                            connectorListener.SendConnectionStatus();
                            break;
                        }

                        case WebSocketMethod.OpenCashDrawer:
                        {
                            OpenCashDrawerRequest request = JsonUtils.Deserialize <OpenCashDrawerRequest>(payload.ToString());
                            cloverConnector.OpenCashDrawer(request);
                            break;
                        }

                        case WebSocketMethod.ShowMessage:
                        {
                            string msg = ((JObject)payload).GetValue("Message").Value <string>();
                            cloverConnector.ShowMessage(msg);
                            break;
                        }

                        case WebSocketMethod.ShowThankYouScreen:
                        {
                            cloverConnector.ShowThankYouScreen();
                            break;
                        }

                        case WebSocketMethod.ShowWelcomeScreen:
                        {
                            cloverConnector.ShowWelcomeScreen();
                            break;
                        }

                        case WebSocketMethod.Break:     // deprecated. use ResetDevice
                        case WebSocketMethod.ResetDevice:
                        {
                            cloverConnector.ResetDevice();
                            break;
                        }

                        case WebSocketMethod.PrintText:
                        {
                            JArray        messages    = (JArray)payload.GetValue("Messages");
                            List <string> messageList = new List <string>();
                            foreach (string msg in messages)
                            {
                                messageList.Add(msg);
                            }
                            cloverConnector.Print(new PrintRequest()
                                {
                                    text = messageList
                                });
                            break;
                        }

                        case WebSocketMethod.PrintImage:
                        {
                            string       base64Img = ((JObject)payload).GetValue("Bitmap").Value <string>();
                            byte[]       imgBytes  = Convert.FromBase64String(base64Img);
                            MemoryStream ms        = new MemoryStream();
                            ms.Write(imgBytes, 0, imgBytes.Length);
                            Bitmap bp = new Bitmap(ms);
                            ms.Close();
                            cloverConnector.Print(new PrintRequest()
                                {
                                    images = new List <Bitmap> {
                                        bp
                                    }
                                });
                            break;
                        }

                        case WebSocketMethod.PrintImageFromURL:
                        {
                            string url = ((JObject)payload).GetValue("Url").Value <string>();
                            cloverConnector.Print(new PrintRequest()
                                {
                                    imageURLs = new List <string> {
                                        url
                                    }
                                });
                            break;
                        }

                        case WebSocketMethod.Auth:
                        {
                            AuthRequest authRequest = JsonUtils.Deserialize <AuthRequest>(payload.ToString());
                            cloverConnector.Auth(authRequest);
                            break;
                        }

                        case WebSocketMethod.PreAuth:
                        {
                            PreAuthRequest preAuthRequest = JsonUtils.Deserialize <PreAuthRequest>(payload.ToString());
                            cloverConnector.PreAuth(preAuthRequest);
                            break;
                        }

                        case WebSocketMethod.TipAdjustAuth:
                        {
                            TipAdjustAuthRequest tipAdjustRequest = JsonUtils.Deserialize <TipAdjustAuthRequest>(payload.ToString());
                            cloverConnector.TipAdjustAuth(tipAdjustRequest);
                            break;
                        }

                        case WebSocketMethod.CapturePreAuth:
                        {
                            CapturePreAuthRequest capturePreAuthRequest = JsonUtils.Deserialize <CapturePreAuthRequest>(payload.ToString());
                            cloverConnector.CapturePreAuth(capturePreAuthRequest);
                            break;
                        }

                        case WebSocketMethod.Sale:
                        {
                            SaleRequest saleRequest = JsonUtils.Deserialize <SaleRequest>(payload.ToString());
                            cloverConnector.Sale(saleRequest);
                            break;
                        }

                        case WebSocketMethod.InvokeInputOption:
                        {
                            InputOption io = JsonUtils.Deserialize <InputOption>(payload.ToString());
                            cloverConnector.InvokeInputOption(io);
                            break;
                        }

                        case WebSocketMethod.VoidPayment:
                        {
                            VoidPaymentRequest request = JsonUtils.Deserialize <VoidPaymentRequest>(payload.ToString());
                            cloverConnector.VoidPayment(request);
                            break;
                        }

                        case WebSocketMethod.ManualRefund:
                        {
                            ManualRefundRequest mrr = JsonUtils.Deserialize <ManualRefundRequest>(payload.ToString());
                            cloverConnector.ManualRefund(mrr);
                            break;
                        }

                        case WebSocketMethod.RefundPayment:
                        {
                            RefundPaymentRequest request = JsonUtils.Deserialize <RefundPaymentRequest>(payload.ToString());
                            cloverConnector.RefundPayment(request);
                            break;
                        }

                        case WebSocketMethod.DisplayPaymentReceiptOptions:
                        {
                            DisplayPaymentReceiptOptionsRequest request = JsonUtils.Deserialize <DisplayPaymentReceiptOptionsRequest>(payload.ToString());
                            cloverConnector.DisplayPaymentReceiptOptions(request);
                            break;
                        }

                        case WebSocketMethod.ShowDisplayOrder:
                        {
                            com.clover.remote.order.DisplayOrder displayOrder = JsonUtils.Deserialize <com.clover.remote.order.DisplayOrder>(payload.ToString());
                            cloverConnector.ShowDisplayOrder(displayOrder);
                            break;
                        }

                        case WebSocketMethod.AcceptSignature:
                        {
                            WSVerifySignatureRequest svr = JsonUtils.Deserialize <WSVerifySignatureRequest>(payload.ToString());
                            cloverConnector.AcceptSignature(svr);
                            break;
                        }

                        case WebSocketMethod.RejectSignature:
                        {
                            WSVerifySignatureRequest svr = JsonUtils.Deserialize <WSVerifySignatureRequest>(payload.ToString());
                            cloverConnector.RejectSignature(svr);
                            break;
                        }

                        case WebSocketMethod.ConfirmPayment:
                        {
                            AcceptPayment acceptPayment = JsonUtils.Deserialize <AcceptPayment>(payload.ToString());
                            cloverConnector.AcceptPayment(acceptPayment.Payment);
                            break;
                        }

                        case WebSocketMethod.RejectPayment:
                        {
                            RejectPayment rp = JsonUtils.Deserialize <RejectPayment>(payload.ToString());
                            cloverConnector.RejectPayment(rp.Payment, rp.Challenge);
                            break;
                        }

                        case WebSocketMethod.VaultCard:
                        {
                            VaultCardMessage vcm = JsonUtils.Deserialize <VaultCardMessage>(payload.ToString());
                            cloverConnector.VaultCard(vcm.cardEntryMethods);
                            break;
                        }

                        case WebSocketMethod.ReadCardData:
                        {
                            ReadCardDataRequest request = JsonUtils.Deserialize <ReadCardDataRequest>(payload.ToString());
                            cloverConnector.ReadCardData(request);
                            break;
                        }

                        case WebSocketMethod.Closeout:
                        {
                            CloseoutRequest cr = new CloseoutRequest();
                            cloverConnector.Closeout(cr);
                            break;
                        }

                        case WebSocketMethod.RetrievePendingPayments:
                        {
                            cloverConnector.RetrievePendingPayments();
                            break;
                        }

                        case WebSocketMethod.StartCustomActivity:
                        {
                            CustomActivityRequest request = JsonUtils.Deserialize <CustomActivityRequest>(payload.ToString());
                            cloverConnector.StartCustomActivity(request);
                            break;
                        }

                        case WebSocketMethod.RetrieveDeviceStatus:
                        {
                            RetrieveDeviceStatusRequest request = JsonUtils.Deserialize <RetrieveDeviceStatusRequest>(payload.ToString());
                            cloverConnector.RetrieveDeviceStatus(request);
                            break;
                        }

                        case WebSocketMethod.SendMessageToActivity:
                        {
                            MessageToActivity mta = JsonUtils.Deserialize <MessageToActivity>(payload.ToString());
                            cloverConnector.SendMessageToActivity(mta);
                            break;
                        }

                        case WebSocketMethod.RetrievePaymentRequest:
                        {
                            RetrievePaymentRequest rpr = JsonUtils.Deserialize <RetrievePaymentRequest>(payload.ToString());
                            cloverConnector.RetrievePayment(rpr);
                            break;
                        }

                        case WebSocketMethod.RetrievePrintersRequest:
                        {
                            RetrievePrintersRequest rpr = JsonUtils.Deserialize <RetrievePrintersRequest>(payload.ToString());
                            cloverConnector.RetrievePrinters(rpr);
                            break;
                        }

                        case WebSocketMethod.PrintJobStatusRequest:
                        {
                            PrintJobStatusRequest req = JsonUtils.Deserialize <PrintJobStatusRequest>(payload.ToString());
                            cloverConnector.RetrievePrintJobStatus(req);
                            break;
                        }

                        case WebSocketMethod.PrintRequest:
                        {
                            PrintRequest64Message request      = JsonUtils.Deserialize <PrintRequest64Message>(payload.ToString());
                            PrintRequest          printRequest = null;
                            if (request.base64strings.Count > 0)
                            {
                                byte[]       imgBytes = Convert.FromBase64String(request.base64strings[0]);
                                MemoryStream ms       = new MemoryStream();
                                ms.Write(imgBytes, 0, imgBytes.Length);
                                Bitmap bp = new Bitmap(ms);
                                ms.Close();
                                printRequest = new PrintRequest(bp, request.externalPrintJobId, request.printDeviceId);
                            }
                            else if (request.imageUrls.Count > 0)
                            {
                                printRequest = new PrintRequest(request.imageUrls[0], request.externalPrintJobId, request.printDeviceId);
                            }
                            else if (request.textLines.Count > 0)
                            {
                                printRequest = new PrintRequest(request.textLines, request.externalPrintJobId, request.printDeviceId);
                            }
                            cloverConnector.Print(printRequest);
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("received unknown websocket method: " + method.ToString() + " in CloverWebSocketService.");
                            break;
                        }
                        }
                    }
                    catch (InvalidOperationException ioe)
                    {
                        Console.WriteLine(ioe.Message);
                        socket.Send("Error Deserializing");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        socket.Send("Error Parsing: " + message);
                    }
                };
            };

            InitializeConnector(parameters);
            server.Start(serverSocket);
        }
Пример #13
0
 // Async
 public static async Task <ThreedsPayment> RetrieveAsync(RetrievePaymentRequest request, Options options)
 {
     return(await RestHttpClient.Create().PostAsync <ThreedsPayment>(options.BaseUrl + "/payment/detail", GetHttpHeaders(request, options), request));
 }
Пример #14
0
 public static async Task <Payment> RetrieveAsync(RetrievePaymentRequest request, Options options)
 {
     return(await RestHttpClient.Instance.PostAsync <Payment>(options.BaseUrl + PaymentRetrieveUrl, GetHttpHeaders(request, options), request));
 }
Пример #15
0
 public static Payment Retrieve(RetrievePaymentRequest request, Options options)
 {
     return(RestHttpClient.Instance.Post <Payment>(options.BaseUrl + PaymentRetrieveUrl, GetHttpHeaders(request, options), request));
 }
 public static ThreedsPayment Retrieve(RetrievePaymentRequest request, Options options)
 {
     return(RestHttpClient.Create().Post <ThreedsPayment>(options.BaseUrl + "/payment/detail", request, options));
 }
Пример #17
0
        public override void DoOperation()
        {
            try
            {
                //Validate Reques Header / Constants
                this.baseResponseMessage = ValidateInput();
                if (!this.baseResponseMessage.header.IsSuccess)
                {
                    throw new Exception(this.baseResponseMessage.header.ResponseMessage);
                }

                Options baseHeader = null;
                string  errMsg     = "";
                string  errCode    = "";
                bool    result     = true;

                //Operation
                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region PAYMENT

                    //Create payments
                    Iyzipay.Request.CreatePaymentRequest paymentRequest = PrepareRequest(ref result, ref errMsg, ref baseHeader, ref errCode);
                    Payment payment = Payment.Create(paymentRequest, baseHeader);

                    RetrievePaymentRequest request = new RetrievePaymentRequest();
                    request.Locale                = Locale.TR.ToString();
                    request.ConversationId        = payment.ConversationId;
                    request.PaymentId             = payment.PaymentId;
                    request.PaymentConversationId = payment.ConversationId;

                    //check payments
                    Payment Checkpayments = Payment.Retrieve(request, baseHeader);
                    if (Checkpayments.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }

                    bool checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);
                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = paymentRequest.CallbackUrl,
                        CARD_HOLDER_NAME = paymentRequest.PaymentCard.CardHolderName,
                        CARD_REF_NUMBER  = paymentRequest.PaymentCard.CardNumber,
                        CONVERSATION_ID  = payment.ConversationId,
                        CURRENCY         = payment.Currency,
                        CUSTOMER_NUMBER  = Convert.ToInt64(paymentRequest.Buyer.Id),
                        IP              = paymentRequest.Buyer.Ip,
                        PAID_PRICE      = payment.PaidPrice,
                        PRICE           = payment.Price,
                        PAYMENT_CHANNEL = paymentRequest.PaymentChannel,
                        PAYMENT_ID      = Checkpayments.PaymentId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };

                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region REFUND

                    //Create ReFund
                    FillOptionHeader(ref baseHeader);
                    CreateRefundRequest refundRequest = new CreateRefundRequest();
                    refundRequest.ConversationId       = this.request.CONVERSATION_ID;
                    refundRequest.Locale               = Locale.TR.ToString();
                    refundRequest.PaymentTransactionId = this.request.PAYMENT_ID;
                    refundRequest.Price    = this.request.PRICE;
                    refundRequest.Ip       = this.request.IP;
                    refundRequest.Currency = this.request.CURRENCY;

                    //check refund
                    Refund refund = Refund.Create(refundRequest, baseHeader);
                    if (refund.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception(" Geri ödeme basarısız");
                    }

                    //Transaction
                    checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);

                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = this.request.CALLBACK_URL,
                        CARD_HOLDER_NAME = this.request.CARD_HOLDER_NAME,
                        CARD_REF_NUMBER  = this.request.CARD_REF_NUMBER,
                        CONVERSATION_ID  = refundRequest.ConversationId,
                        CURRENCY         = refundRequest.Currency,
                        CUSTOMER_NUMBER  = this.request.CUSTOMER_NUMBER,
                        IP              = refundRequest.Ip,
                        PAID_PRICE      = refundRequest.Price,
                        PRICE           = refundRequest.Price,
                        PAYMENT_CHANNEL = this.request.PAYMENT_CHANNEL,
                        PAYMENT_ID      = refundRequest.PaymentTransactionId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };

                    #endregion
                    break;

                case (int)OperationType.OperationTypes.UPDATE:
                    #region BKM PAYMENT

                    CreateBkmInitializeRequest requestBKM = PrepareBkmRequest(ref baseHeader);
                    BkmInitialize bkmInitialize           = BkmInitialize.Create(requestBKM, baseHeader);

                    RetrieveBkmRequest retrieveBKM = new RetrieveBkmRequest();
                    retrieveBKM.Locale         = Locale.TR.ToString();
                    retrieveBKM.ConversationId = "123456789";
                    retrieveBKM.Token          = "token";

                    Bkm bkm = Bkm.Retrieve(retrieveBKM, baseHeader);
                    if (bkm.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }

                    //Transaction
                    checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);
                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = requestBKM.CallbackUrl,
                        CARD_HOLDER_NAME = "",
                        CARD_REF_NUMBER  = "",
                        CONVERSATION_ID  = requestBKM.ConversationId,
                        CURRENCY         = "",
                        CUSTOMER_NUMBER  = Convert.ToInt64(requestBKM.Buyer.Id),
                        IP              = requestBKM.Buyer.Ip,
                        PAID_PRICE      = requestBKM.Price,
                        PRICE           = requestBKM.Price,
                        PAYMENT_CHANNEL = requestBKM.PaymentSource,
                        PAYMENT_ID      = requestBKM.BasketId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region 3D PAYMENT
                    //Initialize 3D Payment
                    Iyzipay.Request.CreatePaymentRequest payment3DRequest = Prepare3DRequest(ref baseHeader);
                    ThreedsInitialize threedsInitialize = ThreedsInitialize.Create(payment3DRequest, baseHeader);
                    if (threedsInitialize.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }
                    //Create 3D Payment
                    CreateThreedsPaymentRequest create3Drequestpayment = new CreateThreedsPaymentRequest();
                    create3Drequestpayment.Locale           = Locale.TR.ToString();
                    create3Drequestpayment.ConversationId   = payment3DRequest.ConversationId;
                    create3Drequestpayment.PaymentId        = this.request.PAYMENT_ID;
                    create3Drequestpayment.ConversationData = "conversation data";    // ?????

                    ThreedsPayment threedsPayment = ThreedsPayment.Create(create3Drequestpayment, baseHeader);
                    if (threedsPayment.Status == Status.FAILURE.ToString())
                    {
                        throw new Exception("Odeme basarısız");
                    }

                    //Transaction
                    checkvalue = false;
                    //add transaction
                    CommonServices.AddTransaction(this.request, ref checkvalue);
                    //response
                    this.response = new ResponsePayment
                    {
                        CALLBACK_URL     = payment3DRequest.CallbackUrl,
                        CARD_HOLDER_NAME = payment3DRequest.PaymentCard.CardHolderName,
                        CARD_REF_NUMBER  = payment3DRequest.PaymentCard.CardNumber,
                        CONVERSATION_ID  = payment3DRequest.ConversationId,
                        CURRENCY         = payment3DRequest.Currency,
                        CUSTOMER_NUMBER  = Convert.ToInt64(payment3DRequest.Buyer.Id),
                        IP              = payment3DRequest.Buyer.Ip,
                        PAID_PRICE      = payment3DRequest.PaidPrice,
                        PRICE           = payment3DRequest.Price,
                        PAYMENT_CHANNEL = payment3DRequest.PaymentChannel,
                        PAYMENT_ID      = create3Drequestpayment.PaymentId,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkvalue == false ? false : true,
                            ResponseCode    = checkvalue == false ? CommonDefinitions.INTERNAL_TRANSACTION_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkvalue == false ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };

                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error("Payment Operation has an ERROR: [ERROR : " + ex.Message + "]");
                throw new Exception("Ödeme sirasinda hata oluştu.");
            }
        }
Пример #18
0
 public void RetrievePayment(RetrievePaymentRequest request)
 {
     Send("/RetrievePayment", request);
 }
Пример #19
0
 public override Task <Empty> RetrievePayment(RetrievePaymentRequest request, ServerCallContext context)
 {
     Program.WriteLine("RetrievePayment");
     Connector.RetrievePayment(Translate.From(request));
     return(Task.FromResult(new Empty()));
 }