public MolliePaymentsProcessor(IWebHelper webHelper, ILocalizationService localizationService, ISettingService settingService, IHttpContextAccessor httpContextAccessor, IAddressService addressService, IStateProvinceService stateProvinceService, ICountryService countryService, ICurrencyService currencyService, IProductService productService, IOrderService orderService, CurrencySettings currencySettings, MollieStandardPaymentSettings mollieStandardPaymentSettings) { _webHelper = webHelper; _localizationService = localizationService; _settingService = settingService; _httpContextAccessor = httpContextAccessor; _addressService = addressService; _stateProvinceService = stateProvinceService; _countryService = countryService; _currencyService = currencyService; _currencySettings = currencySettings; _productService = productService; _orderService = orderService; _mollieStandardPaymentSettings = mollieStandardPaymentSettings; _mollieOrderClient = MollieAPIClients.MollieOrderClient( _mollieStandardPaymentSettings.UseSandbox, GetKeysDictionary()); _refundClient = MollieAPIClients.MollieRefundClient( _mollieStandardPaymentSettings.UseSandbox, GetKeysDictionary()); }
public async Task CanRetrieveRefundList() { // If: We create a payment PaymentResponse payment = await CreatePayment(); // When: Retrieve refund list for this payment ListResponse <RefundResponse> refundList = await RefundClient.GetRefundListAsync(payment.Id); // Then Assert.IsNotNull(refundList); Assert.IsNotNull(refundList.Items); }
public async Task GetRefundAsync_TestModeParameterCase_QueryStringOnlyContainsTestModeParameterIfTrue(string expectedUrl, bool?testModeParameter) { // Given: We make a request to retrieve a payment without wanting any extra data bool testMode = testModeParameter ?? false; var mockHttp = this.CreateMockHttpMessageHandler(HttpMethod.Get, $"{BaseMollieClient.ApiEndPoint}{expectedUrl}", defaultGetRefundResponse); HttpClient httpClient = mockHttp.ToHttpClient(); RefundClient refundClient = new RefundClient("abcde", httpClient); // When: We send the request await refundClient.GetRefundAsync("paymentId", "refundId", testmode : testMode); // Then mockHttp.VerifyNoOutstandingExpectation(); }
public async Task CanCreatePartialRefund() { // If: We create a payment of 250 euro PaymentResponse payment = await CreatePayment("250.00"); // We can only test this if you make the payment using the payment.Links.PaymentUrl property. // If you don't do this, this test will fail because we can only refund payments that have been paid Debugger.Break(); // When: We attempt to refund 50 euro RefundRequest refundRequest = new RefundRequest() { Amount = new Amount(Currency.EUR, "50.00") }; RefundResponse refundResponse = await RefundClient.CreateRefundAsync(payment.Id, refundRequest); // Then Assert.AreEqual("50.00", refundResponse.Amount.Value); }
public async Task CanCreateRefund() { // If: We create a payment string amount = "100.00"; PaymentResponse payment = await CreatePayment(amount); // We can only test this if you make the payment using the payment.Links.Checkout property. // If you don't do this, this test will fail because we can only refund payments that have been paid Debugger.Break(); // When: We attempt to refund this payment RefundRequest refundRequest = new RefundRequest() { Amount = new Amount(Currency.EUR, amount) }; RefundResponse refundResponse = await RefundClient.CreateRefundAsync(payment.Id, refundRequest); // Then Assert.IsNotNull(refundResponse); }
public async Task CanRetrieveSingleRefund() { // If: We create a payment PaymentResponse payment = await CreatePayment(); // We can only test this if you make the payment using the payment.Links.PaymentUrl property. // If you don't do this, this test will fail because we can only refund payments that have been paid Debugger.Break(); RefundRequest refundRequest = new RefundRequest() { Amount = new Amount(Currency.EUR, "50.00") }; RefundResponse refundResponse = await RefundClient.CreateRefundAsync(payment.Id, refundRequest); // When: We attempt to retrieve this refund RefundResponse result = await RefundClient.GetRefundAsync(payment.Id, refundResponse.Id); // Then Assert.IsNotNull(result); Assert.AreEqual(refundResponse.Id, result.Id); Assert.AreEqual(refundResponse.Amount.Value, result.Amount.Value); Assert.AreEqual(refundResponse.Amount.Currency, result.Amount.Currency); }