Purchase() public method

Attempts to debit the specified amount from the supplied payment card.
Because the SagePay gateway requires a shopping basket, this overload will create a simple basket containing a single line item whose description is auto-generated from the supplied order details.
public Purchase ( string merchantReference, Kurejito.Payments.Money amount, PaymentCard card ) : PaymentResponse
merchantReference string
amount Kurejito.Payments.Money
card Kurejito.Payments.PaymentCard
return PaymentResponse
 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);
 }
        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_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
 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();
 }