Exemplo n.º 1
0
        public static PaymentVerifyResult CreateVerifyResult(
            string webServiceResponse,
            InvoiceContext context,
            IranKishCallbackResult callbackResult,
            MessagesOptions messagesOptions)
        {
            var result = XmlHelper.GetNodeValueFromXml(webServiceResponse, "KicccPaymentsVerificationResult", "http://tempuri.org/");

            // The result object is actually the amount of invoice . It must equal to invoice's amount.
            if (!long.TryParse(result, out var numericResult))
            {
                return(new PaymentVerifyResult
                {
                    TrackingNumber = callbackResult.InvoiceNumber,
                    TransactionCode = callbackResult.ReferenceId,
                    Status = PaymentVerifyResultStatus.Failed,
                    Message = $"{messagesOptions.InvalidDataReceivedFromGateway} Result: {result}"
                });
            }

            var isSuccess = numericResult == (long)context.Payment.Amount;

            var translatedMessage = isSuccess
                ? messagesOptions.PaymentSucceed
                : IranKishGatewayResultTranslator.Translate(result, messagesOptions);

            return(new PaymentVerifyResult
            {
                TrackingNumber = callbackResult.InvoiceNumber,
                TransactionCode = callbackResult.ReferenceId,
                Status = isSuccess ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
                Message = translatedMessage
            });
        }
Exemplo n.º 2
0
 public static string CreateVerifyData(IranKishCallbackResult callbackResult, IranKishGatewayAccount account)
 {
     return
         ("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">" +
          "<soapenv:Header/>" +
          "<soapenv:Body>" +
          "<tem:KicccPaymentsVerification>" +
          $"<tem:token>{XmlHelper.EncodeXmlValue(callbackResult.Token)}</tem:token>" +
          $"<tem:merchantId>{account.MerchantId}</tem:merchantId>" +
          $"<tem:referenceNumber>{callbackResult.ReferenceId}</tem:referenceNumber>" +
          $"<tem:sha1Key>{account.Sha1Key}</tem:sha1Key>" +
          "</tem:KicccPaymentsVerification>" +
          "</soapenv:Body>" +
          "</soapenv:Envelope>");
 }