public override object Clone() { var clone = new PaymentResponseMessage <TTxn>(); CopyTo(clone); return(clone); }
private static void Check <TResponseTxn>(PaymentResponseMessage <TResponseTxn> message) where TResponseTxn : PaymentResponseTxn, new() { const string method = "Check"; // First check the status for effective system errors. if (message.Status.StatusCode != 0) { EventSource.Raise(Event.Error, method, "An invalid status has been returned from the payment gateway.", Event.Arg("StatusCode", message.Status.StatusCode), Event.Arg("StatusDescription", message.Status.StatusDescription)); throw new SecurePayStatusException(message.Status.StatusCode, message.Status.StatusDescription); } if (!message.Payment.TxnList.Txn.IsApproved) { EventSource.Raise(Event.Warning, method, "A credit card process has not been approved by the payment gateway.", Event.Arg("ResponseCode", message.Payment.TxnList.Txn.ResponseCode), Event.Arg("ResponseText", message.Payment.TxnList.Txn.ResponseText)); // Check for fraud. if (message.Payment.TxnList.Txn is AntiFraudPaymentResponseTxn) { var antiFraudTxn = message.Payment.TxnList.Txn as AntiFraudPaymentResponseTxn; if (!(string.IsNullOrEmpty(antiFraudTxn.AntiFraudResponseCode) || antiFraudTxn.AntiFraudResponseCode == "0" || antiFraudTxn.AntiFraudResponseCode == "00" || antiFraudTxn.AntiFraudResponseCode == "000")) { throw new SecurePayFraudException(antiFraudTxn.AntiFraudResponseCode, antiFraudTxn.AntiFraudResponseText, (FraudGuard)antiFraudTxn.FraudGuard.Clone()); } } throw new SecurePayNotApprovedException(message.Payment.TxnList.Txn.ResponseCode, message.Payment.TxnList.Txn.ResponseText); } }
public static RefundReceipt Map(PaymentResponseMessage <RefundResponseTxn> message) { return(new RefundReceipt { ExternalTransactionId = message.Payment.TxnList.Txn.ExternalTransactionId, ExternalTransactionTime = message.MessageInfo.MessageTimestamp.ToDateTime(), }); }
public static CreditCardReceipt Map <TTxn>(PaymentResponseMessage <TTxn> message) where TTxn : PaymentResponseTxn, new() { return(new CreditCardReceipt { ExternalTransactionId = message.Payment.TxnList.Txn.ExternalTransactionId, ExternalTransactionTime = message.MessageInfo.MessageTimestamp.ToDateTime(), CreditCard = new CreditCardSummary { Pan = message.Payment.TxnList.Txn.CreditCardInfo.Pan, Type = message.Payment.TxnList.Txn.CreditCardInfo.CardType, } }); }
private static PaymentResponseMessage <TResponseTxn> DeserializeWithXmlDocument <TResponseTxn>(string responseXml) where TResponseTxn : PaymentResponseTxn, new() { var message = new PaymentResponseMessage <TResponseTxn>(); var xmlDocument = new XmlDocument(); xmlDocument.LoadXml(responseXml); // Do it all by hand ... var xmlSecurePayMessage = xmlDocument.SelectSingleNode("/SecurePayMessage"); if (xmlSecurePayMessage != null) { // MessageInfo var xmlMessageInfo = xmlSecurePayMessage.SelectSingleNode("MessageInfo"); if (xmlMessageInfo != null) { Deserialize(xmlMessageInfo, message.MessageInfo); } // MerchantInfo var xmlMerchantInfo = xmlSecurePayMessage.SelectSingleNode("MerchantInfo"); if (xmlMerchantInfo != null) { Deserialize(xmlMerchantInfo, message.MerchantInfo); } // Status var xmlStatus = xmlSecurePayMessage.SelectSingleNode("Status"); if (xmlStatus != null) { Deserialize(xmlStatus, message.Status); } // Payment. message.Payment = DeserializePayment <TResponseTxn>(xmlSecurePayMessage); } return(message); }
private void CopyTo(PaymentResponseMessage <TTxn> clone) { base.CopyTo(clone); clone.Payment = (Payment <TTxn>)Payment.Clone(); }
private static void AdjustCents <TPaymentResponseTxn>(PaymentResponseMessage <TPaymentResponseTxn> message, int originalCents) where TPaymentResponseTxn : PaymentResponseTxn, new() { message.Payment.TxnList.Txn.Amount = originalCents; }