public void Excludes_optional_Item()
        {
            var test = new TestClass {Age = 4};
            var result = new HttpPostSerializer().Serialize(test);

            result.ShouldEqual("Age=4");
        }
        public void Serialized_properties()
        {
            var test = new TestClass {Name = "foo", Age = 4};
            var serializer = new HttpPostSerializer();

            var result = serializer.Serialize(test);
            result.ShouldEqual("Name=foo&Age=4");
        }
Exemplo n.º 3
0
        public TransactionRegistrationResponse Send(RequestContext context, string vendorTxCode, ShoppingBasket basket,
            Address billingAddress, Address deliveryAddress, string customerEmail)
        {
            string sagePayUrl = configuration.RegistrationUrl;
            string notificationUrl = urlResolver.BuildNotificationUrl(context);

            var registration = new TransactionRegistration(
                vendorTxCode, basket, notificationUrl,
                billingAddress, deliveryAddress, customerEmail,
                configuration.VendorName);

            var serializer = new HttpPostSerializer();
            var postData = serializer.Serialize(registration);

            var response = requestSender.SendRequest(sagePayUrl, postData);

            var deserializer = new ResponseSerializer();
            return deserializer.Deserialize<TransactionRegistrationResponse>(response);
        }
Exemplo n.º 4
0
		public RefundResponse Send(string vendorTxCode, string refundReason, decimal amount, string relatedVpsTxId,
		                           string relatedVendorTxCode, string relatedSecurityKey, string relatedAuthNo) {
			var registration = new RefundRegistration(configuration.VendorName,
			                                          vendorTxCode,
			                                          amount,
			                                          refundReason,
			                                          relatedVpsTxId,
			                                          relatedVendorTxCode,
			                                          relatedSecurityKey,
			                                          relatedAuthNo);

			string sagePayUrl = configuration.RefundUrl;

			var serializer = new HttpPostSerializer();
			var postData = serializer.Serialize(registration);
			var response = requestSender.SendRequest(sagePayUrl, postData);
			var deserializer = new ResponseSerializer();
			return deserializer.Deserialize<RefundResponse>(response);
		}
Exemplo n.º 5
0
		public TransactionRegistrationResponse Send(RequestContext context, string vendorTxCode, ShoppingBasket basket,
								Address billingAddress, Address deliveryAddress, string customerEmail, PaymentFormProfile paymentFormProfile = PaymentFormProfile.Normal, string currencyCode="GBP",
								MerchantAccountType accountType=MerchantAccountType.Ecommerce, TxType txType=TxType.Payment) {
			string sagePayUrl = configuration.RegistrationUrl;
			string notificationUrl = urlResolver.BuildNotificationUrl(context);

			var registration = new TransactionRegistration(
				vendorTxCode, basket, notificationUrl,
				billingAddress, deliveryAddress, customerEmail,
				configuration.VendorName,
				paymentFormProfile, currencyCode, accountType, txType);

			var serializer = new HttpPostSerializer();
			var postData = serializer.Serialize(registration);

			var response = requestSender.SendRequest(sagePayUrl, postData);

			var deserializer = new ResponseSerializer();
			return deserializer.Deserialize<TransactionRegistrationResponse>(response);
		}
 public void Formats_property()
 {
     var test = new TestClassWithFormat {Age = 5.5m};
     var result = new HttpPostSerializer().Serialize(test);
     result.ShouldEqual("Age=5.50");
 }
 public void Encodes_property()
 {
     var test = new TestClass {Name = "hello there"};
     var result = new HttpPostSerializer().Serialize(test);
     result.ShouldEqual("Name=hello+there&Age=0");
 }
 public void Does_not_encode_when_Unencoded_attribute_used()
 {
     var test = new TestClassWithUnencodedProperty {Name = "hello there"};
     var result = new HttpPostSerializer().Serialize(test);
     result.ShouldEqual("Name=hello there");
 }