Beispiel #1
0
        private string CreateRequestXml <TRequestTxn>(Guid orderId, string transactionId, PaymentRequestMessage <TRequestTxn> requestMessage)
            where TRequestTxn : PaymentRequestTxn, new()
        {
            // Generate the complete request xml.

            var requestXml = Serialization.Serialize(requestMessage);

            try
            {
                // Record this request but anonymise any sensitive information.

                requestMessage = (PaymentRequestMessage <TRequestTxn>)requestMessage.Clone();
                requestMessage.MerchantInfo.Password = Anonymize(requestMessage.MerchantInfo.Password);
                if (requestMessage.Payment.TxnList.Txn is StandardPaymentRequestTxn)
                {
                    Anonymize((requestMessage.Payment.TxnList.Txn as StandardPaymentRequestTxn).CreditCardInfo);
                }
                else if (requestMessage.Payment.TxnList.Txn is AntiFraudPaymentRequestTxn)
                {
                    Anonymize((requestMessage.Payment.TxnList.Txn as AntiFraudPaymentRequestTxn).CreditCardInfo);
                }

                var purchaseRequest = new PurchaseRequest
                {
                    Time    = DateTime.Now,
                    Message = Serialization.Serialize(requestMessage),
                };
                _purchaseTransactionsCommand.CreatePurchaseRequest(orderId, transactionId, Provider, purchaseRequest);
            }
            catch (Exception)
            {
            }

            return(requestXml);
        }
Beispiel #2
0
        public void TestPurchase()
        {
            var orderId       = Guid.NewGuid();
            var transactionId = Guid.NewGuid().ToString();

            // Request.

            var request = new PurchaseRequest {
                Time = DateTime.Now, Message = RequestMessage
            };

            _purchaseTransactionsCommand.CreatePurchaseRequest(orderId, transactionId, Provider, request);
            AssertTransaction(orderId, transactionId, Provider, request, null, _purchaseTransactionsQuery.GetPurchaseTransactions(orderId));

            // Response.

            var response = new PurchaseResponse {
                Time = DateTime.Now, Message = ResponseMessage
            };

            _purchaseTransactionsCommand.CreatePurchaseResponse(orderId, transactionId, response);
            AssertTransaction(orderId, transactionId, Provider, request, response, _purchaseTransactionsQuery.GetPurchaseTransactions(orderId));
        }