Beispiel #1
0
        public PaymentOnlineBookingResponse ValidateResponseStatus(PaymentOnlineBookingResponse input)
        {
            switch (input.status_code)
            {
            case "404":
                input.status_message = "transaction is not found";
                break;

            case "406":
                input.status_message = "Duplicate order Code. Order Code has already been utilized previously.";
                break;

            case "400":
                if (input.validation_messages.Count > 0)
                {
                    input.status_message = input.validation_messages[0];
                    break;
                }
                else
                {
                    break;
                }

            default:
                break;
            }

            return(input);
        }
Beispiel #2
0
        //public async Task<ReqTokenResultDto> ReqToken(ReqTokenInputDto input)
        //{
        //    var url = "https://app.sandbox.midtrans.com/snap/v1/transactions";
        //    var authToken = Convert.ToBase64String(Encoding.UTF8.GetBytes(_configuration.ServerKey));


        //    using (var client = new HttpClient())
        //    {
        //        client.Timeout = TimeSpan.FromMinutes(10);
        //        var request = CreateRequest(url, "Basic", authToken, client, HttpMethod.Post);
        //        request.Content = new StringContent(JsonConvert.SerializeObject(input), Encoding.UTF8, MimeTypeNames.ApplicationJson);

        //        Logger.InfoFormat("CreatePaymentOnlineBooking() - End.");
        //        return await ReadResponse<PaymentOnlineBookingResponse>(url, client, request);
        //    }
        //}


        public void PaymentError(PaymentOnlineBookingResponse data)
        {
            Logger.InfoFormat("PaymentNotification() - Start.");
            //var responseData = _paymentMidtranshelper.ValidateResponseStatus(JsonConvert.DeserializeObject<PaymentOnlineBookingResponse>(data));

            Logger.DebugFormat("response payment midtrans. {0}" +
                               "status code            = {1}{0}" +
                               "status message         = {2}{0}" +
                               "transaction id         = {3}{0}" +
                               "transaction time       = {4}{0}" +
                               "transaction status     = {5}{0}" +
                               "payment type           = {6}{0}" +
                               "gross amount           = {7}{0}" +
                               "order id               = {8}{0}" +
                               "error message          = {9}{0}" +
                               "fraud status           = {10}{0}" +
                               "signature key          = {11}{0}" +
                               "approval code          = {12}{0}" +
                               "billerKey|billerCode   = {13}{0}",
                               Environment.NewLine, data.status_code, data.status_message,
                               data.transaction_id, data.transaction_time, data.transaction_status,
                               data.payment_type, data.gross_amount, data.order_id,
                               data.error_messages, data.fraud_status, data.signature_key,
                               data.approval_code, data.bill_key + "|" + data.biller_code);
            Logger.InfoFormat("PaymentError() - End.");
        }