public static string GetHdfcChargeRequest(IHdfcCharge hdfcCharge, string tranportalId, string tranportalPassword) { StringBuilder sb = new StringBuilder(); sb.Append($"<ID>{tranportalId}</ID>"); sb.Append($"<password>{tranportalPassword}</password>"); sb.Append($"<card>{hdfcCharge.PaymentCard.CardNumber}</card>"); sb.Append($"<cvv2>{hdfcCharge.PaymentCard.Cvv}</cvv2>"); sb.Append($"<expyear>{hdfcCharge.PaymentCard.ExpiryYear}</expyear>"); sb.Append($"<expmonth>{hdfcCharge.PaymentCard.ExpiryMonth}</expmonth>"); sb.Append($"<action>1</action>"); sb.Append($"<amt>{hdfcCharge.Amount.ToString("0.00")}</amt>"); sb.Append($"<currencycode>356</currencycode>"); sb.Append($"<member>{hdfcCharge.PaymentCard.NameOnCard}</member>"); sb.Append($"<trackid>{hdfcCharge.TransactionId}</trackid>"); return(sb.ToString()); }
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))); } }