public void ItShouldThrowArgumentExceptionForInvalidReturn() { // Arrange Gateway beanstream = new Gateway () { MerchantId = 300200578, PaymentsApiKey = "4BaD82D9197b4cc4b70a221911eE9f70", ApiVersion = "1" }; beanstream.WebCommandExecuter = _executer.Object; _returnRequest = null; // Act var ex = (ArgumentNullException)Assert.Throws(typeof(ArgumentNullException), () =>beanstream.Payments.UnreferencedReturn(_returnRequest)); // Assert Assert.That(ex.ParamName, Is.EqualTo("returnRequest")); }
public void Setup() { _returnRequest = new UnreferencedSwipeReturnRequest () { Amount = 100, OrderNumber = "Test1234" }; _executer = new Mock<IWebCommandExecuter>(); }
/// <summary> /// Return a previous swipe payment that was not made through Beanstream. Use this if you would like to /// return a payment but that payment was performed on another payment service. /// /// You must have this capability enabled on your account by calling Beanstream support. It is dangerous to /// have it enabled as the API will not check if you have a transaction ID. /// </summary> /// <returns>The return result</returns> /// <param name="returnRequest">Return request.</param> public PaymentResponse UnreferencedReturn(UnreferencedSwipeReturnRequest returnRequest) { Gateway.ThrowIfNullArgument (returnRequest, "returnRequest"); string url = BeanstreamUrls.ReturnsUrl .Replace("{v}", String.IsNullOrEmpty(_configuration.Version) ? "v1" : "v"+_configuration.Version) .Replace("{p}", String.IsNullOrEmpty(_configuration.Platform) ? "www" : _configuration.Platform) .Replace("{id}", "0"); // uses ID 0 since there is no existing payment ID for this transaction HttpsWebRequest req = new HttpsWebRequest () { MerchantId = _configuration.MerchantId, Passcode = _configuration.PaymentsApiPasscode, WebCommandExecutor = _webCommandExecuter }; returnRequest.MerchantId = _configuration.MerchantId.ToString(); string response = req.ProcessTransaction (HttpMethod.Post, url, returnRequest); return JsonConvert.DeserializeObject<PaymentResponse>(response); }