예제 #1
0
 public IHdfcEnrollmentResponse HdfcEnrollmentVerification(IHdfcCharge hdfcCharge)
 {
     try
     {
         IHdfcEnrolledCharge hdfcEnrolledCharge = new HdfcEnrolledCharge();
         string response    = HdfcChargerHelper.HttpWebRequestHandler(_settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Hdfc.EnrollmentVerificationUrl), HdfcChargerHelper.GetHdfcChargeRequest(hdfcCharge, _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Hdfc.TranportalId), _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Hdfc.TranportalPassword)));
         string result      = HdfcChargerHelper.GetResultField(response, "result");
         string error       = HdfcChargerHelper.GetResultField(response, "error_text");
         bool   errorStatus = string.IsNullOrWhiteSpace(error) ? true : false;
         if (errorStatus)
         {
             if (result.ToUpper().Equals("ENROLLED"))
             {
                 hdfcEnrolledCharge.AcsUrl = HdfcChargerHelper.GetResultField(response, "url");
                 hdfcEnrolledCharge.PaymentAuthenticationRequest = HdfcChargerHelper.GetResultField(response, "PAReq");
                 hdfcEnrolledCharge.PaymentId = HdfcChargerHelper.GetResultField(response, "paymentid");
             }
             hdfcEnrolledCharge.Result        = HdfcChargerHelper.GetResultField(response, "result");
             hdfcEnrolledCharge.Error         = HdfcChargerHelper.GetResultField(response, "error_text");
             hdfcEnrolledCharge.Eci           = !string.IsNullOrWhiteSpace(HdfcChargerHelper.GetResultField(response, "eci")) ? HdfcChargerHelper.GetResultField(response, "eci") : "7";
             hdfcEnrolledCharge.TransactionId = hdfcCharge.TransactionId;
             hdfcEnrolledCharge.Amount        = hdfcCharge.Amount;
             _transactionPaymentDetailRepository.Save(new TransactionPaymentDetail
             {
                 TransactionId    = Convert.ToInt64(hdfcCharge.TransactionId),
                 PaymentOptionId  = PaymentOptions.CreditCard,
                 PaymentGatewayId = PaymentGateway.HDFC,
                 UserCardDetailId = hdfcCharge.UserCardDetailId,
                 RequestType      = "Charge Resolver",
                 Amount           = hdfcCharge.Amount.ToString(),
                 PayConfNumber    = "",
                 PaymentDetail    = "{\"Response\":" + Newtonsoft.Json.JsonConvert.SerializeObject(hdfcEnrolledCharge) + "}",
             });
         }
         return(GetHdfcEnrollmentResponse(errorStatus ? hdfcEnrolledCharge : null, errorStatus ? PaymentGatewayError.None : HdfcChargerHelper.GetPaymentGatewayErrorCode(string.IsNullOrWhiteSpace(error) ? "Transaction declined" : error)));
     }
     catch (Exception ex)
     {
         _logger.Log(LogCategory.Error, new Exception("Failed to verify enrollment", ex));
         return(GetHdfcEnrollmentResponse(null, HdfcChargerHelper.GetPaymentGatewayErrorCode(ex.Message)));
     }
 }
예제 #2
0
 protected override async Task <IPaymentResponse> CreateCharge(IHdfcCharge hdfcCharge)
 {
     try
     {
         string response                  = HdfcChargerHelper.HttpWebRequestHandler(_settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Hdfc.TransactionPortalUrl), HdfcChargerHelper.GetHdfcChargeRequest(hdfcCharge, _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Hdfc.TranportalId), _settings.GetConfigSetting <string>(SettingKeys.PaymentGateway.Hdfc.TranportalPassword)));
         string result                    = HdfcChargerHelper.GetResultField(response, "result");
         string error                     = HdfcChargerHelper.GetResultField(response, "error_text");
         string amount                    = HdfcChargerHelper.GetResultField(response, "amt");
         string paymentId                 = HdfcChargerHelper.GetResultField(response, "payid");
         string transactionId             = HdfcChargerHelper.GetResultField(response, "trackid");
         string paymentConfirmationNumber = HdfcChargerHelper.GetResultField(response, "tranid");
         bool   payStatus                 = result.ToUpper().Equals("CAPTURED") ? true : false;
         if (payStatus)
         {
             if (transactionId != null)
             {
                 _transactionStatusUpdater.UpdateTranscationStatus(Convert.ToInt64(transactionId));
             }
         }
         _transactionPaymentDetailRepository.Save(new TransactionPaymentDetail
         {
             TransactionId    = Convert.ToInt64(hdfcCharge.TransactionId),
             PaymentOptionId  = PaymentOptions.CreditCard,
             PaymentGatewayId = PaymentGateway.HDFC,
             RequestType      = "Not Enrolled Recieved",
             Amount           = hdfcCharge.Amount.ToString(),
             PayConfNumber    = paymentConfirmationNumber,
             PaymentDetail    = "{\"Response\":{\"Result\":\"" + result + "\",\"Error\":\"" + error + "\",\"Amount\":\"" + amount + "\",\"PaymentConfirmationNumber\":\"" + paymentConfirmationNumber + "\",\"PaymentId\":\"" + paymentId + "\",\"TrackId\":\"" + transactionId + "\"}",
         });
         return(GetPaymentResponse(payStatus ? true : false, payStatus ? PaymentGatewayError.None : HdfcChargerHelper.GetPaymentGatewayErrorCode(string.IsNullOrWhiteSpace(error) ? "Transaction declined" : error)));
     }
     catch (Exception ex)
     {
         _logger.Log(LogCategory.Error, new Exception("Failed to create charge", ex));
         return(GetPaymentResponse(false, HdfcChargerHelper.GetPaymentGatewayErrorCode(ex.Message)));
     }
 }