//-----------------------------------------------------------------------------------------
        // CardRefund - Refunds an amount to a previously captured card transaction.
        //  Returns the tranactionCode for the request.
        //-----------------------------------------------------------------------------------------
        public string CardRefund(string captureTransCode, string transExternalId, decimal amount)
        {
            var transCode = "";
            var svc       = GetPaymentEngineService();

            try
            {
                CardRefundRequest request = new CardRefundRequest
                {
                    Amount                = amount,
                    TransactionCode       = captureTransCode,   // Transction code of the previously captured card amount.
                    TransactionExternalId = transExternalId,    // Provide either your transaction number or the bLoyal TransactionToken.
                    ReferenceNumber       = transExternalId
                };

                CardResponse response = svc.CardRefund(_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("CardRefund() 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("CardRefund() FAILED.  Status={0} ", response.Status));
                    msg.Add(string.Format("    Message:{0} ", response.Message));
                }
            }
            catch (bLoyal.Connectors.ApiException ex)
            {
                if (ex != null && !string.IsNullOrWhiteSpace(ex.Code) && ex.Code == "ServiceRedirect")
                {
                    ServiceURLHelper.IsbLoyalServiceUrlDown = true;
                }
                _logger.WriteLogError(ex, "CardRefund in PaymentEngineConnector");
            }
            catch (Exception ex)
            {
                _logger.WriteLogError(ex, "CardRefund in PaymentEngineConnector");
            }
            finally
            {
                if (svc != null)
                {
                    svc.Abort();
                }
            }

            return(transCode);
        }
예제 #2
0
        //-----------------------------------------------------------------------------------------
        // CardRefund - Refunds an amount to a previously captured card transaction.
        //  Returns the tranactionCode for the request.
        //-----------------------------------------------------------------------------------------
        public string CardRefund(string captureTransCode, string transExternalId, decimal amount, System.Windows.Forms.TextBox tbResults)
        {
            var transCode = "";
            var svc       = GetPaymentEngineService();

            try
            {
                CardRefundRequest request = new CardRefundRequest();

                request.Amount                = amount;
                request.TransactionCode       = captureTransCode;                                      // Transction code of the previously captured card amount.
                request.TransactionExternalId = transExternalId;                                       // Provide either your transaction number or the bLoyal TransactionToken.

                CardResponse  response = svc.CardRefund(_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("CardRefund() 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("CardRefund() 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("CardRefund() failed.  Exception: {0}", ex.ToString());
            }
            finally
            {
                if (svc != null)
                {
                    svc.Abort();
                }
            }

            return(transCode);
        }