public static PaymentRequestResult CreateRequestResult( string webServiceResponse, HttpContext httpContext, MellatGatewayOptions gatewayOptions, MessagesOptions messagesOptions, GatewayAccount account) { var result = XmlHelper.GetNodeValueFromXml(webServiceResponse, "return"); var arrayResult = result.Split(','); var resCode = arrayResult[0]; var refId = arrayResult.Length > 1 ? arrayResult[1] : string.Empty; var isSucceed = resCode == OkResult; if (!isSucceed) { var message = resCode == DuplicateOrderNumberResult ? messagesOptions.DuplicateTrackingNumber : MellatGatewayResultTranslator.Translate(resCode, messagesOptions); return(PaymentRequestResult.Failed(message, account.Name)); } return(PaymentRequestResult.SucceedWithPost( account.Name, httpContext, gatewayOptions.PaymentPageUrl, new Dictionary <string, string> { { "RefId", refId } })); }
public static IServiceCollection AddMellatPaymentGateway( this IServiceCollection services, MellatGatewayOptions options) { services.AddTransient <IMellatGateway>(_ => new MellatGateway(options)); return(services); }
public static PaymentRequestResult CreateRequestResult( string webServiceResponse, Invoice invoice, HttpContext httpContext, MellatGatewayOptions gatewayOptions, MessagesOptions messagesOptions, GatewayAccount account) { var result = XmlHelper.GetNodeValueFromXml(webServiceResponse, "return"); var arrayResult = result.Split(','); var resCode = arrayResult[0]; var refId = arrayResult.Length > 1 ? arrayResult[1] : string.Empty; var isSucceed = resCode == OkResult; if (!isSucceed) { var message = resCode == DuplicateOrderNumberResult ? messagesOptions.DuplicateTrackingNumber : MellatGatewayResultTranslator.Translate(resCode, messagesOptions); return(PaymentRequestResult.Failed(message, account.Name)); } var form = new Dictionary <string, string> { { "RefId", refId } }; var additionalData = invoice.GetMellatAdditionalData(); if (!string.IsNullOrWhiteSpace(additionalData?.MobileNumber)) { form.Add("MobileNo", additionalData.MobileNumber); } return(PaymentRequestResult.SucceedWithPost( account.Name, httpContext, gatewayOptions.PaymentPageUrl, form)); }