Ejemplo n.º 1
0
        /// <summary>
        /// This method executes immediately after an order has bene submitted for any reward post processing required.
        /// </summary>
        public virtual void OrderPostProcessing(IOrder order)
        {
            IList <Product> rewardProducts = GetRewardProducts(order.Products);

            if (rewardProducts.Count <= 0)
            {
                return;
            }
            if (CustomerId == 0)
            {
                throw new ApplicationException("CustomerId cannot be zero");
            }

            if (IsRewardPointsAccount)
            {
                // Deduct points
                var createPointTransactionRequest = new CreatePointTransactionRequest
                {
                    CustomerID      = CustomerId,
                    PointAccountID  = RewardPointsAccountId.Value,
                    TransactionType = PointTransactionType.Adjustment,
                    Amount          = -1 * rewardProducts.Count(),
                    Reference       = string.Format("Applied Item Code: {0}", string.Join(", ", rewardProducts.Select(p => p.ItemCode)))
                };

                var response = Api.CreatePointTransaction(createPointTransactionRequest);
            }

            AddProductsToPurchasedExtendedGroup(rewardProducts);
        }
Ejemplo n.º 2
0
        public void OrderPostProcessing(IOrder order)
        {
            var rewardProducts = GetRewardProducts(order.Products);

            if (rewardProducts.Count <= 0)
            {
                return;
            }
            if (CustomerId == 0)
            {
                throw new ApplicationException("CustomerId cannot be zero");
            }

            if (!IsRewardPointsAccount)
            {
                return;
            }
            foreach (var rp in rewardProducts)
            {
                var discount = (RecruitingRewardDiscount)rp.Discounts[0];

                // Deduct  reward cash
                var createPointTransactionRequest = new CreatePointTransactionRequest
                {
                    CustomerID      = CustomerId,
                    PointAccountID  = RewardPointsAccountId.Value,
                    TransactionType = PointTransactionType.Adjustment,
                    Amount          = -1 * discount.AppliedAmount,
                    Reference       =
                        string.Format("Applied Item Code: {0}",
                                      string.Join(", ", rp.ItemCode))
                };

                var response = Api.CreatePointTransaction(createPointTransactionRequest);
            }
            AddProductsToPurchasedExtendedGroup(rewardProducts);
        }
Ejemplo n.º 3
0
 /// <remarks/>
 public void CreatePointTransactionAsync(CreatePointTransactionRequest CreatePointTransactionRequest, object userState) {
     if ((this.CreatePointTransactionOperationCompleted == null)) {
         this.CreatePointTransactionOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreatePointTransactionOperationCompleted);
     }
     this.InvokeAsync("CreatePointTransaction", new object[] {
                 CreatePointTransactionRequest}, this.CreatePointTransactionOperationCompleted, userState);
 }
Ejemplo n.º 4
0
 /// <remarks/>
 public void CreatePointTransactionAsync(CreatePointTransactionRequest CreatePointTransactionRequest) {
     this.CreatePointTransactionAsync(CreatePointTransactionRequest, null);
 }