Ejemplo n.º 1
0
        public override object Clone()
        {
            var clone = new PaymentRequestMessage <TTxn>();

            CopyTo(clone);
            return(clone);
        }
Ejemplo n.º 2
0
        private static PaymentRequestMessage <AntiFraudPaymentRequestTxn> MapAntiFraud(Order order, Purchaser purchaser, CreditCard creditCard, Country country, string merchantId, string password)
        {
            var message = new PaymentRequestMessage <AntiFraudPaymentRequestTxn>
            {
                MerchantInfo =
                {
                    MerchantId = merchantId,
                    Password   = password
                }
            };

            message.Payment.TxnList.Txn.PurchaseId = order.Id;
            message.Payment.TxnList.Txn.Amount     = Map(order.AdjustedPrice, order.Currency);
            message.Payment.TxnList.Txn.Currency   = order.Currency;

            message.Payment.TxnList.Txn.CreditCardInfo.CardNumber = creditCard.CardNumber;
            message.Payment.TxnList.Txn.CreditCardInfo.Cvv        = creditCard.Cvv;
            message.Payment.TxnList.Txn.CreditCardInfo.ExpiryDate = creditCard.ExpiryDate;

            message.Payment.TxnList.Txn.BuyerInfo.Ip           = purchaser.IpAddress;
            message.Payment.TxnList.Txn.BuyerInfo.EmailAddress = purchaser.EmailAddress;
            var mappedCountry = Map(country);

            message.Payment.TxnList.Txn.BuyerInfo.BillingCountry  = mappedCountry;
            message.Payment.TxnList.Txn.BuyerInfo.DeliveryCountry = mappedCountry;

            return(message);
        }
Ejemplo n.º 3
0
        private static int AdjustCents <TPaymentRequestTxn>(PaymentRequestMessage <TPaymentRequestTxn> requestMessage)
            where TPaymentRequestTxn : PaymentRequestTxn, new()
        {
            var originalAmount = requestMessage.Payment.TxnList.Txn.Amount;

            requestMessage.Payment.TxnList.Txn.Amount = originalAmount - (originalAmount % 100);
            return(originalAmount);
        }
Ejemplo n.º 4
0
        public static PaymentRequestMessage <RefundRequestTxn> Map(Guid orderId, string externalTransactionId, string merchantId, string password)
        {
            var message = new PaymentRequestMessage <RefundRequestTxn>
            {
                MerchantInfo =
                {
                    MerchantId = merchantId,
                    Password   = password
                }
            };

            message.Payment.TxnList.Txn.PurchaseId            = orderId;
            message.Payment.TxnList.Txn.ExternalTransactionId = externalTransactionId;
            return(message);
        }
Ejemplo n.º 5
0
        private static PaymentRequestMessage <StandardPaymentRequestTxn> MapStandard(Order order, CreditCard creditCard, string merchantId, string password)
        {
            var message = new PaymentRequestMessage <StandardPaymentRequestTxn>
            {
                MerchantInfo =
                {
                    MerchantId = merchantId,
                    Password   = password
                }
            };

            message.Payment.TxnList.Txn.PurchaseId = order.Id;
            message.Payment.TxnList.Txn.Amount     = Map(order.AdjustedPrice, order.Currency);
            message.Payment.TxnList.Txn.Currency   = order.Currency;

            message.Payment.TxnList.Txn.CreditCardInfo.CardNumber = creditCard.CardNumber;
            message.Payment.TxnList.Txn.CreditCardInfo.Cvv        = creditCard.Cvv;
            message.Payment.TxnList.Txn.CreditCardInfo.ExpiryDate = creditCard.ExpiryDate;

            return(message);
        }
Ejemplo n.º 6
0
 protected void CopyTo(PaymentRequestMessage <TTxn> clone)
 {
     base.CopyTo(clone);
     clone.Payment = (Payment <TTxn>)Payment.Clone();
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        PaymentResponseMessage <TResponseTxn> ISendSecurePayCommand.Send <TRequestTxn, TResponseTxn>(PaymentRequestMessage <TRequestTxn> requestMessage)
        {
            var originalCents = 0;

            if (_ignoreCents)
            {
                originalCents = AdjustCents(requestMessage);
            }

            // Create the request.

            var orderId       = requestMessage.Payment.TxnList.Txn.PurchaseId;
            var transactionId = requestMessage.MessageInfo.MessageId.ToString();

            var requestXml      = CreateRequestXml(orderId, transactionId, requestMessage);
            var responseXml     = Send(requestXml);
            var responseMessage = CreateResponse <TResponseTxn>(orderId, transactionId, responseXml);

            if (_ignoreCents)
            {
                AdjustCents(responseMessage, originalCents);
            }

            return(responseMessage);
        }