예제 #1
0
        public static TransactionResult GetTransaction(string transactionGuidInput, string paymentGuidInput, string transactioGroupInput)
        {
            Guid transactionGuid      = Guid.Empty;
            Guid paymentGuid          = Guid.Empty;
            Guid transactionGroupGuid = Guid.Empty;

            if (!Guid.TryParse(transactionGuidInput, out transactionGuid) || !Guid.TryParse(paymentGuidInput, out paymentGuid) || !Guid.TryParse(transactioGroupInput, out transactionGroupGuid))
            {
                return(null);
            }

            Payment payment = Payment.CreateManager().Load(paymentGuid, GuidType.Internal);

            if (payment == null)
            {
                return(null);
            }

            ServiceLookupMethodMap slmm = ServiceLookupMethodMap.CreateManager().Load(payment.ServiceOffer.Service, payment.PaymentRequest.Customer.Country, LookupMethod.Wap);

            TransactionClient transactionClient = new TransactionClient();

            transactionClient.AttachLogWriter(new CashflowLog(payment.ServiceOffer.Service));

            GetTransactionsRequest getTransactionRequest = new GetTransactionsRequest(RequestMode.Default,
                                                                                      payment.ExternalPaymentGuid.ToString(),
                                                                                      slmm.PaymentConfiguration.PaymentCredentials.Username,
                                                                                      slmm.PaymentConfiguration.PaymentCredentials.Password,
                                                                                      transactionGroupGuid,
                                                                                      null);

            GetTransactionsResponse getTransactionResponse = transactionClient.GetTransactions(getTransactionRequest, null);

            foreach (Cashflow.Message.Data.Transaction transaction in getTransactionResponse.Transactions)
            {
                if (transaction.TransactionID == transactionGuid)
                {
                    return new TransactionResult()
                           {
                               Transaction = transaction,
                               Username    = slmm.PaymentConfiguration.PaymentCredentials.Username,
                               Password    = slmm.PaymentConfiguration.PaymentCredentials.Password
                           }
                }
            }
            ;

            return(null);
        }