Exemplo n.º 1
0
        /// <summary>
        /// Acquires the payment if payment is authorized.
        /// </summary>
        /// <param name="payment"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        /// <remarks>http://www.securetrading.com/files/documentation/STPP-Transaction-Update.pdf
        /// page 9 describes the xml to be sent for updating the transaction.
        /// </remarks>
        protected override bool AcquirePaymentInternal(Payment payment, out string status)
        {
            SecureTradingTransactionQueryXmlResponse transactionQueryResponse = _secureTradingXmlRequester.TransactionQuery(payment.TransactionId, payment.PaymentMethod);

            Guard.Against.PaymentStatusIsNotSuspended(transactionQueryResponse);

            SecureTradingTransactionUpdateXmlResponse updateSettleMentStatusResponse =
                _secureTradingXmlRequester.UpdateSettleMentStatus(payment.TransactionId, SecureTradingSettlementStatus.PendingSettlement, payment.PaymentMethod);

            if (updateSettleMentStatusResponse.ErrorCode == SecureTradingErrorCode.Success)
            {
                status = PaymentMessages.AcquireSuccess;
                payment.PaymentStatus = _paymentStatusRepository.Get((int)PaymentStatusCode.Acquired);
                return(true);
            }

            _loggingService.Log <SecureTradingPaymentMethodService>(string.Format("failed to acquire payment. Message: {0} Response was:\r\n {1}", updateSettleMentStatusResponse.ErrorMessage, updateSettleMentStatusResponse.XmlResponse));
            payment.PaymentStatus = _paymentStatusRepository.Get((int)PaymentStatusCode.AcquireFailed);
            status = string.Format("{0} - {1}", PaymentMessages.AcquireFailed, updateSettleMentStatusResponse.ErrorMessage);
            return(false);
        }
Exemplo n.º 2
0
        protected override bool CancelPaymentInternal(Payment payment, out string status)
        {
            SecureTradingTransactionQueryXmlResponse transactionQueryResponse = _secureTradingXmlRequester.TransactionQuery(payment.TransactionId, payment.PaymentMethod);

            Guard.Against.PaymentDoesNotQualifyForCancellation(transactionQueryResponse);

            SecureTradingTransactionUpdateXmlResponse cancelRequestResponse
                = _secureTradingXmlRequester.UpdateSettleMentStatus(payment.TransactionId, SecureTradingSettlementStatus.Cancelled, payment.PaymentMethod);

            if (cancelRequestResponse.ErrorCode == SecureTradingErrorCode.Success)
            {
                payment.PaymentStatus = _paymentStatusRepository.Get((int)PaymentStatusCode.Cancelled);
                status = PaymentMessages.CancelSuccess;
                return(true);
            }

            _loggingService.Log <SecureTradingPaymentMethodService>(string.Format("failed to cancel payment. Message: {0} Response was:\r\n {1}", cancelRequestResponse.ErrorMessage, cancelRequestResponse.XmlResponse));

            status = string.Format("{0} - {1}", PaymentMessages.CancelFailed, cancelRequestResponse.ErrorMessage);
            return(false);
        }