예제 #1
0
 private LoyaltyResponse PostVoucherTransaction(string inSyndicateCode, VoucherTransactionInfo transaction)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.PostVoucherTransactions(inSyndicateCode, CreateVoucherTransaction(transaction));
         if (response != null)
         {
             foreach (var item in response)
             {
                 if (!item.IsProcessedSuccessfully)
                 {
                     return(CreateResponseError(item.Error,
                                                item.Error,
                                                LoyaltyResponseCode.PostTransactionFailed));
                 }
             }
             return(CreateResponseNoError());
         }
         return(CreateResponseError(
                    @"Failed to process vouchers",
                    @"Failed to process vouchers",
                    LoyaltyResponseCode.PostTransactionFailed));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed));
     }
     catch (Exception ex)
     {
         return(CreateResponseError(
                    "@Failed to post transaction to server",
                    ex.Message,
                    LoyaltyResponseCode.PostTransactionFailed));
     }
 }
예제 #2
0
 public LoyaltyResponse ProcessVoucherTransaction(string inSyndicateCode, VoucherTransactionInfo transaction)
 {
     return(LoyaltyVoucher.Instance.ProcessVoucherTransaction(inSyndicateCode, transaction));
 }
예제 #3
0
        ApiVouchersUsageViewModel CreateVoucherTransaction(VoucherTransactionInfo inTransactionInfo)
        {
            var voucherUsageViewModel = new ApiVouchersUsageViewModel();

            voucherUsageViewModel.TransactionReferenceNumber = inTransactionInfo.TransactionReferenceNumber;
            Guid memberUniqueId = Guid.Empty;

            Guid.TryParse(inTransactionInfo.MemberUniqueId, out memberUniqueId);
            if (!string.IsNullOrWhiteSpace(inTransactionInfo.GiftCardNumber))
            {
                voucherUsageViewModel.GiftCard = new ApiGiftCardUsageRequestViewModel();
                voucherUsageViewModel.GiftCard.GiftCardNumber = inTransactionInfo.GiftCardNumber;
                voucherUsageViewModel.GiftCard.PointsRedeemed = inTransactionInfo.PointsRedeemed;
                voucherUsageViewModel.GiftCard.MemberUniqueId = memberUniqueId;
                if (memberUniqueId == Guid.Empty)
                {
                    voucherUsageViewModel.GiftCard.MemberUniqueId = null;
                }
                voucherUsageViewModel.GiftCard.SiteCode        = inTransactionInfo.SiteCode;
                voucherUsageViewModel.GiftCard.TotalSaleAmount = inTransactionInfo.TotalSaleAmount;
                voucherUsageViewModel.GiftCard.Date            = inTransactionInfo.TransactionDate;
                voucherUsageViewModel.GiftCard.InvoiceNumber   = inTransactionInfo.InvoiceNumber;
            }

            if (!string.IsNullOrWhiteSpace(inTransactionInfo.PocketVoucherNumber))
            {
                voucherUsageViewModel.PocketVoucher = new ApiPocketVoucherUsageRequestViewModel();
                voucherUsageViewModel.PocketVoucher.PocketVoucherNumber = inTransactionInfo.PocketVoucherNumber;
                voucherUsageViewModel.PocketVoucher.DiscountAmount      = inTransactionInfo.PocketVoucherDiscountAmount;
                voucherUsageViewModel.PocketVoucher.MemberUniqueId      = memberUniqueId;
                if (memberUniqueId == Guid.Empty)
                {
                    voucherUsageViewModel.PocketVoucher.MemberUniqueId = null;
                }
                voucherUsageViewModel.PocketVoucher.SiteCode        = inTransactionInfo.SiteCode;
                voucherUsageViewModel.PocketVoucher.TotalSaleAmount = inTransactionInfo.TotalSaleAmount;
                voucherUsageViewModel.PocketVoucher.Date            = inTransactionInfo.TransactionDate;
                voucherUsageViewModel.PocketVoucher.InvoiceNumber   = inTransactionInfo.InvoiceNumber;
            }

            if (!string.IsNullOrWhiteSpace(inTransactionInfo.VoucherName))
            {
                voucherUsageViewModel.Voucher                 = new ApiVoucherUsageRequestViewModel();
                voucherUsageViewModel.Voucher.VoucherName     = inTransactionInfo.VoucherName;
                voucherUsageViewModel.Voucher.DiscountAmount  = inTransactionInfo.MemberVoucherDiscountAmount;
                voucherUsageViewModel.Voucher.MemberUniqueId  = memberUniqueId;
                voucherUsageViewModel.Voucher.SiteCode        = inTransactionInfo.SiteCode;
                voucherUsageViewModel.Voucher.TotalSaleAmount = inTransactionInfo.TotalSaleAmount;
                voucherUsageViewModel.Voucher.Date            = inTransactionInfo.TransactionDate;
                voucherUsageViewModel.Voucher.InvoiceNumber   = inTransactionInfo.InvoiceNumber;
            }

            if (inTransactionInfo.DiscountUsages != null)
            {
                voucherUsageViewModel.Discounts = new List <ApiDiscountUsageRequestViewModel>();
                foreach (var item in inTransactionInfo.DiscountUsages)
                {
                    var discountusage = new ApiDiscountUsageRequestViewModel();
                    discountusage.Date           = inTransactionInfo.TransactionDate;
                    discountusage.DiscountAmount = item.DiscountAmount;
                    discountusage.DiscountCode   = item.DiscountCode;
                    discountusage.MemberUniqueId = memberUniqueId;
                    if (memberUniqueId == Guid.Empty)
                    {
                        discountusage.MemberUniqueId = null;
                    }
                    discountusage.SiteCode        = inTransactionInfo.SiteCode;
                    discountusage.TotalSaleAmount = inTransactionInfo.TotalSaleAmount;
                    discountusage.InvoiceNumber   = inTransactionInfo.InvoiceNumber;
                    voucherUsageViewModel.Discounts.Add(discountusage);
                }
            }
            return(voucherUsageViewModel);
        }