コード例 #1
0
        public void Deserialize_CompleteIsUnsuccessful_ReturnsNonEmptyTransactionErrorCode()
        {
            ResultParser   resultParser = new ResultParser();
            CompleteResult result       = resultParser.Deserialize <CompleteResult>(Factory.CompleteResultError);

            Assert.IsNotNullOrEmpty(result.ErrorDetails.TransactionErrorCode);
        }
コード例 #2
0
        public void Deserialize_CompleteIsSuccessful_ReturnsSuccessTrue()
        {
            ResultParser   resultParser = new ResultParser();
            CompleteResult result       = resultParser.Deserialize <CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNull(result.Status);
        }
コード例 #3
0
        public void Deserialize_CompleteResultXml_ReturnsCompleteResultObject()
        {
            ResultParser   resultParser = new ResultParser();
            CompleteResult result       = resultParser.Deserialize <CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNull(result);
        }
コード例 #4
0
        public void Deserialize_CompleteIsSuccessful_ReturnsNonEmptyTransactionNumber()
        {
            ResultParser   resultParser = new ResultParser();
            CompleteResult result       = resultParser.Deserialize <CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNullOrEmpty(result.TransactionNumber);
        }
コード例 #5
0
        public void Deserialize_CompleteIsSuccessful_ReturnsNonEmptyPaymentMethod()
        {
            ResultParser   resultParser = new ResultParser();
            CompleteResult result       = resultParser.Deserialize <CompleteResult>(Factory.CompleteResult);

            Assert.IsNotNullOrEmpty(result.PaymentMethod);
        }
コード例 #6
0
        public void Deserialize_CompleteIsUnsuccessful_ReturnsSuccessFalse()
        {
            ResultParser   resultParser = new ResultParser();
            CompleteResult result       = resultParser.Deserialize <CompleteResult>(Factory.CompleteResultError);

            Assert.IsFalse(result.Success);
        }
コード例 #7
0
        public override async Task <IExecutionResult> Process(ExternalTask externalTask)
        {
            if (!externalTask.Variables.TryGetValue("cartype", out var cartypeVar))
            {
                throw new System.Exception("error bleh");
            }

            var carType = cartypeVar.Value;

            await Task.Delay(1000);

            Dictionary <string, Variable> Variables = new Dictionary <string, Variable>();

            if ((string)carType == "a" || (string)carType == "b" || (string)carType == "c")
            {
                Variables["AvailCars"] = Variable.Integer(5);
            }
            else
            {
                Variables["AvailCars"] = Variable.Integer(0);
            }

            var compRes = new CompleteResult(Variables);

            return(compRes);
        }
コード例 #8
0
 public EzReceiveRewardsResult(
     CompleteResult result
     )
 {
     StampSheet = result.stampSheet;
     StampSheetEncryptionKeyId = result.stampSheetEncryptionKeyId;
 }
コード例 #9
0
        public void GetTransactionDetails_ReturnsCorrectResult(TransactionStatus transactionStatus, bool expected)
        {
            CompleteResult completeResult = new CompleteResult {
                TransactionStatus = transactionStatus
            };

            Assert.AreEqual(expected, completeResult.GetTransactionDetails);
        }
コード例 #10
0
        public void Success_ReturnsCorrectResult(TransactionStatus transactionStatus, bool statusSuccess, bool expected)
        {
            Status status = Factory.CreateStatus(statusSuccess);

            CompleteResult completeResult = new CompleteResult {
                Status = status, TransactionStatus = transactionStatus
            };

            Assert.AreEqual(expected, completeResult.Success);
        }
コード例 #11
0
        public override async Task <IExecutionResult> Process(ExternalTask externalTask)
        {
            await Task.Delay(1000);

            Dictionary <string, Variable> Variables = new Dictionary <string, Variable>();

            Variables["ProcessMessage"] = Variable.String("placeholder message - all work completed");

            var compRes = new CompleteResult(Variables);

            return(compRes);
        }
コード例 #12
0
ファイル: NotifyHandler.cs プロジェクト: cph-js284/si-camunda
        public override async Task <IExecutionResult> Process(ExternalTask externalTask)
        {
            await Task.Delay(1000);

            Dictionary <string, Variable> Variables = new Dictionary <string, Variable>();

            Variables["NotifyMesssage"] = Variable.String("Placeholder - staff notified, initiating meltdown");

            var compRes = new CompleteResult(Variables);

            return(compRes);
        }
コード例 #13
0
        public void DeleteOrder_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);

            //  Act
            CompleteResult result = mc.DeleteOrder("abcde", "12345");

            //  Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Complete);
        }
コード例 #14
0
        public override async Task <IExecutionResult> Process(ExternalTask externalTask)
        {
            await Task.Delay(1000);

            Dictionary <string, Variable> Variables = new Dictionary <string, Variable>();

            Variables["updateSucces"] = Variable.String("true");

            var compRes = new CompleteResult(Variables);

            return(compRes);
        }
コード例 #15
0
        public override async Task <IExecutionResult> Process(ExternalTask externalTask)
        {
            await Task.Delay(1000);

            Dictionary <string, Variable> Variables = new Dictionary <string, Variable>();

            Variables["updateSucces"] = Variable.String("Placeholder - email sent to confirmation email sent to client");

            var compRes = new CompleteResult(Variables);

            return(compRes);
        }
コード例 #16
0
        public void DeleteMergeVar_Successful()
        {
            //  Arrange
            MailChimpManager mc    = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult       lists = mc.GetLists();

            mc.AddMergeVar(lists.Data.First().Id, "TESTDELETE", "Test Value");

            // Act
            CompleteResult result = mc.DeleteMergeVar(lists.Data.First().Id, "TESTDELETE");

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Complete);
        }
コード例 #17
0
        public CompleteResult Complete(string orderRef)
        {
            Log.InfoFormat("Calling Complete for orderRef:{0}.", orderRef);

            string hash      = _hasher.Create(_payExSettings.AccountNumber, orderRef, _payExSettings.EncryptionKey);
            string xmlResult = _orderFacade.Complete(_payExSettings.AccountNumber, orderRef, hash);

            CompleteResult result = _resultParser.Deserialize <CompleteResult>(xmlResult);

            if (result.Status.Success)
            {
                Log.InfoFormat("Successfully called Complete for orderRef:{0}. Result:{1}", orderRef, xmlResult);
            }
            else
            {
                Log.ErrorFormat("Error when calling Complete for orderRef:{0}. Result:{1}", orderRef, xmlResult);
            }
            return(result);
        }
コード例 #18
0
    public static int ListsMergeVarSet(SqlString apikey, SqlString list_id, SqlString tag, SqlString value)
    {
        try
        {
            MailChimpManager mc = new MailChimpManager(apikey.ToString());

            CompleteResult result = mc.SetMergeVar(list_id.ToString(), tag.ToString(), value.ToString());

            SqlDataRecord record = new SqlDataRecord(CompleteResultsMetaData);
            record.SetBoolean(0, result.Complete);

            SqlContext.Pipe.Send(record);
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
            return(1);
        }
        return(0);
    }
コード例 #19
0
    public static int ListsInterestGroupingUpdate(SqlString apikey, SqlString list_id, SqlInt32 grouping_id, SqlString name, SqlString value)
    {
        try
        {
            MailChimpManager mc = new MailChimpManager(apikey.ToString());

            CompleteResult result = mc.UpdateListInterestGrouping(list_id.ToString(), grouping_id.Value, name.ToString(), value.ToString());

            SqlDataRecord record = new SqlDataRecord(CompleteResultsMetaData);
            record.SetBoolean(0, result.Complete);

            SqlContext.Pipe.Send(record);
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
            return(1);
        }
        return(0);
    }
コード例 #20
0
        public void ResetMergeVar_Successful()
        {
            //  Arrange
            MailChimpManager mc    = new MailChimpManager(TestGlobal.Test_APIKey);
            ListResult       lists = mc.GetLists();

            // we don't want to have an existing merge var interfere
            try { mc.DeleteMergeVar(lists.Data.First().Id, "TESTRESET"); }
            catch { }
            mc.AddMergeVar(lists.Data.First().Id, "TESTRESET", "Test Value");

            // Act
            CompleteResult result = mc.ResetMergeVar(lists.Data.First().Id, "TESTRESET");

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Complete);

            // Clean up
            mc.DeleteMergeVar(lists.Data.First().Id, "TESTRESET");
        }
コード例 #21
0
        public void AddOrder_Successful()
        {
            //  Arrange
            MailChimpManager mc = new MailChimpManager(TestGlobal.Test_APIKey);

            //  Act
            Order order = new Order();

            // Create a list and a Campaign with Ecommerce360 enabled.
            // A link from this campaign mail will contain:
            // ?mc_cid=06a8d1eea7&mc_eid=461b47eac7
            // mc_cid = CampaignId
            // mc_eid = EmailId
            order.CampaignId = "";
            order.EmailId    = "";

            order.Id        = "12345";
            order.StoreId   = "abcde";
            order.StoreName = "My Sports Store";
            order.Total     = 100;
            order.Tax       = 30;
            order.Items     = new List <OrderItem>();

            OrderItem item = new OrderItem();

            item.ProductId    = 1;
            item.ProductName  = "Tennis Ball";
            item.CategoryId   = 1;
            item.CategoryName = "Balls";
            item.Quantity     = 2;
            item.Cost         = 50;

            order.Items.Add(item);

            CompleteResult result = mc.AddOrder(order);

            //  Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Complete);
        }
コード例 #22
0
        public PaymentCompleteResult Complete(PaymentMethod currentPayment, string orderRef)
        {
            Log.InfoFormat("Completing payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
            CompleteResult completeResult = _paymentManager.Complete(orderRef);

            if (!completeResult.Success || string.IsNullOrWhiteSpace(completeResult.TransactionNumber))
            {
                return new PaymentCompleteResult {
                           TransactionErrorCode = completeResult.ErrorDetails != null ? completeResult.ErrorDetails.TransactionErrorCode : string.Empty
                }
            }
            ;

            if (completeResult.GetTransactionDetails)
            {
                Log.InfoFormat("Retrieving transaction details for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);

                if (_paymentCompleter == null)
                {
                    _paymentCompleter = new UpdateTransactionDetails(null, _paymentManager);
                }
                _paymentCompleter = new UpdateTransactionDetails(_paymentCompleter, _paymentManager);
            }

            _paymentActions.UpdatePaymentInformation(currentPayment, completeResult.TransactionNumber, completeResult.PaymentMethod);

            PaymentCompleteResult result = new PaymentCompleteResult {
                Success = true
            };

            if (_paymentCompleter != null)
            {
                result = _paymentCompleter.Complete(currentPayment, orderRef);
            }

            Log.InfoFormat("Successfully completed payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId);
            return(result);
        }
    }
コード例 #23
0
        private void UpdateAgreement(CompleteResult result, Order order)
        {
            // Check if the transaction is based on an agreement
            if (string.IsNullOrEmpty(result.AgreementRef))
            {
                return;
            }

            order.SubscriptionTransactionId = result.AgreementRef;
            // Check if the agreement already exists
            PayExAgreement agreement = _payExAgreementService.GetByAgreementRef(result.AgreementRef);

            if (agreement == null)
            {
                // Save the new agreement
                agreement = new PayExAgreement
                {
                    AgreementRef            = result.AgreementRef,
                    CustomerId              = order.Customer.Id,
                    MaxAmount               = _payExPaymentSettings.AgreementMaxAmount,
                    Name                    = result.MaskedNumber ?? "Sparat kort", // TODO
                    PaymentMethod           = result.PaymentMethod,
                    PaymentMethodExpireDate = result.PaymentMethodExpireDate,
                    PaymentMethodSystemName = order.PaymentMethodSystemName,
                    NumberOfUsages          = 1,
                    LastUsedDate            = DateTime.UtcNow,
                    CreatedDate             = DateTime.UtcNow,
                };
                _payExAgreementService.InsertPayExAgreement(agreement);
            }
            else
            {
                // Log usage
                agreement.NumberOfUsages++;
                agreement.LastUsedDate = DateTime.UtcNow;
                _payExAgreementService.UpdatePayExAgreement(agreement);
            }
        }
コード例 #24
0
        public static CompleteResult ParseCompleteResult(string xmlText)
        {
            var result = new CompleteResult {
                RawXml = xmlText
            };
            var root = result.GetRootElement();

            ParseTransactionResult(result, root);
            foreach (var node in root.Elements())
            {
                var value = node.Value;
                var name  = node.Name.LocalName.ToLower();
                int i;
                switch (name)
                {
                case "orderid":
                    result.OrderID = value;
                    break;

                case "paymentmethod":
                    result.PaymentMethod = value;
                    break;

                case "amount":
                    int.TryParse(value, out i);
                    result.Amount = i / 100.0M;
                    break;

                case "agreementref":
                    result.AgreementRef = value;
                    break;

                case "paymentmethodexpiredate":
                    result.PaymentMethodExpireDate = value.DateFromPayEx();
                    break;

                case "maskednumber":
                    result.MaskedNumber = value;
                    break;

                case "transactionerrorcode":
                    result.TransactionErrorCode = value;
                    break;

                case "transactionerrordescription":
                    result.TransactionErrorDescription = value;
                    break;

                case "transactionthirdpartyerror":
                    result.TransactionThirdPartyError = value;
                    break;

                case "alreadycompleted":
                    result.AlreadyCompleted = string.Compare(value, "true", true) == 0;
                    break;

                case "pending":
                    result.Pending = string.Compare(value, "true", true) == 0;
                    break;
                }
            }

            return(result);
        }
コード例 #25
0
 internal override void ParseResponseBody(System.IO.Stream inputStream, string contentType, long contentLength)
 {
     completeResult = new CompleteResult();
     XmlParse.ParseCompleteMultipartUploadResult(inputStream, completeResult);
 }
コード例 #26
0
ファイル: OnCompleteEventArgs.cs プロジェクト: AlienJust/RPD
 /// <summary>
 /// Инициализирует новый экземпляр класса
 /// </summary>
 /// <param name="resultCode">Результат операции</param>
 /// <param name="message">Текстовое сообщение</param>
 /// <param name="argument">Дополнительный аргумент</param>
 public OnCompleteEventArgs(CompleteResult resultCode, string message, object argument)
 {
     this.resultCode = resultCode;
     this.message    = message;
     this.argument   = argument;
 }
コード例 #27
0
ファイル: OnCompleteEventArgs.cs プロジェクト: AlienJust/RPD
 /// <summary>
 /// Инициализирует новый экземпляр класса
 /// </summary>
 /// <param name="resultCode">Результат операции</param>
 /// <param name="message">Текстовое сообщение</param>
 public OnCompleteEventArgs(CompleteResult resultCode, string message)
 {
     this.resultCode = resultCode;
     this.message    = message;
     this.argument   = null;
 }
コード例 #28
0
        public async Task <Order> DoComplete(string orderRef, bool isCallback)
        {
            // Get our payment processor
            var processor = _paymentService.LoadPaymentMethodBySystemName(PaymentSystemName) as PayExPaymentProcessor;

            if (processor == null ||
                !_paymentService.IsPaymentMethodActive(processor) || !processor.PluginDescriptor.Installed)
            {
                throw new NopException("PayEx module is not active or cannot be loaded.");
            }

            if (string.IsNullOrWhiteSpace(orderRef))
            {
                return(null);
            }

            // Call complete
            CompleteResult result = await processor.Complete(orderRef);

            // Attempt to get the order associated with the transaction.
            Order order = null;

            if (!string.IsNullOrEmpty(result.OrderID) &&
                Guid.TryParse(result.OrderID, out var orderGuid))
            {
                order = _orderService.GetOrderByGuid(orderGuid);
            }

            // If the transaction is pending, then we are expecting a callback to this method within 3 seconds due to occational delay from Swish in m-commerce flow.
            // Upon completion in separate process, the order PaymentStatus will have changed from Pending to Paid or Failed.
            if (order != null && result.Pending == true && !isCallback)
            {
                for (int i = 0; i < 5; i++)
                {
                    await Task.Delay(1000);

                    order = _orderService.GetOrderById(order.Id);
                    // If the order status changes from pending then the below code has already been run by a separate process. We are done.
                    if (order.PaymentStatus != PaymentStatus.Pending)
                    {
                        return(order);
                    }
                }

                // This should very rarely happen. But in case the transaction callback failed, we can check it here again.
                result = await processor.Complete(orderRef);
            }

            if (order != null && result.IsTransactionSuccessful)
            {
                // Add order note
                var note = new StringBuilder();
                note.AppendLine($"PayEx: Complete SUCCEEDED {(isCallback ? "synchronously" : "via callback")}");
                note.AppendLine("PaymentMethod: " + result.PaymentMethod);
                note.AppendLine(string.Format("Amount: {0:n2}", result.Amount));
                note.AppendLine("TransactionNumber: " + result.TransactionNumber);
                note.AppendLine("TransactionStatus: " + result.TransactionStatus);
                order.OrderNotes.Add(
                    new OrderNote
                {
                    Note = note.ToString(),
                    DisplayToCustomer = false,
                    CreatedOnUtc      = DateTime.UtcNow,
                });
                _orderService.UpdateOrder(order);

                // Validate order total
                if (_payExPaymentSettings.ValidateOrderTotal &&
                    !Math.Round(result.Amount.Value, 2).Equals(Math.Round(order.OrderTotal, 2)))
                {
                    string errorStr = string.Format(
                        "PayEx Complete. Returned order total {0:n2} doesn't equal order total {1:n2}", result.Amount,
                        order.OrderTotal);
                    _logger.Error(errorStr, customer: order.Customer);

                    return(order);
                }

                UpdateAgreement(result, order);

                UpdateOrderPaymentStatus(result, order);

                return(order);
            }
            //else // Transaction not successful
            //{
            //    string note = "Transaction was not successful.";
            //    if (order != null)
            //        AddOrderNote(order, note);
            //    return false;
            //}
            else // Request or transaction not successful
            {
                // Logg error or failure
                var note = new StringBuilder();
                note.AppendLine("PayEx: Complete FAILED");
                note.AppendLine("ErrorCode: " + result.ErrorCode);
                note.AppendLine("Description: " + result.Description);
                note.AppendLine("ThirdPartyError: " + result.ThirdPartyError);
                note.AppendLine("ParamName: " + result.ParamName);
                note.AppendLine("TransactionStatus: " + result.TransactionStatus);
                if (result.TransactionErrorCode != null)
                {
                    note.AppendLine("TransactionErrorCode: " + result.TransactionErrorCode);
                    note.AppendLine("TransactionErrorDescription: " + result.TransactionErrorDescription);
                    note.AppendLine("TransactionThirdPartyError: " + result.TransactionThirdPartyError);
                }

                note.AppendLine("PaymentMethod: " + result.PaymentMethod);
                note.AppendLine(string.Format("Amount: {0:n2}", result.Amount));
                note.AppendLine("AlreadyCompleted: " + result.AlreadyCompleted);
                note.AppendLine("OrderID: " + result.OrderID);
                if (!result.IsRequestSuccessful)
                {
                    _logger.Error(note.ToString());
                }
                if (order != null)
                {
                    AddOrderNote(order, note.ToString());
                }
            }

            return(null);
        }