//-----------------------------------------------------------------------------------------
        // CardAuthorize - Authorizes that the card has an adequate balance and puts a hold on the card.
        //  Returns the tranactionCode for the request.
        //-----------------------------------------------------------------------------------------
        public string CardAuthorize(string cardNumber, string tenderCode, string transExternalId, decimal amount, System.Windows.Forms.TextBox tbResults, Guid?customerUid = null)
        {
            var transCode = "";
            var svc       = GetPaymentEngineService();

            try
            {
                CardAuthorizeRequest request = new CardAuthorizeRequest
                {
                    // Build up the card authorization request based on what the user/cashier entered.
                    CardNumber            = cardNumber,
                    CustomerUid           = customerUid ?? Guid.Empty, // Optionally provide the bLoyal customer uid if you have it.
                    CardPin               = "",                        // Some clients require a PIN.
                    Swiped                = false,                     // Set to true when a card is swiped and false if manually keyed.
                    Amount                = amount,
                    TenderCode            = tenderCode,                // Used bLoyal to determine wehtehr it's a gift card, egift, coupon, on account, or loyalty tender.
                    TransactionExternalId = transExternalId            // Provide either your transaction number or the bLoyal TransactionToken.
                                                                       //request.ReferenceNumber = transExternalId;
                };

                CardResponse response = svc.CardAuthorize(_accessKey, _storeCode, _deviceCode, request);    // StoreCode and DeviceCode are not required if you are using a device AccessKey.

                List <string> msg = new List <string>();
                if (response.Status == CardRequestStatus.Approved)
                {
                    transCode = response.TransactionCode;
                    msg.Add(string.Format("CardAuthorize() succeeded.  Authorization Code:{0} ", response.TransactionCode));
                    msg.Add(string.Format("    Current Balance={0}, Available Balance={1} ", response.CurrentBalance, response.AvailableBalance));
                }
                else
                {
                    msg.Add(string.Format("CardAuthorize() FAILED.  Status={0} ", response.Status));
                    msg.Add(string.Format("    Message:{0} ", response.Message));
                    msg.Add(string.Format("    Current Balance={0}, Available Balance={1} ", response.CurrentBalance, response.AvailableBalance));
                }
                tbResults.Lines = msg.ToArray();
            }
            catch (bLoyal.Connectors.ApiException ex)
            {
                if (ex != null && !string.IsNullOrWhiteSpace(ex.Code) && ex.Code == "ServiceRedirect")
                {
                    ServiceURLHelper.IsbLoyalServiceUrlDown = true;
                }
                _logger.WriteLogError(ex, "CardAuthorize in PaymentEngineConnector");
            }
            catch (Exception ex)
            {
                _logger.WriteLogError(ex, "CardAuthorize in PaymentEngineConnector");
            }
            finally
            {
                if (svc != null)
                {
                    svc.Abort();
                }
            }
            return(transCode);
        }
Beispiel #2
0
        //-----------------------------------------------------------------------------------------
        // CardAuthorize - Authorizes that the card has an adequate balance and puts a hold on the card.
        //  Returns the tranactionCode for the request.
        //-----------------------------------------------------------------------------------------
        public string CardAuthorize(string cardNumber, string tenderCode, string transExternalId, decimal amount, System.Windows.Forms.TextBox tbResults, Guid?customerUid = null)
        {
            var transCode = "";
            var svc       = GetPaymentEngineService();

            try
            {
                CardAuthorizeRequest request = new CardAuthorizeRequest();

                // Build up the card authorization request based on what the user/cashier entered.
                request.CardNumber            = cardNumber;
                request.CustomerUid           = customerUid ?? Guid.Empty;                                // Optionally provide the bLoyal customer uid if you have it.
                request.CardPin               = "";                                                       // Some clients require a PIN.
                request.Swiped                = false;                                                    // Set to true when a card is swiped and false if manually keyed.
                request.Amount                = amount;
                request.TenderCode            = tenderCode;                                               // Used bLoyal to determine wehtehr it's a gift card, egift, coupon, on account, or loyalty tender.
                request.TransactionExternalId = transExternalId;                                          // Provide either your transaction number or the bLoyal TransactionToken.

                CardResponse  response = svc.CardAuthorize(_accessKey, _storeCode, _deviceCode, request); // StoreCode and DeviceCode are not required if you are using a device AccessKey.
                List <string> msg      = new List <string>();
                if (response.Status == CardRequestStatus.Approved)
                {
                    transCode = response.TransactionCode;
                    msg.Add(string.Format("CardAuthorize() succeeded.  Authorization Code:{0} ", response.TransactionCode));
                    msg.Add(string.Format("    Current Balance={0}, Available Balance={1} ", response.CurrentBalance, response.AvailableBalance));
                }
                else
                {
                    msg.Add(string.Format("CardAuthorize() FAILED.  Status={0} ", response.Status));
                    msg.Add(string.Format("    Message:{0} ", response.Message));
                    msg.Add(string.Format("    Current Balance={0}, Available Balance={1} ", response.CurrentBalance, response.AvailableBalance));
                }
                tbResults.Lines = msg.ToArray();
            }
            catch (System.Exception ex)
            {
                tbResults.Text = string.Format("CardAuthorize() failed.  Exception: {0}", ex.ToString());
            }
            finally
            {
                if (svc != null)
                {
                    svc.Abort();
                }
            }
            return(transCode);
        }