public async Task CreateCreditWithTokenAndListCreditsTest() { try { var createTokenRequest = _tokenRequestBuilder.Build(); var token = await _gateway.CreateToken(createTokenRequest); var creditRequest = new CreditRequest() { Amount = 100, Currency = "EUR", Description = "desc", Card = _cardRequestBuilder.WithId(token.Id).Build() }; var newCredit = await _gateway.CreateCredit(creditRequest); var credits = await _gateway.ListCredits(); Assert.IsNotNull(credits.List.FirstOrDefault(c => c.Id == newCredit.Id)); } catch (SecurionPayException exc) { HandleApiException(exc); } }
public async Task ChargeCaptureRefundFlowTest() { try { var createTokenRequest = _tokenRequestBuilder.Build(); var token = await _gateway.CreateToken(createTokenRequest); token = await _gateway.RetrieveToken(token.Id); var chargeRequest = _chargeRequestBuilder.WithCard(_cardRequestBuilder.WithId(token.Id)) .WithIsCaptured(false) .Build(); var charge = await _gateway.CreateCharge(chargeRequest); var capture = new CaptureRequest() { ChargeId = charge.Id }; charge = await _gateway.CaptureCharge(capture); var refund = new RefundRequest() { ChargeId = charge.Id, Amount = 500 }; charge = await _gateway.RefundCharge(refund); charge = await _gateway.RetrieveCharge(charge.Id); Assert.IsTrue(charge.Captured); Assert.IsTrue(charge.Refunded); Assert.AreEqual(1, charge.Refunds.Count); Assert.AreEqual(500, charge.Refunds.First().Amount); Assert.AreEqual(chargeRequest.Amount - 500, charge.Amount); } catch (SecurionPayException exc) { HandleApiException(exc); } }
public async Task CreateTokenTest() { var requestTester = GetRequestTester(); var tokenRequest = _tokenRequestBuilder.Build(); await requestTester.TestMethod <Token>( async (api) => { await api.CreateToken(tokenRequest); }, new RequestDescriptor() { Method = HttpMethod.Post, Action = "tokens", Parameter = tokenRequest } ); }
public async Task CustomerWithCardTokenTest() { try { var createTokenRequest = _tokenRequestBuilder.Build(); var token = await _gateway.CreateToken(createTokenRequest); token = await _gateway.RetrieveToken(token.Id); var customerRequest = _customerRequestBuilder.WithCard(_cardRequestBuilder.WithId(token.Id)).Build(); var customer = await _gateway.CreateCustomer(customerRequest); Assert.AreEqual(1, customer.Cards.Count); Assert.AreEqual(createTokenRequest.CardholderName, customer.Cards.First().CardholderName); } catch (SecurionPayException exc) { HandleApiException(exc); } }