public static string CreateRefundData(ParsianGatewayAccount account, InvoiceContext context, Money amount) { var transaction = context.Transactions.SingleOrDefault(item => item.Type == TransactionType.Verify); if (transaction == null) { throw new InvalidOperationException($"No transaction record found in database for payment with tracking number {context.Payment.TrackingNumber}."); } if (!AdditionalDataConverter.ToDictionary(transaction).TryGetValue("token", out var token)) { throw new InvalidOperationException($"No token found in database for payment with tracking number {context.Payment.TrackingNumber}."); } return ("<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:rev=\"https://pec.Shaparak.ir/NewIPGServices/Reversal/ReversalService\">" + "<soap:Header/>" + "<soap:Body>" + "<rev:ReversalRequest>" + "<!--Optional:-->" + "<rev:requestData>" + "<!--Optional:-->" + $"<rev:LoginAccount>{account.LoginAccount}</rev:LoginAccount>" + $"<rev:Token>{token}</rev:Token>" + "</rev:requestData>" + "</rev:ReversalRequest>" + "</soap:Body>" + "</soap:Envelope>"); }
public static string CreateVerifyData(ParsianGatewayAccount account, ParsianCallbackResult callbackResult) { return ("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:con=\"https://pec.Shaparak.ir/NewIPGServices/Confirm/ConfirmService\">" + "<soapenv:Header/>" + "<soapenv:Body>" + "<con:ConfirmPayment>" + "<!--Optional:-->" + "<con:requestData>" + "<!--Optional:-->" + $"<con:LoginAccount>{account.LoginAccount}</con:LoginAccount>" + $"<con:Token>{callbackResult.Token}</con:Token>" + "</con:requestData>" + "</con:ConfirmPayment>" + "</soapenv:Body>" + "</soapenv:Envelope>"); }
public static string CreateRequestData(ParsianGatewayAccount account, Invoice invoice) { return ("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:sal=\"https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService\">" + "<soapenv:Header/>" + "<soapenv:Body>" + "<sal:SalePaymentRequest>" + "<!--Optional:-->" + "<sal:requestData>" + "<!--Optional:-->" + $"<sal:LoginAccount>{account.LoginAccount}</sal:LoginAccount>" + $"<sal:Amount>{(long)invoice.Amount}</sal:Amount>" + $"<sal:OrderId>{invoice.TrackingNumber}</sal:OrderId>" + "<!--Optional:-->" + $"<sal:CallBackUrl>{invoice.CallbackUrl}</sal:CallBackUrl>" + "<!--Optional:-->" + "<sal:AdditionalData></sal:AdditionalData>" + "<!--Optional:-->" + "<sal:Originator></sal:Originator>" + "</sal:requestData>" + "</sal:SalePaymentRequest> " + "</soapenv:Body> " + "</soapenv:Envelope> "); }
public static PaymentRequestResult CreateRequestResult(string webServiceResponse, IHttpContextAccessor httpContextAccessor, ParsianGatewayAccount account, MessagesOptions messagesOptions) { var token = XmlHelper.GetNodeValueFromXml(webServiceResponse, "Token", "https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService"); var status = XmlHelper.GetNodeValueFromXml(webServiceResponse, "Status", "https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService"); var message = XmlHelper.GetNodeValueFromXml(webServiceResponse, "Message", "https://pec.Shaparak.ir/NewIPGServices/Sale/SaleService"); var isSucceed = !status.IsNullOrEmpty() && status == "0" && !token.IsNullOrEmpty(); if (!isSucceed) { if (message == null) { message = messagesOptions.PaymentFailed; } return(PaymentRequestResult.Failed(message)); } var paymentPageUrl = $"{PaymentPageUrl}?Token={token}"; var result = PaymentRequestResult.Succeed(new GatewayRedirect(httpContextAccessor, paymentPageUrl), account.Name); result.DatabaseAdditionalData.Add("token", token); return(result); }