void it_should_parse_wpf_notifications() { var expectedWpfNotification = new WpfNotification() { NotificationType = "wpf", WpfUniqueId = "26aa150ee68b1b2d6758a0e6c44fce4c", WpfStatus = "approved", PaymentTransactionTransactionType = "sale", WpfTransactionId = "mtid201104081447161135536962", PaymentTransactionUniqueId = "bad08183a9ec545daf0f24c48361aa10", PaymentTransactionTerminalToken = "e9fd7a957845450fb7ab9dccb498b6e1f6e1e3aa", Signature = "c5219b3d385e74496b2b48a5497b347e102849f10eacd25b062f823b" }; var notificationData = String.Format("notification_type={0}&wpf_unique_id={1}&wpf_status={2}&payment_transaction_transaction_type={3}" + "&wpf_transaction_id={4}&payment_transaction_unique_id={5}&payment_transaction_terminal_token={6}&signature={7}", expectedWpfNotification.NotificationType, expectedWpfNotification.WpfUniqueId, expectedWpfNotification.WpfStatus, expectedWpfNotification.PaymentTransactionTransactionType, expectedWpfNotification.WpfTransactionId, expectedWpfNotification.PaymentTransactionUniqueId, expectedWpfNotification.PaymentTransactionTerminalToken, expectedWpfNotification.Signature); var wpfNotification = Notification.Parse(notificationData) as WpfNotification; wpfNotification.should_not_be_null(); wpfNotification.should_be(expectedWpfNotification); }
void it_should_render_correct_wpf_notification_response() { var wpfNotification = new WpfNotification() { WpfUniqueId = "26aa150ee68b1b2d6758a0e6c44fce4c" }; var xmlResponse = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<notification_echo xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"WpfNotification\">" + "<wpf_unique_id>" + wpfNotification.WpfUniqueId + "</wpf_unique_id>" + "</notification_echo>"; var expectedResponse = Encoding.UTF8.GetBytes(xmlResponse); var actualResponse = wpfNotification.GetEchoResponseBody(); actualResponse.should_be(expectedResponse); }
void when_determining_authenticity() { it["should recognize an authentic 3d notification"] = () => { var configuration = new Configuration(Environments.Staging, string.Empty, string.Empty, "bogus", certificate, Endpoints.EComProcessing); var threeDNotification = new ThreeDNotification() { Signature = "08d01ae1ebdc22b6a1a764257819bb26e9e94e8d", UniqueId = "fc6c3c8c0219730c7a099eaa540f70dc" }; threeDNotification.IsAuthentic(configuration).should_be_true(); }; it["should recognize a fake 3d notification"] = () => { var configuration = new Configuration(Environments.Staging, string.Empty, string.Empty, "boguS", certificate, Endpoints.EComProcessing); var threeDNotification = new ThreeDNotification() { Signature = "08d01ae1ebdc22b6a1a764257819bb26e9e94e8d", UniqueId = "fc6c3c8c0219730c7a099eaa540f70dc" }; threeDNotification.IsAuthentic(configuration).should_be_false(); }; it["should recognize an authentic wpf notification"] = () => { var configuration = new Configuration(Environments.Staging, string.Empty, string.Empty, "50fd87e65eb415f42fb5af4c9cf497662e00b785", certificate, Endpoints.EComProcessing); var wpfNotification = new WpfNotification() { Signature = "c5219b3d385e74496b2b48a5497b347e102849f10eacd25b062f823bbd11249ce4e233f031C0ecebc9b691e69d23eb0c1cd65a79621152467b56aC2bf103b512", WpfUniqueId = "26aa150ee68b1b2d6758a0e6c44fce4c" }; wpfNotification.IsAuthentic(configuration).should_be_true(); }; it["should recognize a fake wpf notification"] = () => { var configuration = new Configuration(Environments.Staging, string.Empty, string.Empty, "50Fd87e65eb415f42fb5af4c9cf497662e00b785", certificate, Endpoints.EComProcessing); var wpfNotification = new WpfNotification() { Signature = "c5219b3d385e74496b2b48a5497b347e102849f10eacd25b062f823bbd11249ce4e233f031C0ecebc9b691e69d23eb0c1cd65a79621152467b56aC2bf103b512", WpfUniqueId = "26aa150ee68b1b2d6758a0e6c44fce4c" }; wpfNotification.IsAuthentic(configuration).should_be_false(); }; }
private static WpfNotification CreateWpfNotification(NameValueCollection parameters) { var wpfNotification = new WpfNotification() { NotificationType = parameters.Get("notification_type"), PaymentTransactionTerminalToken = parameters.Get("payment_transaction_terminal_token"), PaymentTransactionTransactionType = parameters.Get("payment_transaction_transaction_type"), PaymentTransactionUniqueId = parameters.Get("payment_transaction_unique_id"), Signature = parameters.Get("signature"), WpfStatus = parameters.Get("wpf_status"), WpfTransactionId = parameters.Get("wpf_transaction_id"), WpfUniqueId = parameters.Get("wpf_unique_id") }; return wpfNotification; }