A payment gateway interface to the SagePay VspDirect payment system.
Inheritance: IPurchase
        private void Verify_Sagepay_Status_Code(string sagePayStatus, PaymentStatus expectedStatus)
        {
            var http = new Mock<IHttpPostTransport>();
            http
                .Setup(h => h.Post(It.IsAny<Uri>(), It.IsAny<string>()))
                .Returns(this.MakePostResponse(sagePayStatus));

            var gw = new SagePayPaymentGateway(http.Object, VENDOR_NAME, VPS_PROTOCOL, GatewayMode.Simulator);
            var card = new PaymentCard("I M LOADED", "123412341234134", "1212", "123", CardType.Visa);
            var response = gw.Purchase("123456", new Money(123.45m, new Currency("GBP")), card);
            Assert.Equal(expectedStatus, response.Status);
        }
 public void SagePay_Response_Contains_Payment_Id()
 {
     var http = new Mock<IHttpPostTransport>();
     var vpsTxId = "{00001111-2222-3333-4444-556677889900}";
     var sagepay = new SagePayPaymentGateway(http.Object, "rockshop", 2.23m, GatewayMode.Live);
     http
         .Setup(h => h.Post(It.IsAny<Uri>(), It.IsAny<string>()))
         .Returns(this.MakePostResponse("OK", vpsTxId));
     var card = new PaymentCard("I M LOADED", "123412341234134", "1212", "123", CardType.Visa);
     var response = sagepay.Purchase("1234", new Money(123.45m, new Currency("GBP")), card);
     Assert.Equal(vpsTxId, response.PaymentId);
 }
 public void SagePay_Post_With_No_Basket_Creates_Simple_Basket()
 {
     http.Setup(h => h.Post(It.IsAny<Uri>(), It.IsAny<string>()))
         .Callback((Uri uri, string post) => {
             var values = HttpUtility.ParseQueryString(post);
             Assert.Equal("1:Transaction ref 1234:::::123.45", values["basket"]);
         })
         .Returns(MakePostResponse("OK"));
     var sagePay = new SagePayPaymentGateway(http.Object, VENDOR_NAME, VPS_PROTOCOL, GatewayMode.Simulator);
     sagePay.Purchase("1234", new Money(123.45m, new Currency("GBP")), card);
     http.VerifyAll();
 }
Beispiel #4
0
 private void VerifyPurchasePostUrl(GatewayMode mode, string postUri)
 {
     http.Setup(h => h.Post(new Uri(postUri), It.IsAny<string>())).Returns(MakePostResponse("OK"));
     var sagePay = new SagePayPaymentGateway(http.Object, "myVendor", 2.23m, mode);
     sagePay.Purchase("123", new Money(123.45m, new Currency("GBP")), card);
     http.VerifyAll();
 }
Beispiel #5
0
 public SagePayUnitTests()
 {
     http = new Mock<IHttpPostTransport>();
     gateway = new SagePayPaymentGateway(http.Object, VENDOR_NAME, VPS_PROTOCOL, GatewayMode.Simulator);
     card = new PaymentCard("I M LOADED", "13412341341234", "1212", "123", CardType.Visa);
 }
Beispiel #6
0
 private void VerifyPurchasePostUrl(GatewayMode mode, string postUri)
 {
     http.Setup(h => h.Post(new Uri(postUri), It.IsAny<string>()));
     var sagePay = new SagePayPaymentGateway(http.Object, "myVendor", 2.23m, mode);
     sagePay.Purchase("123", 123.45m, "GBP", card);
     http.VerifyAll();
 }