public async Task ChargeCardWithInsufficientFoundsTest() { try { var customerRequest = _customerRequestBuilder.Build(); var customer = await _gateway.CreateCustomer(customerRequest); var chargeRequest = _chargeRequestBuilder.WithCustomerId(customer.Id).WithCard(_cardRequestBuilder).Build(); var charge = await _gateway.CreateCharge(chargeRequest); } catch (SecurionPayException exc) { Assert.AreEqual(ErrorCode.InsufficientFunds, exc.Error.Code); } }
public async Task ChargeCardTest() { try { var customerRequest = _customerRequestBuilder.Build(); var customer = await _gateway.CreateCustomer(customerRequest); var cardRequest = _cardRequestBuilder.WithCustomerId(customer.Id).Build(); var card = await _gateway.CreateCard(cardRequest); card = await _gateway.RetrieveCard(customer.Id, card.Id); Assert.AreEqual(cardRequest.GetLast4(), card.Last4); Assert.AreEqual(cardRequest.ExpMonth, card.ExpMonth); Assert.AreEqual(cardRequest.ExpYear, card.ExpYear); Assert.AreEqual(cardRequest.CardholderName, card.CardholderName); var chargeReqest = _chargeRequestBuilder.WithCustomerId(customer.Id) .Build(); var charge = await _gateway.CreateCharge(chargeReqest); Assert.AreEqual(chargeReqest.Amount, charge.Amount); } catch (SecurionPayException exc) { HandleApiException(exc); } }
private async Task <Charge> CreateChargeWithDispute(CustomerRequest customerRequest) { var customer = await _gateway.CreateCustomer(customerRequest); var chargeRequest = _chargeRequestBuilder.WithCustomerId(customer.Id) .WithCard(_cardRequestBuilder.WithNumberCausingDispute()) .Build(); int retryCount = 0; Charge chargeWithDispute; do { var charge = await _gateway.CreateCharge(chargeRequest); await Task.Delay((int)_retryInterval.TotalMilliseconds); chargeWithDispute = await _gateway.RetrieveCharge(charge.Id); retryCount++; }while (retryCount <= _maxRetries && !chargeWithDispute.Disputed); Assert.IsTrue(chargeWithDispute.Disputed); return(chargeWithDispute); }