public string CreateReadyToTriggerPaymentXml(SecurePayCardInfo card, string customerId, SecurePayPayment payment) { ValidatePayment(payment); return new XDocument( new XDeclaration("1.0", "utf-8", "no"), new XElement("SecurePayMessage", new XElement("MessageInfo", new XElement("messageID", CreateMessageId()), new XElement("messageTimestamp", GetTimeStamp(DateTime.Now)), new XElement("timeoutValue", _connectionTimeoutSeconds), new XElement("apiVersion", "spxml-3.0")), // NOTE <-- Different to Single payments new XElement("MerchantInfo", new XElement("merchantID", _merchantId), new XElement("password", _password)), new XElement("RequestType", "Periodic"), // NOTE <--DIFF new XElement("Periodic", new XElement("PeriodicList", new XAttribute("count", "1"), new XElement("PeriodicItem", new XAttribute("ID", "1"), new XElement("actionType", "add"), new XElement("clientID", customerId), new XElement("CreditCardInfo", new XElement("cardNumber", card.Number), new XElement("expiryDate", card.GetExpiry())), new XElement("amount", payment.Amount), new XElement("currency", payment.Currency.ToUpper()), new XElement("periodicType", "4") // << Triggered Payment ))))).ToStringWithDeclaration(); }
/// <summary> /// TODO: replace this with creation of a SecurePayMessage object /// </summary> public string SinglePaymentXml(SecurePayCardInfo card, SecurePayPayment payment, string purchaseOrderNo) { card.ValidateExpiry(); return new XDocument( new XDeclaration("1.0", "utf-8", "no"), new XElement("SecurePayMessage", new XElement("MessageInfo", new XElement("messageID", "757a5be5b84b4d8ab84ec03ebd24af"), new XElement("messageTimestamp", GetTimeStamp(DateTime.Now)), new XElement("timeoutValue", _connectionTimeoutSeconds), new XElement("apiVersion", "xml-4.2")), new XElement("MerchantInfo", new XElement("merchantID", _merchantId), new XElement("password", _password)), new XElement("RequestType", "Payment"), new XElement("Payment", new XElement("TxnList", new XAttribute("count", "1"), new XElement("Txn", new XAttribute("ID", "1"), new XElement("txnType", "0"), new XElement("txnSource", "0"), new XElement("amount", payment.Amount), new XElement("currency", payment.Currency.ToUpper()), new XElement("purchaseOrderNo", purchaseOrderNo), new XElement("CreditCardInfo", new XElement("cardNumber", card.Number), new XElement("expiryDate", card.GetExpiry()) )))))).ToStringWithDeclaration(); }