//-----------------------------------------------------------------------------------------
        // CardCapture - Captures a previously authorized card amount.
        //  Returns the tranactionCode for the request.
        //-----------------------------------------------------------------------------------------
        public string CardCapture(string authTransCode, string transExternalId, decimal amount, System.Windows.Forms.TextBox tbResults)
        {
            var transCode = "";
            var svc       = GetPaymentEngineService();

            try
            {
                CardCaptureRequest request = new CardCaptureRequest
                {
                    TransactionCode       = authTransCode, // Transaction code for the previously authorized transaction.
                    Amount                = amount,
                    TransactionExternalId = transExternalId,
                    ReferenceNumber       = transExternalId,
                };

                CardResponse response = svc.CardCapture(_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("CardCapture() succeeded.  Transaction Code:{0}", response.TransactionCode));
                    msg.Add(string.Format("    Current Balance={0}, Available Balance={1} ", response.CurrentBalance, response.AvailableBalance));
                }
                else
                {
                    msg.Add(string.Format("CardCapture() FAILED.  Status={0} ", response.Status));
                    msg.Add(string.Format("    Message:{0} ", response.Message));
                }
                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, "CardCapture in PaymentEngineConnector");
            }
            catch (Exception ex)
            {
                _logger.WriteLogError(ex, "CardCapture in PaymentEngineConnector");
            }
            finally
            {
                if (svc != null)
                {
                    svc.Abort();
                }
            }
            return(transCode);
        }
Пример #2
0
        //-----------------------------------------------------------------------------------------
        // CardCapture - Captures a previously authorized card amount.
        //  Returns the tranactionCode for the request.
        //-----------------------------------------------------------------------------------------
        public string CardCapture(string authTransCode, string transExternalId, decimal amount, System.Windows.Forms.TextBox tbResults)
        {
            var transCode = "";
            var svc       = GetPaymentEngineService();

            try
            {
                CardCaptureRequest request = new CardCaptureRequest();

                request.TransactionCode       = authTransCode; // Transaction code for the previously authorized transaction.
                request.Amount                = amount;
                request.TransactionExternalId = transExternalId;
                CardResponse  response = svc.CardCapture(_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("CardCapture() succeeded.  Transaction Code:{0}", response.TransactionCode));
                    msg.Add(string.Format("    Current Balance={0}, Available Balance={1} ", response.CurrentBalance, response.AvailableBalance));
                }
                else
                {
                    msg.Add(string.Format("CardCapture() FAILED.  Status={0} ", response.Status));
                    msg.Add(string.Format("    Message:{0} ", response.Message));
                }
                tbResults.Lines = msg.ToArray();
            }
            catch (System.Exception ex)
            {
                tbResults.Text = string.Format("CardCapture() failed.  Exception: {0}", ex.ToString());
            }
            finally
            {
                if (svc != null)
                {
                    svc.Abort();
                }
            }
            return(transCode);
        }