public EnlistmentTimeoutRecordSchema(string transactionId, Guid enlistmentId, TransactionOutcome outcome, TimeSpan timeout)
 {
     this.transactionId = transactionId;
     this.enlistmentId  = enlistmentId;
     this.outcome       = outcome;
     this.timeout       = timeout;
 }
 public EnlistmentTimeoutRecordSchema(string transactionId, Guid enlistmentId, TransactionOutcome outcome, TimeSpan timeout)
 {
     this.transactionId = transactionId;
     this.enlistmentId = enlistmentId;
     this.outcome = outcome;
     this.timeout = timeout;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// GestPay calls this controller while proceeding with the transaction
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public ActionResult GestPayS2SEndpoint(string a, string b)
        {
            TransactionOutcome outcome = _gestPayTransactionServices.ReceiveS2STransaction(a, b);
            //the mesages given in the view are for debug purposes, because GestPay does not care
            string shapeString = "S2S";

            if (!string.IsNullOrWhiteSpace(outcome.TransactionResult))
            {
                if (outcome.TransactionResult == "KO")
                {
                    shapeString += T(" Transaction failed with error: {0}", outcome.ErrorDescription).Text;
                }
                else if (outcome.TransactionResult == "OK")
                {
                    shapeString += T("Transaction successful.").Text;
                }
                else
                {
                    shapeString += T(" Transactions still in progress.").Text;
                }
            }

            Shape.Outcome = shapeString;
            return(View(Shape));;
        }
        public void Withdraw_DiffAmounts_Result(decimal amount, TransactionOutcome expectOutcome,
                                                decimal expectedResult, decimal expectedAccBal, decimal expectedResultAmount,
                                                string expectedFailureMessage)
        {
            //arrange
            var cust = DefaultAccount();
            //act
            var result = cust.Withdraw(amount);

            //assert
            Assert.Equal(expectOutcome, result.Result);
            Assert.Equal(expectedResult, result.CustomerBalance);
            Assert.Equal(expectedAccBal, cust.AccountBalance);
            Assert.Equal(expectedResultAmount, result.Amount);
            Assert.Equal(expectedFailureMessage, result.FailureMessage);
        }
        public static void Trace(Guid enlistmentId, string transactionId, TransactionOutcome outcome)
        {
            ParticipantOutcomeRecordSchema extendedData = new ParticipantOutcomeRecordSchema(transactionId, enlistmentId, outcome);

            TxTraceUtility.Trace(TraceEventType.Verbose, 0xb0027, Microsoft.Transactions.SR.GetString("ParticipantStateMachineFinished"), extendedData, null, enlistmentId, null);
        }
 public ParticipantOutcomeRecordSchema(string transactionId, Guid enlistmentId, TransactionOutcome outcome)
 {
     this.transactionId = transactionId;
     this.enlistmentId = enlistmentId;
     this.outcome = outcome;
 }
Ejemplo n.º 7
0
 public TransactionResult(TransactionOutcome result, string failureMessage)
 {
     Result         = result;
     FailureMessage = failureMessage;
 }
 public static void Trace(Guid enlistmentId, string transactionId, TransactionOutcome outcome, TimeSpan timeout)
 {
     EnlistmentTimeoutRecordSchema extendedData = new EnlistmentTimeoutRecordSchema(transactionId, enlistmentId, outcome, timeout);
     TxTraceUtility.Trace(TraceEventType.Warning, 0xb0004, Microsoft.Transactions.SR.GetString("VolatileOutcomeTimeout"), extendedData, null, enlistmentId, null);
 }
Ejemplo n.º 9
0
 public CoordinatorOutcomeRecordSchema(string transactionId, TransactionOutcome outcome)
 {
     this.transactionId = transactionId;
     this.outcome       = outcome;
 }
Ejemplo n.º 10
0
 public CustomerBalanceResult(decimal customerBalance, TransactionOutcome result, string failureMessage) : base(result, failureMessage)
 {
     CustomerBalance = customerBalance;
 }
Ejemplo n.º 11
0
 public CustomerPinValidationResult(TransactionOutcome result, string failureMessage) : base(result, failureMessage)
 {
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Given the results of a transaction, get the url of the page showing them to the user. This url, depending on the call that started the
        /// transaction, may not actually be an url.
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public string InterpretTransactionResult(string a, string b)
        {
            var settings = _orchardServices
                           .WorkContext
                           .CurrentSite
                           .As <PaymentGestPaySettingsPart>();

            if (a == settings.GestPayShopLogin)
            {
                XmlNode outcome;// = Decrypt(a, b, settings.UseTestEnvironment);
                try {
                    outcome = Decrypt(a, b, settings.UseTestEnvironment);
                } catch (Exception ex) {
                    //Log the error
                    LocalizedString error = T("Request to GestPay service failed: {0}", ex.Message);
                    Logger.Error(error.Text);
                    throw new Exception(error.Text);
                }

                //the closure of the transaction should be handled in the S2S method
                //Here, eventually, we send error messages or info strings, that wee add to the record in the endpayment
                TransactionOutcome result = new TransactionOutcome();
                try {
                    result = new TransactionOutcome(outcome);
                    Validator.ValidateObject(result, new ValidationContext(result), true);
                } catch (Exception ex) {
                    LocalizedString exception = T("Validation problems on the response received: {0}", ex.Message);
                    //Log the error
                    Logger.Error(exception.Text);
                    throw new Exception(exception.Text);
                    ////update the PaymentRecord for this transaction
                    //int pId;
                    //if (result != null && int.TryParse(result.ShopTransactionID, out pId)) {
                    //    try {
                    //        EndPayment(pId, false, null, exception.Text);
                    //    } catch (Exception exin) {
                    //        throw new Exception(T("EndPayment caused exception: {0}.\npId: {1}\nsuccess: false\nerror:{2}", exin.Message, pId.ToString(), exception.Text).Text);
                    //    }
                    //    return GetPaymentInfoUrl(pId);
                    //} else {
                    //    exception = T("Failed to identify transaction from GestPay's response. Additional error: {0}", exception.Text);
                    //    Logger.Error(exception.Text);
                    //    throw new Exception(exception.Text);
                    //}
                }

                int paymentId;
                if (int.TryParse(result.ShopTransactionID, out paymentId))
                {
                    //if (result.TransactionResult == "OK") {
                    //    try {
                    //        EndPayment(paymentId, true, null, null);
                    //    } catch (Exception exin) {
                    //        throw new Exception(T("EndPayment caused exception: {0}.\npId: {1}\nsuccess: true", exin.Message, paymentId.ToString()).Text);
                    //    }
                    //} else {
                    //    try {
                    //        EndPayment(paymentId, false, result.ErrorCode, result.ErrorDescription);
                    //    } catch (Exception exin) {
                    //        throw new Exception(T("EndPayment caused exception: {0}.\npId: {1}\nsuccess: false\nerror:{2}\ninfo:{3}", exin.Message, paymentId.ToString(), result.ErrorCode, result.ErrorDescription).Text);
                    //    }
                    //}
                    return(GetPaymentInfoUrl(paymentId));
                }
                else
                {
                    if (result.TransactionResult == "KO")
                    {
                        throw new Exception(T("Failed to get the transaction Id back from GestPay. Error {0}: {1}", result.ErrorCode, result.ErrorDescription).Text);
                    }
                    throw new Exception(T("Failed to get the transaction Id back from GestPay.").Text);
                }
            }

            LocalizedString ErrorHere = T("GestPay sent transaction information, but the Shop Login was wrong ({0})", a);

            Logger.Error(ErrorHere.Text);
            throw new Exception(ErrorHere.Text);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// After receiving a call form the GestPay servers, we use this method to parse what we have been sent and
        /// interpret it to an actual response.
        /// </summary>
        /// <param name="a">The GestPay Shop Login used in the transaction.</param>
        /// <param name="b">An encrypted string representing the transaction results.</param>
        public TransactionOutcome ReceiveS2STransaction(string a, string b)
        {
            var settings = _orchardServices
                           .WorkContext
                           .CurrentSite
                           .As <PaymentGestPaySettingsPart>();

            if (a == settings.GestPayShopLogin)
            {
                //decrypt the string b
                XmlNode outcome;
                try {
                    outcome = Decrypt(a, b, settings.UseTestEnvironment);
                } catch (Exception ex) {
                    //Log the error
                    LocalizedString error = T("Request to GestPay service failed: {0}", ex.Message);
                    Logger.Error(error.Text);
                    throw new Exception(error.Text);
                }

                string errors = "";
                //this is the method that should handle the end of the transaction on our end.
                TransactionOutcome result = new TransactionOutcome();
                try {
                    result = new TransactionOutcome(outcome);
                    Validator.ValidateObject(result, new ValidationContext(result), true);
                } catch (Exception ex) {
                    LocalizedString exception = T("Validation problems on the response received: {0}", ex.Message);
                    //Log the error
                    Logger.Error(exception.Text);
                    errors += exception.Text + Environment.NewLine;

                    result.TransactionResult = "KO";
                    result.ErrorDescription  = exception.Text;
                }

                //update the PaymentRecord for this transaction
                int pId;
                if (result != null && int.TryParse(result.ShopTransactionID, out pId))
                {
                    //We can process things normally
                    try {
                        decimal amount = decimal.Parse(result.Amount, CultureInfo.InvariantCulture);
                        if (amount != GetPaymentInfo(pId).Amount)
                        {
                            EndPayment(pId, false, null,
                                       T("The amount from the GestPay server ({0}) does not match the amount in our records ({1}).",
                                         amount.ToString("0.##", CultureInfo.InvariantCulture),
                                         GetPaymentInfo(pId).Amount.ToString("0.##", CultureInfo.InvariantCulture)).Text);
                        }
                        else if (result.TransactionResult == "OK" && result.ErrorCode == "0")
                        {
                            EndPayment(pId, true, null, null, string.Format("Bank ID: {0}\nAuth Code: {1}", result.BankTransactionID, result.AuthorizationCode));
                        }
                        else
                        {
                            result.TransactionResult = "KO";
                            EndPayment(pId, false, result.ErrorCode, result.ErrorDescription);
                        }
                    } catch (Exception exin) {
                        result.TransactionResult = "KO";
                        errors += exin.Message + Environment.NewLine;
                        throw new Exception(T("EndPayment caused exception: {0}.\npId: {1}\nerror:{2}", exin.Message, pId.ToString(), errors).Text);
                    }
                }
                else
                {
                    result.TransactionResult = "KO";
                    errors = T("Failed to identify transaction from GestPay's response. Additional error: {0}", errors).Text;
                    Logger.Error(errors);
                }

                result.ErrorDescription = errors;

                return(result);
            }

            LocalizedString ErrorHere = T("GestPay sent transaction information, but the Shop Login was wrong ({0})", a);

            Logger.Error(ErrorHere.Text);
            return(TransactionOutcome.InternalError(ErrorHere.Text));
        }
 public CoordinatorOutcomeRecordSchema(string transactionId, TransactionOutcome outcome)
 {
     this.transactionId = transactionId;
     this.outcome = outcome;
 }
 public static void Trace(Guid enlistmentId, string transactionId, TransactionOutcome outcome)
 {
     ParticipantOutcomeRecordSchema extendedData = new ParticipantOutcomeRecordSchema(transactionId, enlistmentId, outcome);
     TxTraceUtility.Trace(TraceEventType.Verbose, 0xb0027, Microsoft.Transactions.SR.GetString("ParticipantStateMachineFinished"), extendedData, null, enlistmentId, null);
 }
Ejemplo n.º 16
0
 public CustomerTransactionResult(decimal customerBalance, decimal amount, TransactionOutcome result, string failureMessage) : base(result, failureMessage)
 {
     CustomerBalance = customerBalance;
     Amount          = amount;
 }
Ejemplo n.º 17
0
        public static void Trace(Guid enlistmentId, string transactionId, TransactionOutcome outcome, TimeSpan timeout)
        {
            EnlistmentTimeoutRecordSchema extendedData = new EnlistmentTimeoutRecordSchema(transactionId, enlistmentId, outcome, timeout);

            TxTraceUtility.Trace(TraceEventType.Warning, 0xb0004, Microsoft.Transactions.SR.GetString("VolatileOutcomeTimeout"), extendedData, null, enlistmentId, null);
        }
Ejemplo n.º 18
0
 public AtmTransactionResult(decimal balance, TransactionOutcome result, string failureMessage) : base(result, failureMessage)
 {
     Balance = balance;
 }
 public ParticipantOutcomeRecordSchema(string transactionId, Guid enlistmentId, TransactionOutcome outcome)
 {
     this.transactionId = transactionId;
     this.enlistmentId  = enlistmentId;
     this.outcome       = outcome;
 }