public static PaymentRequestResult CreateRequestResult(string response, HttpContext httpContext, ZarinPalGatewayAccount account, MessagesOptions messagesOptions) { var status = XmlHelper.GetNodeValueFromXml(response, "Status", "http://zarinpal.com/"); var authority = XmlHelper.GetNodeValueFromXml(response, "Authority", "http://zarinpal.com/"); var isSucceed = string.Equals(status, NumericOkResult, StringComparison.InvariantCultureIgnoreCase); if (!isSucceed) { var message = ZarinPalStatusTranslator.Translate(status, messagesOptions); return(PaymentRequestResult.Failed(message, account.Name)); } var paymentPageUrl = GetWebPageUrl(account.IsSandbox) + authority; var transporterDescriptor = GatewayTransporterDescriptor.CreateRedirect(paymentPageUrl); var transporter = new DefaultGatewayTransporter(httpContext, transporterDescriptor); return(PaymentRequestResult.Succeed(transporter, account.Name)); }
public static PaymentVerifyResult CreateVerifyResult(string response, MessagesOptions messagesOptions) { var status = XmlHelper.GetNodeValueFromXml(response, "Status", "http://zarinpal.com/"); var refId = XmlHelper.GetNodeValueFromXml(response, "RefID", "http://zarinpal.com/"); var isSucceed = string.Equals(status, NumericOkResult, StringComparison.OrdinalIgnoreCase); if (!isSucceed) { var message = ZarinPalStatusTranslator.Translate(status, messagesOptions); var verifyResultStatus = string.Equals(status, NumericAlreadyOkResult, StringComparison.OrdinalIgnoreCase) ? PaymentVerifyResultStatus.AlreadyVerified : PaymentVerifyResultStatus.Failed; return(new PaymentVerifyResult { Status = verifyResultStatus, Message = message }); } return(PaymentVerifyResult.Succeed(refId, messagesOptions.PaymentSucceed)); }