/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="payment">The Payment for this transaction</param>
 /// <param name="remoteIP">The remote IP of the user initiating the request</param>
 public AuthorizeTransactionRequest(Payment payment, string remoteIP) : base(payment, remoteIP)
 {
     this._TransactionOrigin = TransactionOrigin.Internet;
 }
Exemple #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="payment">The Payment object associated with this request</param>
 /// <param name="recurringTransaction">The original recurring transactions that is being cancelled</param>
 /// <param name="remoteIP">Remote IP of the user initiating the request</param>
 public CancelRecurringTransactionRequest(Payment payment, Transaction recurringTransaction, string remoteIP) : base(payment, remoteIP)
 {
     this._TransactionOrigin    = TransactionOrigin.Internet;
     this._RecurringTransaction = recurringTransaction;
 }
        /// <summary>
        /// Gets a payment status that would become of the given payment after the specified transaction completes
        /// </summary>
        /// <param name="payment">The payment object</param>
        /// <param name="transaction">The transaction after which to determine the status</param>
        /// <returns>A payment status that would become of the given payment after the specified transaction completes</returns>
        public static PaymentStatus GetStatusAfterTransaction(Payment payment, Transaction transaction)
        {
            LSDecimal totalCaptured;
            LSDecimal totalAuthorized;
            LSDecimal temp;

            switch (transaction.TransactionType)
            {
            case TransactionType.Authorize:
                switch (transaction.TransactionStatus)
                {
                case TransactionStatus.Successful:
                    return(PaymentStatus.Authorized);

                case TransactionStatus.Failed:
                    return(PaymentStatus.AuthorizationFailed);

                case TransactionStatus.Pending:
                    return(PaymentStatus.AuthorizationPending);
                }
                break;

            case TransactionType.PartialCapture:
                switch (transaction.TransactionStatus)
                {
                case TransactionStatus.Successful:
                    totalCaptured   = payment.Transactions.GetTotalCaptured();
                    totalAuthorized = payment.Transactions.GetTotalAuthorized();
                    temp            = totalCaptured + transaction.Amount;
                    if (totalAuthorized > temp)
                    {
                        return(PaymentStatus.Authorized);
                    }
                    else
                    {
                        return(PaymentStatus.Captured);
                    }

                case TransactionStatus.Failed:
                    return(PaymentStatus.CaptureFailed);

                case TransactionStatus.Pending:
                    return(PaymentStatus.CapturePending);
                }
                break;

            case TransactionType.AuthorizeCapture:
                switch (transaction.TransactionStatus)
                {
                case TransactionStatus.Successful:
                    return(PaymentStatus.Captured);

                case TransactionStatus.Failed:
                    return(PaymentStatus.AuthorizationFailed);

                case TransactionStatus.Pending:
                    return(PaymentStatus.AuthorizationPending);
                }
                break;

            case TransactionType.Capture:
                switch (transaction.TransactionStatus)
                {
                case TransactionStatus.Successful:
                    return(PaymentStatus.Captured);

                case TransactionStatus.Failed:
                    return(PaymentStatus.CaptureFailed);

                case TransactionStatus.Pending:
                    return(PaymentStatus.CapturePending);
                }
                break;

            case TransactionType.PartialRefund:
            case TransactionType.Refund:
                switch (transaction.TransactionStatus)
                {
                case TransactionStatus.Successful:
                    totalCaptured = payment.Transactions.GetTotalCaptured();
                    if (totalCaptured > transaction.Amount)
                    {
                        //MAKE SURE THE TRANSACTION TYPE IS APPROPRIATE
                        transaction.TransactionType = TransactionType.PartialRefund;
                        return(PaymentStatus.Captured);
                    }
                    else
                    {
                        return(PaymentStatus.Refunded);
                    }

                case TransactionStatus.Failed:
                    return(PaymentStatus.Captured);

                case TransactionStatus.Pending:
                    return(PaymentStatus.RefundPending);
                }
                break;

            case TransactionType.Void:
                switch (transaction.TransactionStatus)
                {
                case TransactionStatus.Successful:
                    totalCaptured = payment.Transactions.GetTotalCaptured();
                    if (totalCaptured > 0)
                    {
                        return(PaymentStatus.Captured);
                    }
                    else
                    {
                        return(PaymentStatus.Void);
                    }

                case TransactionStatus.Failed:
                    //return PaymentStatus.VoidFailed;
                    return(payment.PaymentStatus);

                case TransactionStatus.Pending:
                    return(PaymentStatus.VoidPending);
                }
                break;

            case TransactionType.AuthorizeRecurring:
                if (transaction.TransactionStatus == TransactionStatus.Successful)
                {
                    // USE COMPLETED INSTEAD OF CAPTURED BECAUSE THIS PAYMENT CANNOT BE REFUNDED
                    // THROUGH THE EXISTING API
                    return(PaymentStatus.Completed);
                }
                else
                {
                    // VOID BECAUSE WE CANNOT RETRY RECURRING TRANSACTIONS
                    return(PaymentStatus.Void);
                }

            case TransactionType.CancelRecurring:
                return(PaymentStatus.Void);
            }

            //THIS SHOULD NEVER HAPPEN IF ALL TRANSACTION TYPES AND TRANSACTION STATUSES ARE SPECIFIED ABOVE
            throw new ArgumentOutOfRangeException("Invalid Transaction Type or Transaction Status. Type:"
                                                  + transaction.TransactionType.ToString() +
                                                  "Status:" + transaction.TransactionStatus.ToString());
        }